COSC 51023 - Worksheet 01
COSC 51023 - Worksheet 01
Work Sheet 01
1. Create the following four Relations for the database using create table statements.
J1 SORTER KANDY
J2 PUNCH MATARA
J3 READER JAFFNA
J4 CONSOLE JAFFNA
J5 COLLATOR COLOMBO
J6 VIDEO GALLE
J7 TAPE COLOMBO
S1 SAMAN 20 COLOMBO
S2 JAGATH 10 KANDY
S3 ANIL 30 KANDY
S4 GAMINI 20 COLOMBO
S5 BALA 30 JAFFNA
SPJ
S1 P1 J1 200
S1 P2 J4 700
S2 P3 J2 200
S2 P3 J3 200
S2 P3 J4 500
S2 P3 J5 600
S2 P3 J6 400
S2 P3 J7 800
S2 P5 J2 100
S3 P3 J3 200
S3 P4 J4 500
S4 P2 J1 300
S4 P2 J4 300
S5 P1 J2 1000
S5 P2 J2 200
S5 P2 J4 100
S5 P3 J4 1200
S5 P4 J4 800
S5 P5 J4 400
S5 P5 J5 500
S5 P5 J7 100
S5 P6 J2 200
S5 P6 J4 500
2. First, work by yourselves, then check with the below answers (there can be slight
differences than below answers).
CREATE TABLE S
SNAME VARCHAR(20),
STATUS NUMBER,
CITY VARCHAR(15));
CREATE TABLE P
PNAME VARCHAR(20),
PRICE NUMBER,
WEIGHT NUMBER,
COLOUR VARCHAR(5),
CITY VARCHAR(15));
CREATE TABLE J
JNAME VARCHAR(20),
CITY VARCHAR(15));
Quantity NUMBER);
Insert into P(Pno, Pname, Price, COLOUR, Weight, City) values('P1', 'NUT', 20, 'RED', 12, 'COLOMBO');
l. Get supplier names for suppliers who are not currently supplying part P2
li. Get the supplier names for suppliers who currently supply all parts
lii. Get the supplier name for suppliers who currently supply all parts that are supplied by
S1
liii. Get the supplier name for suppliers for whom there is some part that is not being
supplied by the supplier
liv. Get part numbers for parts that either weigh more than 18 pounds or are currently
supplied by supplier S2.
a. Delete supplier S1
d. …