Beruflich Dokumente
Kultur Dokumente
Lec14
Example revisited....
Consider the following schema. People(PID,name,address,gender,age) Planet(Plname,colour,shade,Galaxy) Live(PID,Plname,migratedfrom,status) (A person can be migrated from one planet to another planet at any time. Depending on that the status will be living or shifted. By birth the value of migratedfrom for a given PID is NULL) Property(PrID,PID,Plname,type) GuestHouse(GID,No.of.Bed rooms) Haveasite(SID,sqfts)
Find the names of all people who is having property on all the planets.
Division
Goal: Produce the tuples in one relation, r, that match all tuples in another relation, s r (A1, An, B1, Bm) s (B1 Bm) r/s, with attributes A1, An, is the set of all tuples <a> such that for every tuple <b> in s, <a,b> is in r Can be expressed in terms of projection, set difference, and cross-product
Division (contd)
Division - Example
Schema for Student Registration System
Student (Id, Name, Addr, Status) Professor (Id, Name, DeptId) Course (DeptId, CrsCode, CrsName, Descr) Transcript (StudId, CrsCode, Semester, Grade) Teaching (ProfId, CrsCode, Semester) Department (DeptId, Name)
Division - Example
List the Ids of students who have passed all courses that were taught in spring 2000 Numerator:
StudId and CrsCode for every course passed by every student: StudId, CrsCode ( Grade F (Transcript) ) Transcript
Denominator:
CrsCode of all courses taught in spring 2000 CrsCode ( Semester=S2000 (Teaching) ) Teaching
Result is numerator/denominator
Division Example2
sno s1 s1 s1 s1 s2 s2 s3 s4 s4 pno p1 p2 p3 p4 p1 p2 p2 p2 p4
pno p2
B1
sno s1 s2 s3 s4
pno p2 p4 B2
pno p1 p2 p4 B3
sno s1 s4
A/B1
A/B2
sno s1 A/B3
Disqualified x values:
x (( x ( A) B) A)
Disqualified x values
A/B:
x ( A)
Example s
Reserves
Sailors
sid 22 31 58
Boats