Professional Documents
Culture Documents
HDBP200-1 - Teaching and Learning Solutions W4
HDBP200-1 - Teaching and Learning Solutions W4
Use the diagrams below to answer the following relational algebra questions.
DRIVER
ID F_NAME SURNAME CELL ADDRESS
100 Charles Muranda 0123456789 21 Cape Town City
101 Joe Doe 0987654321 35 Johannesburg City
103 John Smith 0876543219 42 Durban City
104 Sarah Simpsons 0765432123 55 Pretoria North
TRIPS
ID DRIVER_ID DEPARTURE_CITY_ID ARRIVAL_CITY_ID GOODS_ID DEPARTURE_DATE STATUS
CITY STATUS
ID CITY_NAME COUNTRY_ID ID STATUS
01 Kinshasa 103 1 In transit
05 Durban 100 2 Delivered successfully
10 Windhoek 102 3 Delivered with challenges in transit
15 Lubumbashi 103
20 Johannesburg 100
25 Gaborone 105
GOODS
ID NAME
101 Minerals
105 Petroleum
108 Medical supplies
110 Cars
115 Chemicals
120 Beef
1 HDBP200-1-Jul-Dec2020-T&L-Memo-CMu-W4-18082020
a. Determine the appropriate relational algebra expressions that would give the following results from
the above tables:
1.
ID F_NAME SURNAME CELL ADDRESS
100 Charles Muranda 0123456789 21 Cape Town City
101 Joe Doe 0987654321 35 Johannesburg City
103 John Smith 0876543219 42 Durban City
Solution
𝜎𝐷𝑅𝐼𝑉𝐸𝑅.𝐼𝐷<104 (𝐷𝑅𝐼𝑉𝐸𝑅)
2.
F_NAME SURNAME
Charles Muranda
Joe Doe
John Smith
Sarah Simpsons
Solution
𝜋𝐹𝑁𝐴𝑀𝐸 ,𝑆𝑈𝑅𝑁𝐴𝑀𝐸 (𝜎𝐷𝑅𝐼𝑉𝐸𝑅.𝐼𝐷<104 (𝐷𝑅𝐼𝑉𝐸𝑅))
3.
F_NAME DEPARTURE_DATE GOODS.NAME
Charles 2020-04-20 Minerals
Solution
• Starting with the TRIPS table, we need to join it with the DRIVERS table (the join condition is (DRIVERS.ID
= TRIPS.DRIVER_ID) and we only want where DRIVER_ID is 100:
2 HDBP200-1-Jul-Dec2020-T&L-Memo-CMu-W4-18082020
• Now that we are done with joining all tables, let us select the required columns:
Solution
ADDRESS
21 Cape Town City
35 Johannesburg City
42 Durban City
55 Pretoria North
SOLUTION
SURNAME GOODS.NAME
Muranda Minerals
Simpsons Cars
Smith Minerals
3 HDBP200-1-Jul-Dec2020-T&L-Memo-CMu-W4-18082020