Download presentation
Presentation is loading. Please wait.
Published byLeo Bryant Modified over 5 years ago
1
Session 3 Welcome: To session 3-the 8th. learning sequence
“Relational algebra “ Recap : In the previous learning sequence, we discussed some example queries. Present learning: We shall explore the following topic: - Another 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- Get names of suppliers who supply at least one silver part.
8
Q1- Get names of suppliers who supply at least one silver part.
Temp1 P-color = ‘silver’ (Part)
9
Q1- Get names of suppliers who supply at least one silver part.
Temp1 P-color = ‘silver’ (Part) P-number P-name Color Price P-city P1 TV Silver 300 Amman P4 PC 400 Irbid P6 Scanner silver 150 Jarash Temp1
10
Q1- Get names of suppliers who supply at least one silver part.
Temp1 P-color = ‘silver’ (Part) Temp2 Shipment Temp1
11
Q1- Get names of suppliers who supply at least one silver part.
Temp1 P-color = ‘silver’ (Part) Temp2 Shipment Temp1 S-number P-number Quantity P-name Color Price P-city S100 P1 100 TV Silver 300 Amman P4 160 PC 400 Irbid S200 200 S400 80 S500 Temp2
12
Q1- Get names of suppliers who supply 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
Q1- Get names of suppliers who supply at least one silver part.
Temp1 P-color = ‘silver’ (Part) Temp2 Shipment Temp1 Temp3 S-number (Temp2) Temp4 Supplier Temp3 S-number S-name S-city S100 Ahmed Amman S200 Ali Jarash S400 Jasim Aqaba S500 Rana Temp4
14
Q1- Get names of suppliers who supply 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
Q2- Get the names and cities of suppliers who supply parts stored in Irbid.
16
Q2- Get the names and cities of suppliers who supply parts stored in Irbid.
Temp1 P-city = ‘Irbid’ (Part)
17
Q2- Get the names and cities of suppliers who supply parts stored in Irbid.
Temp1 P-city = ‘Irbid’ (Part) P-number P-name Color Price P-city P4 PC Silver 400 Irbid P5 Printer Red 100 Temp1
18
Temp1 P-city = ‘Irbid’ (Part) Temp2 Shipment Temp1
Q2- Get the names and cities of suppliers who supply parts stored in Irbid. Temp1 P-city = ‘Irbid’ (Part) Temp2 Shipment Temp1 Temp2 S-number P-number Quantity P-name Color Price P-city S100 P4 160 PC Silver 400 Irbid P5 50 Printer Red 100 S400 80 S500
19
Temp1 P-city = ‘Irbid’ (Part) Temp2 Shipment Temp1
Q2- Get the names and cities of suppliers who supply parts stored in Irbid. Temp1 P-city = ‘Irbid’ (Part) Temp2 Shipment Temp1 Temp3 S-number (Temp2) S-number S100 S400 S500 Temp3
20
Q2- Get the names and cities of suppliers who supply parts stored in Irbid.
Temp1 P-city = ‘Irbid’ (Part) Temp2 Shipment Temp1 Temp3 S-number (Temp2) Temp4 Supplier Temp3
21
Temp1 P-city = ‘Irbid’ (Part) Temp2 Shipment Temp1
Q2- Get the names and cities of suppliers who supply parts stored in Irbid. Temp1 P-city = ‘Irbid’ (Part) Temp2 Shipment Temp1 Temp3 S-number (Temp2) Temp4 Supplier Temp3 S-number S-name S-city S100 Ahmed Amman S400 Jasim Aqaba S500 Rana Temp4
22
Q2- Get the names and cities of suppliers who supply 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
Temp1 P-city = ‘Irbid’ (Part) Temp2 Shipment Temp1
Q2- Get the names and cities of suppliers who supply 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-name S-city Ahmed Amman Jasim Aqaba Rana Result
24
Q3- Find supplier names for suppliers who supply all parts.
25
Q3- Find supplier names for suppliers who supply all parts.
Temp1 P-number (Part)
26
Q3- Find supplier names for suppliers who supply all parts.
Temp1 P-number (Part) P-number P1 P2 P3 P4 P5 P6 Temp1
27
Q3- Find supplier names for suppliers who supply all parts.
Temp1 P-number (Part) Temp2 S-number , P-number (Shipment)
28
Q3- Find supplier names for suppliers who supply all parts.
Temp1 P-number (Part) S-number P-number S100 P1 P2 P3 P4 P5 P6 S200 S300 S400 S500 Temp2 S-number , P-number (Shipment) Temp2
29
Q3- Find supplier names for suppliers who supply all parts.
Temp1 P-number (Part) Temp2 S-number , P-number (Shipment) Temp3 Temp2 Temp1
30
Q3- 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
Q3- 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
Q3- 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 Temp4 S-number S-name S-city S100 Ahmed Amman
33
Q3- 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
Q3- 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
Q4- How many parts they have?
36
Q4- How many parts they have?
g count (P-number) (Part) P-number 7
37
Q5- Find the total quantities supplied by each supplier.
38
Q5- Find the total quantities supplied by each supplier.
S-number g sum (Quantity) (Shipment)
39
Q5- Find the total quantities supplied by each supplier.
S-number g sum (Quantity) (Shipment) S-number Quantity S100 610 S200 350 S300 400 S400 230 S500 100
40
Q5- Find the total quantities supplied by each supplier.
S-number g sum (Quantity) as ( sum-quantity) (Shipment) S-number Sum-Quantity S100 730 S200 350 S300 400 S400 250 S500 100
41
Relational Algebra Summary: In this learning sequence, we discussed another example queries about purchasing system.
42
END
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.