# 1 Session 3 Welcome: To session 3 - the 7 th. learning sequence “Relational algebra “ Recap : In the previous learning sequences, we discussed some operators.

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

1 Session 3 Welcome: To session 3 - the 7 th. learning sequence “Relational algebra “ Recap : In the previous learning sequences, we discussed some operators of relational algebra. Present learning: We shall explore the following topic: Example Queries - Example Queries

2 Relational Algebra

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

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

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

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

Example Queries uQ1- Find The cities for all suppliers.  S-city (Supplier)

Example Queries uQ1- Find The cities for all suppliers. S-city Amman Jarash Irbid Aquaba The result relation  S-city (Supplier)

Example Queries n Q2- Find city for Ahmed.

Example Queries n Q2- Find city for Ahmed. Temp1   S-name = ‘Ahmed’ (Supplier)

Example Queries n Q2- Find city for Ahmed. Temp1   S-name = ‘Ahmed’ (Supplier) S-numberS-nameS-city S100AhmedAmman Temp1

Example Queries n Q2- Find city for Ahmed. Temp1   S-name = ‘Ahmed’ (Supplier) S-numberS-nameS-city S100AhmedAmman Temp1 S-city Amman Result Result   S-city (Temp1)

Example Queries uQ3- Find Supplier number and name for suppliers in Amman.

Example Queries uQ3- Find Supplier number and name for suppliers in Amman. Temp1   S-city= ‘Amman’ (Supplier)

Example Queries uQ3- Find Supplier number and name for suppliers in Amman. Temp1   S-city= ‘Amman’ (Supplier) S-numberS-nameS-city S100AhmedAmman S500RanaAmman Temp1

Example Queries uQ3- Find Supplier number and name for suppliers in Amman. Temp1   S-city= ‘Amman’ (Supplier) S-numberS-nameS-city S100AhmedAmman S500RanaAmman Temp1 Result   S-number, S-name (Temp1)

Example Queries uQ3- Find Supplier number and name for suppliers in Amman. Temp1   S-city= ‘Amman’ (Supplier) S-numberS-nameS-city S100AhmedAmman S500RanaAmman Temp1 Result   S-number, S-name (Temp1) S-numberS-name S100Ahmed S500Rana Result

Example Queries n Q4- For each part supplied, find the part names and the names of all cities storing these parts.

Example Queries n Q4- For each part supplied, find the part names and the names of all cities storing these parts. Temp1   P-number ( Shipment )

Example Queries n Q4- For each part supplied, find the part names and the names of all cities storing these parts. Temp1   P-number ( Shipment ) P-number P1 P2 P3 P4 P5 P6 Temp1

Example Queries n Q4- For each part supplied, find the part names and the names of all cities storing these parts. Temp1   P-number ( Shipment ) Temp2  Part Temp1

Example Queries n Q4- For each part supplied, find the part names and the names of all cities storing these parts. Temp1   P-number ( Shipment ) Temp2  Part Temp1 P-numberP-nameColorPriceP-city P1TVSilver300Amman P2CameraBlack100Jarash P3VideoBlack200Amman P4PCSilver400Irbid P5PrinterRed100Irbid P6Scannersilver150Jarash Temp2

Example Queries n Q4- For each part supplied, find the part names and the names of all cities storing these parts. Temp1   P-number ( Shipment ) Temp2  Part Temp1 Result   P-name, p-city(Temp2) P-nameP-city TVAmman CameraJarash VideoAmman PCIrbid PrinterIrbid ScannerJarash Result

Example Queries n Q5- For each part supplied, find the part numbers and names of all cities supplying the parts.

Example Queries n Q5- For each part supplied, find the part numbers and names of all cities supplying the parts. Temp1  Shipment Supplier

Example Queries n Q5- For each part supplied, find the part numbers and names of all cities supplying the parts. Temp1  Shipment Supplier S-numberP-numberQuantityS-nameS-city S100P1100AhmedAmman S100P2150AhmedAmman S100P3200AhmedAmman S100P4160AhmedAmman S100P550AhmedAmman S100P670AhmedAmman S200P1200AliJarash S200P2150AliJarash S300P2400KasimIrbid S400P2150JasimAquaba S400P480JasimAquaba S500P4100RanaAmman Temp1

Example Queries n Q5- For each part supplied, find the part numbers and names of all cities supplying the parts. Result   P-number, S-city ( Temp1 ) Temp1  Shipment Supplier P-numberS-city P1Amman P2Amman P3Amman P4Amman P5Amman P6Amman P1Jarash P2Jarash P2Irbid P2Aquaba P4Aquaba P4Amman Result

Example Queries n Q6- Get supplier numbers for suppliers who supply part p2

Example Queries n Q6- Get supplier numbers for suppliers who supply part p2 Temp1   p-number = ‘p2’ (Shipment)

Example Queries n Q6- Get supplier numbers for suppliers who supply part p2 Temp1   p-number = ‘p2’ (Shipment) S-numberP-numberQuantity S100P2150 S200P2150 S300P2400 S400P2150 Temp1

Example Queries n Q6- Get supplier numbers for suppliers who supply part p2 Temp1   P-number = ‘p2’ (Shipment) Result   S-number ( Temp1 ) S-number S100 S200 S300 S400 Result

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

33 END

Similar presentations