%3Cp%3EWrite%20the%20following%20queries%20in%20Relational%20Algebra%20(no%20agg
ID: 3551713 • Letter: #
Question
%3Cp%3EWrite%20the%20following%20queries%20in%20Relational%20Algebra%20(no%20aggregates%0Aor%20groupin%20allowed)%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3ECustomer%20(%3Cspan%20class%3D%22c1%22%3Ecid%3C%2Fspan%3E%2C%20name%2C%20address)%3C%2Fp%3E%0A%3Cp%3ECar%20(%3Cspan%20class%3D%22c1%22%3Evin%3C%2Fspan%3E%2C%20make%2C%20color%2C%20number-doors%2C%0Adaily-price)%3C%2Fp%3E%0A%3Cp%3EReservation%20(%3Cspan%20class%3D%22c1%22%3Ecid%3C%2Fspan%3E%2C%20%3Cspan%20class%3D%0A%22c1%22%3Evin%3C%2Fspan%3E%2C%20date%2C%20location%2C%20number-days)%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3ECustomer%20contains%20the%20customer%20id%20(the%20key)%2C%20name%20and%20address%20of%0Aeach%20customer%20who%20rents%20a%20car.%20Car%20contains%20information%20about%0Avehicles%3A%20the%20vin%20(key)%2C%20the%20make%2C%20color%2C%20number%20of%20doors%20(either%202%0Aor%204)%2C%20and%20the%20daily%20price%20to%20rent%20the%20car.%20Reservations%20registers%0Aeach%20reservation%2C%20who%20reserved%20the%20car%2C%20which%20car%20was%20reserved%2C%20the%0Alocation%20where%20the%20car%20was%20rented%2C%20the%20date%20the%20reservation%20starts%2C%0Aand%20the%20number%20of%20days%20it%20lasts.%20Each%20customer%20may%20make%20several%0Areservations%20and%20each%20car%20can%20be%20reserved%20several%20times.%20Note%20that%0Awe%20assume%20no%20two%20reservations%20of%20the%20same%20car%20or%20by%20the%20same%0Acustomer%20on%20the%20same%20day.%20Assume%20date%20has%20both%20month%20and%20year%2C%20as%0Ain%20March%202009.%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3EWrite%20the%20following%20queries%20in%20Relational%20Algebra%20(no%20aggregates%0Aor%20groupin%20allowed)%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E1.%20List%20the%20names%20of%20customers%20who%20have%20reserved%20a%20green%20car%0Aduring%20September%202013.%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E2.%20Find%20the%20customers%20who%20reserved%20the%20same%20car%20(a%20car%20of%20the%0Asame%20make%20and%20color)%20more%20than%20once.%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E3.%20Find%20the%20customers%20who%20have%20reserved%20only%204-door%0Acars.%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0A%3Cp%3E%3Cbr%20%2F%3E%3C%2Fp%3E%0AExplanation / Answer
1. Select p.name from customer p,car q, reservation s where extract(year_month from s.date)=201309 and q.color='Green' and p.cid=s.cid and q.cid=s.cid;
2.Sorry not able to solve without aggregate function.
3.select name from customer where cid in
(select distinct (r.cid) from car p, reservation q, customer r where p.vin=q.vin and q.cid=r.cid and r.cid not in
(select p.cid from car p,reservation r where p.vin=r.vin and p.door=2) );
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.