Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Exercises of SQL uAnswer the following questions, based on the database below. wSupplier (SNO, SNAME, STATUS, CITY) wPart(PNO, PNAME, COLOR, WEIGHT)

Similar presentations


Presentation on theme: "1 Exercises of SQL uAnswer the following questions, based on the database below. wSupplier (SNO, SNAME, STATUS, CITY) wPart(PNO, PNAME, COLOR, WEIGHT)"— Presentation transcript:

1 1 Exercises of SQL uAnswer the following questions, based on the database below. wSupplier (SNO, SNAME, STATUS, CITY) wPart(PNO, PNAME, COLOR, WEIGHT) wProject(JNO, JNAME, CITY) wSPJ(SNO, PNO, JNO, QTY) uThe schema has four relations. The key attributes for each relation are shown in red.

2 2 u1.Give suitable declarations for each relation. u2.Write the following queries: w(1)Find the name and city of all the Supplier. w(2)Find the name, color and weight of all the parts. w(3)Find the number of all the projects using the parts that provided by S1. w(4)Find the name and quantity of all the parts used by J2. w(5)Find the number of all the parts made in ShangHai. w(6)Find the name of all the projects which have used the parts made in ShangHai.

3 3 w(7)Find the number of all the projects that didn’t used the parts made in TianJin. w(8)Update all the parts which color is red with blue. w(9)Update the Supplier S5 of the part P6 used by J4 with Supplier S3. w(10)Delete all the records about S2 from relation Supplier, and delete corresponding records from relation SPJ. w(11)Insert a new record(S2, J6, P4, 200) into relation Supplier. w(12)Grant the INSERT privilege on table Supplier to user John, and he includes the grant option with this privilege. w(13)Grant the SELECT privilege on table SPJ and UPDATE privilege on attribute QTY of SPJ to user Allice.

4 4 u3.Construct a view ThirdProj giving the Supplier number(Sno), part number(Pno), supporting quantity(QTY) of all Supplier who provide parts for “Third Project”. Write each of the queries using this view. w(1)Find the part number and supporting quantity of all parts used by “Third Project”. w(2)Find the supporting relation of S1.


Download ppt "1 Exercises of SQL uAnswer the following questions, based on the database below. wSupplier (SNO, SNAME, STATUS, CITY) wPart(PNO, PNAME, COLOR, WEIGHT)"

Similar presentations


Ads by Google