Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the tables above that show the relations and the existing tuples within

ID: 2246806 • Letter: C

Question

Consider the tables above that show the relations and the existing tuples within the Hire a Holiday Home relational schema. Currently the database only has four tuples in each relation. However, it will store significantly more information in the future.

Choose the correct answer below for the following:

How many superkeys are there in the Hosts relation?
How many candidate keys are there in the Bookings relation?   

What is the most appropriate primary key of the Bookings relation?   
What are the foreign keys in the Bookings relation? and ?

Customers firstName Tony Daniel Jimmy Jimmy lastName Sahama James phoneNumbe 0432328888 0412348711 0725637822 0488226739 customerlD email tony@gmail.com dan@yahoo.com C001 James jimmy@gmail.com Hosts address 101 Blue St 22 Riverview Rd 99 Penthouse Dr 01 Mountain Rd 22 Kiribilli St hostID name Joe Hockey Malcom Turnbull Richy Rich Empire Builder Richy Rich H001 Bookings bookingID B001 B002 B003 B004 hostID H002 H004 customerlD C001 C002 C001 dateFrom 20/08/2015 25/08/2015 24/08/2015 25/08/2015 date To 24108/2015 30/08/2015 04/09/2015 30/08/2015 H004

Explanation / Answer

How many superkeys are there in the Hosts relation?

SUPER KEY: It is a set of attributes which can uniquely identify a row i.e. a set of attributes which can determine all other attributes of the relation.

There are three super keys in the hosts table.They are:

How many candidate keys are there in the Bookings relation?

CANDIDATE KEY: It is a super key such that any proper subset of the candidate key is not a super key. It qualifies the uniqueness of a row.

The candidate key in the bookings relation is :(bookingID,hostID,customerID).

The set of all the three above mentioned columns can uniquely determine a row of the bookings table.

What is the most appropriate primary key of the Bookings relation?

PRIMARY KEY: The candidate key that is used to uniquely identify the rows of a relation.It maintains the uniqueness of a row.

In bookings relation bookingID itself can uniquely identify a row.So the primary key is bookingID.

What are the foreign keys in the Bookings relation?

FOREIGN KEY: It is a key i.e. a column/set of columns which is a primary key in some other relation.

In bookings relation hostID and customerID are foreign keys because hostID is the primary key in hosts relation and customerID is the primary key in the customers relation.