Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The question is asking for Tuple and Domain CALCULUS. Please do not provide SQL

ID: 3739318 • Letter: T

Question

The question is asking for Tuple and Domain CALCULUS. Please do not provide SQL queries.

Considering the following four tables: Farmer (SIN, name, age, sex, vname) Village (name, area, population, province) Kids (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

ANS:-

a)
Find the fathers who have kids going to school. Then find the mothers who have kids
going to school
R1 ? ?SIN(Farmers)
R2 ? R1 ?SIN=F_SIN Kids
R3 ? R1 ?SIN=M_SIN Kids
R4 ? R2 ? R3
R5 ? ?SIN(R4)


b)
Assuming all kids go to school – but this can be
handled checking for a null value in the Kids school column
-Also assuming that Kids live in the same village as both their parents, and that each kid has
two parents. With a ton of work this can be worked around as well.
-Using R5 From above
R1 ? Farmers ? SIN=M_SIN Kids //using one parent here
R2 ? R1 ?SNAME=S_NAME AND R1.VNAME=SCHOOL.VNAME School
R3 ? R1 ?SNAME=S_NAME AND R1.VNAME!=SCHOOL.VNAME School
R4 ? ?SNAME(R2)
R5 ? ?SNAME(R3)
R6 ? R4 – R5

We have the school name as the final result. If we wanted all the school information, R6 is
joined with School over sname to get it


c)

The method below uses Aggregation. Any reasonable attempt was given credit.
R1(POPULATION) ? ?MAXIMUM POPULATION(Village)
R2 ? R1*Village //Joining over population. If there are ties, then more than one
//is returned.
R3 ? ?NAME(R2)

d)

Find the SIN,S_NAME pairs for parents. This gives each school they have a kid
registered in. Divide by all schools.
R1 ? ?SIN(Farmers)
R2 ? R1 ?SIN=F_SIN Kids
R3 ? R1 ?SIN=M_SIN Kids
R4 ? R2 ? R3
R5 ? ?SIN,S_NAME(R4)
R6(S_NAME) ? ?SNAME(School)
R7 ? R5 ÷ R6


e)

Find all villages, then all villages with a school. Subtract
R1(VNAME) ? ?NAME(Village)
R2 ? ?VNAME(School)
R3 ? R1 – R2

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote