Download presentation
Presentation is loading. Please wait.
Published byWendy Jordan Modified over 6 years ago
1
Session 3 Welcome: To session 3 - the 7th. 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
2
Relational Algebra
3
Relational Algebra A basic expression in the relational algebra consists of either one of the following: A relation in the database A constant relation
4
Relational Instances for the Purchasing System
The Supplier relation: S-number S-name S-city S100 Ahmed Amman S200 Ali Jarash S300 Kasim Irbid S400 Jasim Aqaba S500 Rana
5
The Part relation: P-number P-name Color Price P-city P1 TV Silver 300
Amman P2 Camera Black 100 Jarash P3 Video 200 P4 PC 400 Irbid P5 Printer Red P6 Scanner silver 150 5
6
The shipment relation:
S-number P-number Quantity S100 P1 100 P2 150 P3 200 P4 160 S200 S300 400 S400 80 S500 6
7
Q1- Find The cities for all suppliers .
S-city (Supplier)
8
Q1- Find The cities for all suppliers .
S-city (Supplier) S-city Amman Jarash Irbid Aqaba The result relation
9
Q2- Find city for Ahmed.
10
Q2- Find city for Ahmed. Temp1 S-name = ‘Ahmed’ (Supplier)
11
Q2- Find city for Ahmed. Temp1 S-name = ‘Ahmed’ (Supplier) S-number S-name S-city S100 Ahmed Amman Temp1
12
Q2- Find city for Ahmed. Temp1 S-name = ‘Ahmed’ (Supplier) S-number S-name S-city S100 Ahmed Amman Temp1 Result S-city (Temp1) S-city Amman Result
13
Q3- Find the number and name for suppliers in Amman.
14
Q3- Find the number and name for suppliers in Amman.
Temp1 S-city= ‘Amman’ (Supplier)
15
Q3- Find the number and name for suppliers in Amman.
Temp1 S-city= ‘Amman’ (Supplier) S-number S-name S-city S100 Ahmed Amman S500 Rana Temp1
16
Q3- Find the number and name for suppliers in Amman.
Temp1 S-city= ‘Amman’ (Supplier) S-number S-name S-city S100 Ahmed Amman S500 Rana Temp1 Result S-number, S-name (Temp1)
17
Q3- Find the number and name for suppliers in Amman.
Temp1 S-city= ‘Amman’ (Supplier) S-number S-name S-city S100 Ahmed Amman S500 Rana Temp1 Result S-number, S-name (Temp1) S-number S-name S100 Ahmed S500 Rana Result
18
Q4- For each part shipped, find the part names and the names of all cities storing these parts.
19
Q4- For each part shipped, find the part names and the names of all cities storing these parts.
Temp1 P-number ( Shipment )
20
Q4- For each part shipped, find the part names and the names of all cities storing these parts.
Temp1 P-number ( Shipment ) P-number P1 P2 P3 P4 Temp1
21
Q4- For each part shipped, find the part names and the names of all cities storing these parts.
Temp1 P-number ( Shipment ) Temp2 Part Temp1
22
Q4- For each part shipped, find the part names and the names of all cities storing these parts.
Temp1 P-number ( Shipment ) Temp2 Part Temp1 P-number P-name Color Price P-city P1 TV Silver 300 Amman P2 Camera Black 100 Jarash P3 Video 200 P4 PC 400 Irbid Temp2
23
Q4- For each part shipped, 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-name P-city TV Amman Camera Jarash Video PC Irbid Result
24
Q5- For each part shipped, find the part numbers and names of all cities supplying the parts.
25
Q5- For each part shipped, find the part numbers and names of all cities supplying the parts.
Temp1 Shipment Supplier
26
Q5- For each part shipped, find the part numbers and names of all cities supplying the parts.
Temp1 Shipment Supplier S-number P-number Quantity S-name S-city S100 P1 100 Ahmed Amman P2 150 P3 200 P4 160 S200 Ali Jarash S300 400 Kasim Irbid S400 Jasim Aqaba 80 S500 Rana Temp1
27
Result P-number, S-city ( Temp1 )
Q5- For each part shipped, find the part numbers and names of all cities supplying the parts. Temp1 Shipment Supplier P-number S-city P1 Amman P2 P3 P4 Jarash Irbid Aqaba Result P-number, S-city ( Temp1 ) Result
28
Q6- Get supplier numbers for suppliers who supply part p2
29
Q6- Get supplier numbers for suppliers who supply part p2
Temp1 p-number = ‘p2’ (Shipment)
30
Q6- Get supplier numbers for suppliers who supply part p2
Temp1 p-number = ‘p2’ (Shipment) S-number P-number Quantity S100 P2 150 S200 S300 400 S400 Temp1
31
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
© 2025 SlidePlayer.com. Inc.
All rights reserved.