Problem 1 The following schemas describe Presidents, Judges and the appointment
ID: 3575949 • Letter: P
Question
Problem 1 The following schemas describe Presidents, Judges and the appointment relationships between them.
Formulate the following queries on these schemas in Relational Algebra.
Presidents(PName : string, PDateOfBirth : int, Party : string, HomeState : string)
Judges(JName : string, JDateOfBirth : int, LawSchool : string)
Appoints(PName : string, JName : string, Date : integer)
c) Retrieve the names of the presidents who appointed judges from both Yale and Harvard?
e) Retrieve the pairs of names of judges attended the same law school
f) What are the political parties whose presidents only appointed judges from Yale
i) List the oldest of judges graduated from each law school appointed by presidents in the Republican Party.
Explanation / Answer
Before moving further, we will make the following assumptions for the abbreviations
P = President(PN, PDOB, PARTY, HS)
J = Judge(JN, JDOB, LS)
A = Appointment(PN, JN, Date)
Question C
1. T1 (LS='Harvard' or LS='Yale') (LS(J))
2. T2 PN, LS ( A A.JN = J.JN J )
3. T2÷ T1
Explanation :
In the first step, I am creating a temporary relation consisting of only two entries 'Yale' and 'Harvard'. In the second step we are joining Appointments and Judges to get the information of every presidents to all the law-schools they appointed judges from. Then finally, the divide operation will pick only those president who has a record with both Yale and Harvard.
Question E
1. J1.JN, J2.JN [ J1(J) (J1.JN != J2.JN and J1.LS = J2.LS)J2(J)]
Explanation :
Here denotes the rename operation, which renames the output relation. Effectively, it makes two copies of Judge relation, J1 and J2. Then we are finding out the judges who belong to the same law school [but are not the same person].
Question F
1. T1 PN ( A A.JN = J.JNand(LS!='Yale') J)
2. T2 PN ( A A.JN = J.JNand(LS='Yale') J)
3. T3 T2-T1
4. PARTY ( T3 T3.PN =P.PN P) )
Explanation :
In the first step, if any president has appointed only 'Yale' school judges, his name will never be included. All other presidents who has appointed judges from other schools will be included.
In the second step we are finding the Presidents who has appointed Judges from Yale. Then we are taking difference in step third, which will remove any president who has also appointed judges from schools, other than Yale.
Question I
1. T1 PN,A.JN, JDOB,LS ( A A.JN = J.JN J)
2. T2 JN, JDOB, LS ( T1 T1.PN =P.PNand PARTY='Republicians' P)
3. T3 T2
4. JN (T2) – (T2 (T2.JN != T3.JN) and (T2.JDOB <= T3.JDOB) and (T2.LS = T3.LS) (T3))
Explanation :
In the first step we are joining Appointments and Judges information. In the second step we are finding only the judges who were appointed by republician party presidents. In the third we are keeping an additional copy of above obtained result. In step four, we finding out the list of all judges who were appointed by republician presidents. And from the above list, we are removing the judges whose age is less than some judge from the same law school and also appointed by Republician president.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.