0% found this document useful (0 votes)
148 views2 pages

Tutorial 5 - SQL Practice 1

The document provides instructions and questions for two SQL practice exercises based on different schemas. The first part includes 5 questions about sailors, boats, and reservations based on a schema with Sailors, Boats, and Reserves tables. The second part includes another 5 questions about students, faculty, classes, and enrollments based on a schema with Student, Faculty, Class, and Enrolled tables. Students are asked to write SQL queries to answer each of the 10 multi-part questions.

Uploaded by

aksagar22
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
148 views2 pages

Tutorial 5 - SQL Practice 1

The document provides instructions and questions for two SQL practice exercises based on different schemas. The first part includes 5 questions about sailors, boats, and reservations based on a schema with Sailors, Boats, and Reserves tables. The second part includes another 5 questions about students, faculty, classes, and enrollments based on a schema with Student, Faculty, Class, and Enrolled tables. Students are asked to write SQL queries to answer each of the 10 multi-part questions.

Uploaded by

aksagar22
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

Tutorial 5 – SQL practice 1

Basic Queries

Feb.16, 2007

Student Version

 You can find help page on how to set up the data set at:
http://www.ugrad.cs.ubc.ca/~cs304/2006W2/practice-questions/SQLpractice/

 You can also find SQLPlus info at:


http://www.ugrad.cs.ubc.ca/~cs304/2006W2/tutorials/SQLPlus/SQLPlus.html

Part1: The following 5 queries will be based on schema1 and the data

you can find in all.sql.


Note: The questions here we have already solved in RA format, now I want you to do it in SQL
format

Schema1:
Sailors (sid, sname, rating, age);
Boats (bid, bname, colour);
Reserves (sid, bid, day);

1. Find all sailors who are teens (show all information)

2. Find the names of sailors who have reserved at least one boat

3. Find the colors of boats reserved by dustin

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
Part2: The following 5 queries will be based on schema2 and the data

you can find in all.sql

Schema2:
Student (snum, sname, major, standing, age);
Faculty (fid, fname, deptid);
Class (name, meets_at, room, fid);
Enrolled (snum, cname);

6. Find the names of the student whose major is in Computer Science.

7. Find the name s of the student who has enrolled in course Database Systems.

8. Find all the courses which are taught by David Anderson

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.

You might also like