Question: Question 3 . Consider the table created by the following SQL statement: CREATE TABLE timetable ( orig , char ( 3 ) , - -
Question Consider the table created by the following SQL statement:
CREATE TABLE timetable
orig char code of the origin station
dest char code of the destination station
departure time expressed as minutes elapsed since :
dep smallint CHECK dep AND dep
arrival time expressed as minutes elapsed since :
arr smallint CHECK arr AND arr
fare numeric ticket price
CHECK arr dep AND orig dest
PRIMARY KEY orig dest, dep, arr
;
a Using only standard constructs we have seen in class, write an SQL query
to find all connections with exactly stop and such that:
the origin and final destination are distinct stations;
there is no cheaper direct route or no direct route at all;
the connection time is at least and no more than minutes.
Return the codes of the origin, stopover, and destination stations for the
overall trip the total travel time including connection time and the total
fare. If there is more than one connection that satisfies the requirements,
they must all be included in the answer.
A correct query is worth marks; additional marks are awarded if the
query has at most one level of nesting and does not use aggregation, outer
joins, setbag operations, CASE and WITH.
b Can the query in Question a output rows with multiplicity greater than
one? If yes, provide an instance witnessing that this is the case; otherwise,
explain why such a situation cannot occur.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
