Tutorial 5 - SQL Practice 1: Basic Queries
Tutorial 5 - SQL Practice 1: Basic Queries
Basic Queries
Feb.16, 2007
Solutions
Schema1:
Sailors (sid, sname, rating, age);
Boats (bid, bname, colour);
Reserves (sid, bid, day);
Schema2:
Student (snum, sname, major, standing, age);
Faculty (fid, fname, deptid);
Class (name, meets_at, room, fid);
Enrolled (snum, cname);
Schema4:
Flights (flno, origin, destination, distance, departs, arrives, price);
Aircraft (aid, aname, cruisingrange);
Employees (eid, ename, salary);
Certified (eid, aid);
Schema5:
Suppliers (sid, sname, address);
Parts (pid, pname, colour);
Catalog (sid, pid, cost);
%/
Queries:
Select *
From sailors
Where age >= 13
and age <= 19
2. Find the names of sailors who have reserved at least one boat
4. Find the sailor IDs of all sailors who have reserved red boats but not green boats
5. Find the names of sailors who have reserved at least two boats
7. Find the name s of the student who has enrolled in course Database Systems.
9. Find all the courses which are NOT using room R128
10. Find all the students who are in any one of the classes that professor James Smith teaches.