Considering the following four tables: Farmer(SIN, name, age, sex, vname) Villag
ID: 3676556 • Letter: C
Question
Considering the following four tables:
Farmer(SIN, name, age, sex, vname)
Village(name, area, population, province)
KKids(SIN, f_sin, m_sin, s_name)
School(sname, vname, no_classes)
Where: sname=school name, vname =village name, f_sin and m_sin stand for the father`s and mother`s SIN, respectively.
Code the following queries in Tuple-Relational Calculus and Domain-Relational Calculus:
a) Find SIN of farmers who have some kids going to school?
b) Find name of each school attended only by kids from the same village where the school is located?
c) Find the name of the most crowded village(s) (most population)?
d) Find SIN numbers of farmers who have at least one kid in every school registered in the database?
e) Find names of villages with no schools?
f) Find the school attended by all kids of Mark? (all kids of Mark must go to school and must attend same school)
g) Find names of farmers whose kids go only to schools outside the Province where the farmers live? (the farmer may have kids not going to schools at all, but if some of the kids go to schools then the schools they attend must be in other Provinces)
Explanation / Answer
a) Select SIN from Farmer where Kkids.f_sin = Farmer.SIN
B) Select SIN from Kkids where f_in = (Select * from Farmer inner join school where Farmer.vname = School.vname)
c) SELECT MAX(population) FROM Village
d)
e) Select name from village outer full join School where vname IS NULL
F) Select SIN from Kkids where f_name = “Mark” GROUP BY sname
g) Select SIN from Kkids where f_in not = (Select * from Farmer inner join school where Farmer.vname = School.vname)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.