Sample Assignment

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

We had studied the flowing case scenario in the classroom.

I am attaching the same


here again as example.
You own a company that sells Home Products, Beauty Products and Health
Products. Multiple wholesalers are your customers who order these products from
you. Each product can be ordered in multiple orders and each order can consist of
multiple products.
Following ERD shows these relations

Category

has

Product
M
in

Customer

gives

M
Sales Order

Therefore the table structure now will be as follows :


Category

Product

Customer

SalesOrder Hdr

Cat_Id (PK)
Cat_Name

Prod_Id (PK)
Prod_Name
Prod_Rate
Prod_UOM
Cat_Id(FK)

Cust_Id (PK)
Cust_Name
Cust_Address
Cust_Email
Cust_Phone

Inv_Id (PK)
Inv_Dt
Cust_Id (FK)
Total Amount

SalesOrder Det
Inv_Id (FK) PK
Prod_Id (FK)
Qty
Item Amount

In the above solution, We have enumerated a few fields only in each table. We
expect detailing as far as possible for the assignment tables.
Relationships between two tables can be 1:1 or 1:M or M:N
When relation is 1:M the primary key of the first table goes into second as foreign
key. Eg: Cat_Id in Product Table or Cust_Id in Sales Order Hdr
When two tables have many to many relation a third table is created where the
primary keys of participating tables are taken as foreign key and together they form
primary key (composite) Eg: Inv_Id and Prod_Id in Sales Order Det Table (Third
Table)

You might also like