Documente Academic
Documente Profesional
Documente Cultură
1
1 Supplier-Part Case Study
Consider a sample database to store the information about Supplier, Parts and quantity
supplied by the suppliers. The database consists of three tables S, P and SP.
Table S (Supplier table) contains the information about the suppliers and having following
fields:
Table P (Part table) contains the information about the parts and having following fields:
S Table
Column Data Type Width Constrains
Name
Sno Varchar2 5 Primary Key
Sname Varchar2 20 Unique
City Varchar2 20 City must be New Delhi, Patiala, Amritsar
and Qadian
Stauts Number 3 Must be grea/ter than 10
P Table
Column Data Type Width Constrains
Name
Pno Varchar2 5 Primary Key
Pname Varchar2 20 Unique
Color Varchar2 20 Not Null
City Varchar2 20 City must be Jalandhar, Patiala, Amritsar
and Qadian
SP Table
Column Data Type Width Constrains
Name
Sno Varchar2 5 Refers Sno of Supplier table
Pno Varchar2 5 Refers Pno of Part table
Qty Number 4 Must be greater than 100
Identify the primary key of SP table and apply Primary constraint on that.
S Table
SNO NAME CITY STATUS
S1 SUNEET QADIAN 20
S2 ANKIT AMRITSAR 10
S3 AMIT PATIALA 30
P Table
PNO NAME COLOR CITY
P1 NUT RED QADIAN
P2 BOLT GREEN AMRITSAR
P3 SCREW BLUE JALANDHAR
P4 SCREW RED QADIAN
SP Table
SNO PNO QTY
S1 P1 250
S1 P2 300
S1 P3 500
S2 P1 250
S2 P2 500
S3 P2 300
1. Check the working of all the constraints by inserting the invalid data in the corresponding
columns.
1. For each part supplied get part number and names of all cities supplying the part.
2. Get Qty supplied for Red parts.
3. Get Sname supplying Red part.
4. Get Sname, Pname who supply qty more than 100.
5. Get all pairs of suppliers numbers such that the two suppliers are located in the same
city.
6. Get Sname for suppliers who supply part P2.
7. Get Supplier numbers for suppliers who supply at least one part supplied by supplier S2.
8. Get supplier names for suppliers who do not supply part P2.
9. Get suppliers numbers for suppliers who are located in same city as supplier S1.