Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Session 3 Welcome: To session 3-the 8 th. learning sequence “Relational algebra “ Recap : In the previous learning sequence, we discussed some example.

Similar presentations


Presentation on theme: "1 Session 3 Welcome: To session 3-the 8 th. learning sequence “Relational algebra “ Recap : In the previous learning sequence, we discussed some example."— Presentation transcript:

1 1 Session 3 Welcome: To session 3-the 8 th. learning sequence “Relational algebra “ Recap : In the previous learning sequence, we discussed some example queries. Present learning: We shall explore the following topic: xample Queries. - Another example Queries.

2 2 Relational Algebra

3 uA basic expression in the relational algebra consists of either one of the following: wA relation in the database wA constant relation

4 Relational Instances for the Purchasing System The Supplier relation: S-numberS-nameS-city S100AhmedAmman S200AliJarash S300KasimIrbid S400JasimAquaba S500RanaAmman

5 5 The Part relation: P-numberP-nameColorPriceP-city P1TVSilver300Amman P2CameraBlack100Jarash P3VideoBlack200Amman P4PCSilver400Irbid P5PrinterRed100Irbid P6Scannersilver150Jarash

6 6 The shipment relation: S-numberP-numberQuantity S100P1100 S100P2150 S100P3200 S100P4160 S100P550 S100P670 S200P1200 S200P2150 S300P2400 S400P2150 S400P480 S500P4100

7 Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part.

8 Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part)

9 Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) P-numberP-nameColorPriceP-city P1TVSilver300Amman P4PCSilver400Irbid P6Scannersilver150Jarash Temp1

10 Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1

11 Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1 S-numberP-numberQuantityP-nameColorPriceP-city S100P1100TVSilver300Amman S100P4160PCSilver400Irbid S100P670Scannersilver150Jarash S200P1200TVSilver300Amman S400P480PCSilver400Irbid S500P4100PCSilver400Irbid Temp2

12 Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) S-number S100 S200 S400 S500 Temp3

13 Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 S-numberS-nameS-city S100AhmedAmman S200AliJarash S400JasimAquaba S500RanaAmman Temp4

14 Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 Result   S-name (Temp4) S-name Ahmed Ali Jasim Rana Result

15 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid.

16 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part)

17 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) P-numberP-nameColorPriceP-city P4PCSilver400Irbid P5PrinterRed100Irbid Temp1

18 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 S-numberP-numberQuantityP-nameColorPriceP-city S100P4160PCSilver400Irbid S100P550PrinterRed100Irbid S400P480PCSilver400Irbid S500P4100PCSilver400Irbid Temp2

19 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) S-number S100 S400 S500 Temp3

20 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3

21 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 S-numberS-nameS-city S100AhmedAmman S400JasimAquaba S500RanaAmman Temp4

22 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 Result   S-name, S-city (Temp4)

23 Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 Result   S-name, S-city (Temp4) S-nameS-city AhmedAmman JasimAquaba RanaAmman Result

24 Example Queries uQ3- Find supplier names for suppliers who supply all parts.

25 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part)

26 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) P-number P1 P2 P3 P4 P5 P6 Temp1

27 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment)

28 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) S-numberP-number S100P1 S100P2 S100P3 S100P4 S100P5 S100P6 S200P1 S200P2 S300P2 S400P2 S400P4 S500P4 Temp2

29 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1

30 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 S-number S100 Temp3

31 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 Temp4  Supplier Temp3

32 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 Temp4  Supplier Temp3 S-numberS-nameS-city S100AhmedAmman Temp4

33 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 Temp4  Supplier Temp3 Result   S-name (Temp4)

34 Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 Temp4  Supplier Temp3 Result   S-name (Temp4) S-name Ahmed Result

35 Example Queries uQ4- How many parts they have?

36 Example Queries uQ4- How many parts they have? g count (P-number) (Part) P-number 6

37 Example Queries uQ5- Find the total quantities supplied by each supplier.

38 Example Queries uQ6- Find the total quantities supplied by each supplier. S-number g sum (Quantity) (Shipment)

39 Example Queries uQ6- Find the total quantities supplied by each supplier. S-number g sum (Quantity) (Shipment) S-numberQuantity S100730 S200350 S300400 S400250 S500100

40 Example Queries uQ6- Find the total quantities supplied by each supplier. S-number g sum (Quantity) as ( sum-quantity) (Shipment) S-numberSum-Quantity S100730 S200350 S300400 S400250 S500100

41 41 Relational Algebra Summary: In this learning sequence, we discussed another example queries about purchasing system.

42 42 END


Download ppt "1 Session 3 Welcome: To session 3-the 8 th. learning sequence “Relational algebra “ Recap : In the previous learning sequence, we discussed some example."

Similar presentations


Ads by Google