Deck 8: Query Processing
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/8
Play
Full screen (f)
Deck 8: Query Processing
1
Case Study 1 - InstantBuy
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, sex, DOB, officeNo)
Item (itemNo, itemDescription, itemSize, itemColor, itemPrice, itemType)
ItemType (itemType, typeDescription)
ClientOrder (orderNo, clientNo, dateOrder, dateDeliver)
OrderDetail (orderNo, itemNo, noOfItems)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, mgrStaffNo, areaNo)
Area (areaNo, areaDescription)
For a more complete description, see Case Study 3 under Chapter 22.
-Using the above relational schema, determine whether the following query is both type and semantically correct:
SELECT CO.orderNo, C.cAddress, OD.itemNo
FROM OrderDetail OD, ClientOrder CO, Client C, Office O, Area A
WHERE CO.clientNo = C.clientNo AND
C.officeNo = O.officeNo AND
O.areaNo = A.areaNo AND
A.areaDescription = 'SE' AND
C.cName = 'J. Smith';
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, sex, DOB, officeNo)
Item (itemNo, itemDescription, itemSize, itemColor, itemPrice, itemType)
ItemType (itemType, typeDescription)
ClientOrder (orderNo, clientNo, dateOrder, dateDeliver)
OrderDetail (orderNo, itemNo, noOfItems)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, mgrStaffNo, areaNo)
Area (areaNo, areaDescription)
For a more complete description, see Case Study 3 under Chapter 22.
-Using the above relational schema, determine whether the following query is both type and semantically correct:
SELECT CO.orderNo, C.cAddress, OD.itemNo
FROM OrderDetail OD, ClientOrder CO, Client C, Office O, Area A
WHERE CO.clientNo = C.clientNo AND
C.officeNo = O.officeNo AND
O.areaNo = A.areaNo AND
A.areaDescription = 'SE' AND
C.cName = 'J. Smith';
Query graph will show that OrderDetail has no join to the other relations, although it is connected to the Result. Should conclude that it is not semantically correct.
2
Case Study 1 - InstantBuy
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, sex, DOB, officeNo)
Item (itemNo, itemDescription, itemSize, itemColor, itemPrice, itemType)
ItemType (itemType, typeDescription)
ClientOrder (orderNo, clientNo, dateOrder, dateDeliver)
OrderDetail (orderNo, itemNo, noOfItems)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, mgrStaffNo, areaNo)
Area (areaNo, areaDescription)
For a more complete description, see Case Study 3 under Chapter 22.
-Consider the above relational schema. Map the following query onto a relational algebra tree, and then transform it into a reduced query.Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
SELECT CO.orderNo, C.cAddress, O.oAddress
FROM ClientOrder CO, Client C, Office O, Area A
WHERE CO.clientNo = C.clientNo AND
C.officeNo = O.officeNo AND
CO.dateDeliver < '1-Jun-96' AND
O.areaNo = A.areaNo AND
A.areaDescription = 'NE' AND
C.cName = 'J. Smith' AND
CO.dateOrder > '1-Jan-96';
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, sex, DOB, officeNo)
Item (itemNo, itemDescription, itemSize, itemColor, itemPrice, itemType)
ItemType (itemType, typeDescription)
ClientOrder (orderNo, clientNo, dateOrder, dateDeliver)
OrderDetail (orderNo, itemNo, noOfItems)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, mgrStaffNo, areaNo)
Area (areaNo, areaDescription)
For a more complete description, see Case Study 3 under Chapter 22.
-Consider the above relational schema. Map the following query onto a relational algebra tree, and then transform it into a reduced query.Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
SELECT CO.orderNo, C.cAddress, O.oAddress
FROM ClientOrder CO, Client C, Office O, Area A
WHERE CO.clientNo = C.clientNo AND
C.officeNo = O.officeNo AND
CO.dateDeliver < '1-Jun-96' AND
O.areaNo = A.areaNo AND
A.areaDescription = 'NE' AND
C.cName = 'J. Smith' AND
CO.dateOrder > '1-Jan-96';

3
Case Study 2 - Complete Pet Care

For a more complete description, see Case Study 4 under Chapter 22.
-Using the above relational schema, determine whether the following query is both type and semantically correct:
SELECT P.petNo, petName, oName, O.TelNo
FROM Pet P, Owner O, Prescription Pr, Medication M, Surgery S
WHERE Pr.medNo = M.medNo AND
S.surgeryNo = O.surgeryNo AND
PR.petNo = P.petNo AND
P.ownerNo = O.ownerNo AND
M.medNo = 'J. Smith' AND adminMethod = 'Oral' AND
S.surgeryNo = 100;

For a more complete description, see Case Study 4 under Chapter 22.
-Using the above relational schema, determine whether the following query is both type and semantically correct:
SELECT P.petNo, petName, oName, O.TelNo
FROM Pet P, Owner O, Prescription Pr, Medication M, Surgery S
WHERE Pr.medNo = M.medNo AND
S.surgeryNo = O.surgeryNo AND
PR.petNo = P.petNo AND
P.ownerNo = O.ownerNo AND
M.medNo = 'J. Smith' AND adminMethod = 'Oral' AND
S.surgeryNo = 100;
Various problems with query:
surgeryNo is not part of Owner table;
medNo is not a textual attribute but an integer;
TelNo is not part of Owner (its oTelNo)
surgeryNo is not part of Owner table;
medNo is not a textual attribute but an integer;
TelNo is not part of Owner (its oTelNo)
4
Case Study 2 - Complete Pet Care

For a more complete description, see Case Study 4 under Chapter 22.
-Consider the above relational schema. Map the following query onto a relational algebra tree, and then transform it into a reduced query.Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
SELECT P.petNo, petName, oName, oAddress
FROM Pet P, Owner O, Prescription P, Medication M
WHERE PR.medNo = M.medNo AND
PR.petNo = P.petNo AND
P.ownerNo = O.ownerNo AND
medName = ' Provac' AND
unitsPerDay > 200 AND
petDescription = 'Setter';

For a more complete description, see Case Study 4 under Chapter 22.
-Consider the above relational schema. Map the following query onto a relational algebra tree, and then transform it into a reduced query.Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
SELECT P.petNo, petName, oName, oAddress
FROM Pet P, Owner O, Prescription P, Medication M
WHERE PR.medNo = M.medNo AND
PR.petNo = P.petNo AND
P.ownerNo = O.ownerNo AND
medName = ' Provac' AND
unitsPerDay > 200 AND
petDescription = 'Setter';
Unlock Deck
Unlock for access to all 8 flashcards in this deck.
Unlock Deck
k this deck
5
Case Study 2 - Complete Pet Care

For a more complete description, see Case Study 4 under Chapter 22.
-Now assume that the relation Medication given in Question 20.4 is horizontally fragmented as follows:

Transform the relational algebra tree from Question 20.4 into a reduced query on fragments. Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.

For a more complete description, see Case Study 4 under Chapter 22.
-Now assume that the relation Medication given in Question 20.4 is horizontally fragmented as follows:

Transform the relational algebra tree from Question 20.4 into a reduced query on fragments. Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
Unlock Deck
Unlock for access to all 8 flashcards in this deck.
Unlock Deck
k this deck
6
Case Study 3 - Rapid Roads
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, officeNo)
Unit (unitRegNo, unitDescription, maxPayload, officeNo)
Trailer (trailerNo, trailerDescription, trailerLength, maxCarryingWt, officeNo)
ClientOrder (orderNo, clientNo, dateOrder, collectDate, collectAddress, deliveryDate, deliveryAddress, loadWeight, loadDescription)
TransportReq (orderNo, unitRegNo, trailerNo)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, position, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, countryNo)
Country (countryNo, countryName)
For a more complete description, see Case Study 5 under Chapter 22.
-Using the above relational schema, determine whether the following query is both type and semantically correct:
SELECT CO.clientNo, cAddress
FROM TransportReq TR, ClientOrder CO, Client C, Unit U, Trailer T
WHERE CO.clientNo = C.clientNo AND
TR.unitRegNo = U.unitRegNo AND
TR.trailerNo = T.trailerNo AND
maxCarryingWt < maxPayload AND
LoadWeight < maxPayload;
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, officeNo)
Unit (unitRegNo, unitDescription, maxPayload, officeNo)
Trailer (trailerNo, trailerDescription, trailerLength, maxCarryingWt, officeNo)
ClientOrder (orderNo, clientNo, dateOrder, collectDate, collectAddress, deliveryDate, deliveryAddress, loadWeight, loadDescription)
TransportReq (orderNo, unitRegNo, trailerNo)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, position, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, countryNo)
Country (countryNo, countryName)
For a more complete description, see Case Study 5 under Chapter 22.
-Using the above relational schema, determine whether the following query is both type and semantically correct:
SELECT CO.clientNo, cAddress
FROM TransportReq TR, ClientOrder CO, Client C, Unit U, Trailer T
WHERE CO.clientNo = C.clientNo AND
TR.unitRegNo = U.unitRegNo AND
TR.trailerNo = T.trailerNo AND
maxCarryingWt < maxPayload AND
LoadWeight < maxPayload;
Unlock Deck
Unlock for access to all 8 flashcards in this deck.
Unlock Deck
k this deck
7
Case Study 3 - Rapid Roads
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, officeNo)
Unit (unitRegNo, unitDescription, maxPayload, officeNo)
Trailer (trailerNo, trailerDescription, trailerLength, maxCarryingWt, officeNo)
ClientOrder (orderNo, clientNo, dateOrder, collectDate, collectAddress, deliveryDate, deliveryAddress, loadWeight, loadDescription)
TransportReq (orderNo, unitRegNo, trailerNo)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, position, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, countryNo)
Country (countryNo, countryName)
For a more complete description, see Case Study 5 under Chapter 22.
-Consider the above relational schema. Map the following query onto a relational algebra tree, and then transform it into a reduced query:
SELECT trailerDescription, unitDescription
FROM Trailer T, Unit U, Office O, TransportReq TR
WHERE TR.trailerNo = T.trailerNo AND
TR.unitRegNo = U.unitRegNo AND
U.officeNo = O.officeNo AND
maxPayload > maxCarryingWt AND
O.officeNo = 2;
Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, officeNo)
Unit (unitRegNo, unitDescription, maxPayload, officeNo)
Trailer (trailerNo, trailerDescription, trailerLength, maxCarryingWt, officeNo)
ClientOrder (orderNo, clientNo, dateOrder, collectDate, collectAddress, deliveryDate, deliveryAddress, loadWeight, loadDescription)
TransportReq (orderNo, unitRegNo, trailerNo)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, position, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, countryNo)
Country (countryNo, countryName)
For a more complete description, see Case Study 5 under Chapter 22.
-Consider the above relational schema. Map the following query onto a relational algebra tree, and then transform it into a reduced query:
SELECT trailerDescription, unitDescription
FROM Trailer T, Unit U, Office O, TransportReq TR
WHERE TR.trailerNo = T.trailerNo AND
TR.unitRegNo = U.unitRegNo AND
U.officeNo = O.officeNo AND
maxPayload > maxCarryingWt AND
O.officeNo = 2;
Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
Unlock Deck
Unlock for access to all 8 flashcards in this deck.
Unlock Deck
k this deck
8
Case Study 3 - Rapid Roads
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, officeNo)
Unit (unitRegNo, unitDescription, maxPayload, officeNo)
Trailer (trailerNo, trailerDescription, trailerLength, maxCarryingWt, officeNo)
ClientOrder (orderNo, clientNo, dateOrder, collectDate, collectAddress, deliveryDate, deliveryAddress, loadWeight, loadDescription)
TransportReq (orderNo, unitRegNo, trailerNo)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, position, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, countryNo)
Country (countryNo, countryName)
For a more complete description, see Case Study 5 under Chapter 22.
-Now assume that the relation Trailer given in Question 20.7 is horizontally fragmented as follows:
Transform the relational algebra tree from Question 21.7 into a reduced query on fragments. Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
Client (clientNo, cName, cAddress, cTelNo, cFaxNo, officeNo)
Unit (unitRegNo, unitDescription, maxPayload, officeNo)
Trailer (trailerNo, trailerDescription, trailerLength, maxCarryingWt, officeNo)
ClientOrder (orderNo, clientNo, dateOrder, collectDate, collectAddress, deliveryDate, deliveryAddress, loadWeight, loadDescription)
TransportReq (orderNo, unitRegNo, trailerNo)
Staff (staffNo, sName, sAddress, sTelNo, sex, DOB, position, NIN, taxCode, salary, officeNo)
Office (officeNo, oAddress, oTelNo, oFaxNo, countryNo)
Country (countryNo, countryName)
For a more complete description, see Case Study 5 under Chapter 22.
-Now assume that the relation Trailer given in Question 20.7 is horizontally fragmented as follows:

Transform the relational algebra tree from Question 21.7 into a reduced query on fragments. Give a full explanation of the reasoning behind each step and state any transformation rules used during the reduction process.
Unlock Deck
Unlock for access to all 8 flashcards in this deck.
Unlock Deck
k this deck