Formulate the following queries using SQL (the answers to these queries in relational algebra, tuple relational calculus, and domain relational calculus were given in the previous section):
relational database contains details about journeys from Paisley to a variety of destinations and contains the following relations:
Operator (opCode, opName)
Journey (opCode, destinationCode, price)
Destination (destinationCode, destinationName, distance)
Each operator is assigned a unique code (opCode) and the relation operator records the association between this code and the operator’s name (opName). Each destination has a unique code (destinationCode) and the relation destination records the association between this code and the destination name (destinationName), and the distance of the destination from Paisley. The relation Journey records the price of an adult fare from Paisley to the given destination by as specified operator, several operators may operate over the same route.
(a) List the details of journeys less than £100.
(b) List the names of all destinations.
(c) Find the names of all destinations within 20 miles.
(d) List the names of all operators with at least one journey priced at under £5.
(e) List the names of all operators and prices of journeys to ‘Ayr’.
(f) List the names of all destinations that do not have any operators.
(a) SELECT *
FROM Journey
WHERE price < 100;
(b) SELECT destinationName
FROM Destination;
(c) SELECT destinationName
FROM Destination
WHERE distance < 20;
(d) SELECT opName
FROM Operator o, Journey j
WHERE (o.opCode = j.opCode) AND (j.price < 5);
(e) SELECT opName, price
FROM Destination d, Operator o, Journey j
WHERE (j.destinationCode = d.destinationCode) AND
(o.opCode = j.opCode) AND (destinationName = ‘Ayr’);
(f) SELECT destinationName
FROM Destination d
WHERE destinationCode NOT IN (SELECT destinationCode FROM Journey);
You might also like to view...
The time during which an application is executing is referred to as ____________.
a. up time b. execution c. run time d. instancing
Answer the following statements true (T) or false (F)
1. An array is a collection of variables all of the same type. 2. An array has only one public instance variable, which is named length. 3. An arrays length instance variables value can be changed by a program. 4. An array of chars is the same as a String in Java. 5. An array name references a memory address.
4.5E + 13 is an example of the ________ format
A) Scientific B) Fixed C) Standard D) Percent
Which IEEE 802.1x component is contained within the client?
A) Supplicant B) Authenticator C) Initiator D) Agent