Uploaded by Thành Tín Võ

SD. Assignment 4. Tin Thanh Vo

advertisement
Student name: Tin Thanh Vo
Student ID: 000852422
Subject: Spatial Database
ASSIGNMENT 4
Question 1.
a. 𝜋 Name (𝜎 GDP > 500 ∧ 𝐺𝐷𝑃 < 1000 (𝐂𝐎𝐔𝐍𝐓𝐑𝐘))
b. R = π life. Exp (σ name(𝐂𝐎𝐔𝐍𝐓𝐑𝐘))
S = π origin (𝐑𝐈𝐕𝐄𝐑)
 Intersection: R⋂S
c. R = π name (σ cont = ′ SAM ′ (𝐂𝐎𝐔𝐍𝐓𝐑𝐘))
S = π country (σ pop < 2 (𝐂𝐈𝐓𝐘))
 Union: R ∪ S
d. R = π name, cont (COUNTRY)
S = π country, name (𝐂𝐈𝐓𝐘)
From R*S, we will have the schema of the R*S relation is:
R*S

R.name
R. cont
S. Country
Conditional Joints:
π name (σ(R. name = S. country) ∧ (R. cont =′ SAM ′ )(𝐑. 𝐒)
Question 2.
a. SELECT Co.name, Co.GDP
FROM COUNTRY Co
WHERE 500 < Co.GDP AND Co.GDP < 1000
1
S. name
b. SELECT Co.Life-Exp, R.Origin,
FROM COUNTRY Co, RIVER R
WHERE Co.name = R.Origin
c. SELECT Co.Cont, Ci.name, Ci.Pop (Millions)
FROM COUNTRY Co, CITY Ci
WHERE Co.name = Ci.Country AND
Co.Cont=’SAM’ AND
Ci.Pop (Millions) < 2
d. SELECT Ci.name, Co.Cont
FROM CITY Ci, COUNTRY Co
WHERE Co.name = Ci.Country AND
NOT Co.Cont = ’SAM’
2
Download