Menu

[solved]-Using Php Mysql Add New Record Table Following Database Display Website First Normal Form Q39089237

Using PHP and MySQL add a new record to each table in thefollowing database and display them in a website.

First Normal Form (1NF) :

1NF says all the columns in the table should be automic innature.
No duplicate columns and repeating group of columns are allowed in1NF.

Given table is in the 1NF because all columns are automic innature and no duplicate and multivalued columns exists.

Second Normal Form (2NF) :

2NF says table should be in the 1NF.
In 2NF partial dependency is not allowed.
Partial dependency means non key column should depends upon primarykey column.

Here above schema needs to normalize into 2NF to remove partialdependency.Need to identify new tables like

Customer :This table stores customer details.
Product:This table stores product details
Order :This table stores order details.

Below are tables in 2NF.

1.Table Name :Customer

Description :This table stores customer details like CustomerID,CustomerFirstName and CustomerLastName.

Schema :Customer (CustomerID ,CustomerFirstName,CustomerLastName)

FD:CustomerID ==> CustomerFirstName and CustomerLastName

2.Table Name :Product

Description :This table stores product details like ProductID,ProductName and ProductPrice.

Schema :Product(ProductID ,ProductName ,ProductPrice)

FD:ProductID ==>ProductName ,ProductPrice

3.Table Name :Order

Description :This table stores order details likeOrderId,OrderDate and ShippingDate .

Schema :Order(OrderId,OrderDate ,ShippingDate)

FD:OrderId ==>OrderDate ,ShippingDate

Third Normal Form (3NF):

3NF says table should be in the 2NF.
In 3NF transitive dependency is not allowed.
Transitive dependency means non key column in the table shoulddepends on non key column in the table.

Here above table needs to normalize into 3NF to removetransitive dependency.Below are tables in 3NF.

1.Table Name :Customer

Description :This table stores customer details like CustomerID,CustomerFirstName and CustomerLastName.

Schema :Customer (CustomerID ,CustomerFirstName,CustomerLastName)

FD:CustomerID ==> CustomerFirstName and CustomerLastName

2.Table Name :Product

Description :This table stores product details like ProductID,ProductName and ProductPrice.

Schema :Product(ProductID ,ProductName ,ProductPrice)

FD:ProductID ==>ProductName ,ProductPrice

3.Table Name :Order

Description :This table stores order details likeOrderId,OrderDate and ShippingDate , along with customerdetails.

Schema :Order(OrderId,OrderDate ,ShippingDate,CustomerID)

FD:OrderId,CustomerID ==>OrderDate ,ShippingDate

4.Table Name :OrderDetails

Description :This table stores order details like OrderId andProductID.

NOTE :This table is formed because an order can have any numberof product and orderID is primary key in order table so which cannot be duplicate in order table but as orderID is foreign key inOrderDetails which can be duplicate.

Schema :OrderDetails(OrderId,ProductID)

***********************************

Tables in MYSQL :

1.Table Name :Customer

create TABLE customer(
CustomerID int primary key,
CustomerFirstName varchar(20) not null,
CustomerLastName varchar(20) not null
);

2.Table Name :Product

create TABLE product(
ProductID int primary key,
ProductName varchar(20) not null,
ProductPrice decimal(6,2) not null
);

3.Table Name :Order

create TABLE `order`(
OrderID int primary key,
OrderDate date not null,
ShippingDate date not null,
customerID int not null,
foreign key (customerID) REFERENCES customer (customerID)
);

4.Table Name :OrderDetails

create TABLE orderDetails(
OrderID int,
ProductID int not null,
primary key (OrderID,ProductID),
foreign key (OrderID) REFERENCES `order` (OrderID),
foreign key (ProductID) REFERENCES product (ProductID)
);

Expert Answer


Answer to Using PHP and MySQL add a new record to each table in the following database and display them in a website. First Normal… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *