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 ?
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.