DBMS Cat 3
DBMS Cat 3
Cat 3(exam)
Group no:- 20
Question no:-10
10.A salesperson may manage many other salespeople. A
salesperson is managed by only one salespeople. A salesperson
can be an agent for many customers. A customer is managed by
one salespeople. A customer can place many orders. An order
can be placed by one customer. An order lists many inventory
items. An inventory item may be listed on many orders. An
inventory item is assembled from many parts. A part may be
assembled into many inventory items. Many employees assemble
an inventory item from many parts. A supplier supplies many
parts. A part may be supplied by many suppliers.
For customer:-
For order:-
For product:-
For employee:-
For supplier:-
In this diagram :-
PRIMARY KEY:- The PRIMARY KEY constraint uniquely identifies each record in a table. A
table can have only one primary key, which may consist of one single or of multiple fields.
ACCORDING TO THIS POINT THE PRIMARY KEYS OF THESE TABLE.
1.In salesperson table the primary key is Sperson id.
2.In customer table the primary key is customer id.
3.in order table the primary key is order id.
4.in product table the primary key is product id.
5.in employee table the primary key is id.
6.in supplier table the primary key is company name.
Foreign key:- The foreign key constraint is a key used to link two tables
together.
CREATE TABLE Orders (
OrderID int NOT NULL,
OrderNumber int NOT NULL,
PersonID int,
PRIMARY KEY (OrderID),
FOREIGN KEY (SPersonID) REFERENCES SPersons(SPersonID)
);
1.IF we want to link with two table (i.e link with product table and employee
table here employee id is a foreign key.