You work as a Database Designer for Realtech Inc. You want to create two tables, Product and Order,
such that a row in the Order table does not exist without a corresponding row in the Product table.
The structure of the Product and Order tables with their respective columns is given below:
Product
ProductID
ProductNumber
Date_of_manufacturing
SupplierID
ProductPrice
ProductQty
Order
OrderID
OrderDate
OrderQuantity
OrderPrice
Based on this information, while maintaining the integrity of this rule, what will you do to
accomplish the task?
A.
Create the Product table, and then create the Order table. Create a third table that will be
used to join the Product and Order tables by using FOREIGN KEY constraints.
B.
Create the Product table, and then create the Order table that has a primary key referenced
by the foreign key in the Product table.
C.
Create the Product table, and then create the Order table. Create a primary key in both the
tables and form a one-to-one relationship.
D.
Create the Product table, and then create the Order table that has a foreign key constraint
that references the primary key in the Product table.
Explanation:
The Product table and the Order table will have a one-to-many relationship. To form this
relationship, you will have to add a column in the
Order table, and create a foreign key constraint on that column such that it references the primary
key in the Product table. Suppose
ProductID is designated as the primary key of the Product table, then it will have to be migrated to
the Order table to maintain the referential
integrity constraint.