0% found this document useful (0 votes)
3 views

Lab Assignment 8_Join & Sub-query

The document outlines a lab assignment focused on creating and populating three tables: Sailors, Boats, and Reserves, with specified primary and foreign keys. It also includes a series of SQL queries that utilize JOINs and sub-queries to retrieve information about sailors based on their boat reservations and ratings. The queries address various conditions, such as reservations of specific boat colors, comparisons of ratings, and finding sailors with the highest ratings.

Uploaded by

ssbakshi2050
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab Assignment 8_Join & Sub-query

The document outlines a lab assignment focused on creating and populating three tables: Sailors, Boats, and Reserves, with specified primary and foreign keys. It also includes a series of SQL queries that utilize JOINs and sub-queries to retrieve information about sailors based on their boat reservations and ratings. The queries address various conditions, such as reservations of specific boat colors, comparisons of ratings, and finding sailors with the highest ratings.

Uploaded by

ssbakshi2050
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab Assignment 8- Join and Sub Queries

Create the following tables and insert some tuples in these tables shown below. Where sid is the
primary key for the Sailors table, bid is the primary key for the Boats table and sid and bid are
the foreign keys for the Reserves table referencing to the Sailors and Boats table, respectively.
Sailors(sid: integer, sname: string, rating: integer, age: real)
Boats(bid: integer, bname: string, color: string)
Reserves(sid: integer, bid: integer, day: date)
After inserting the records in these tables, the instances should look like as follows:

Sailors Reserves Boats

Write SQL command using JOINs and/or Sub-queries for the following:

Q1. Find the names of sailors who have reserved a red or a green boat.
Q2. Find the names of sailors who have reserved both a red and a green boat.
Q3. Find the names of sailors who have reserved boat 103
Q4. Find the names of sailors who have reserved a red boat.
Q5. Find the names of sailors who have NOT reserved a red boat.
Q6. Find the names of sailors who have reserved at least one boat.
Q7. Find sailors whose rating is better than some sailor called Horatio.
Q8. Find sailors whose rating is better than every sailor called Horatio.
Q9. Find the sailors with the highest rating.
Q10. Find the names of sailors who have reserved all boats.

You might also like