FIT9132 Tutorial 4 Sample Solution
FIT9132 Tutorial 4 Sample Solution
FIT9132 2020 S1
License: Copyright © Monash University, unless otherwise stated. All Rights Reserved.
COPYRIGHT WARNING
Warning
This material is protected by copyright. For use within Monash University only. NOT FOR RESALE.
Page 1 of 5
4.1 The Relational Model
4.1.1 Lead Tutor Explanation Part A
Why would we not just store all the customer and order information in one relation so as to avoid a
join operation?
Doing so would result in substantial data redundancy and would lead to insert, update and delete
anomalies.
1. Relation: A named set of attributes, consisting of a heading and a body. The heading is the
schema, the body is the set of tuples (the state at a point in time)
3. Domain: A set of atomic (indivisible) values from which an attribute's values are drawn.
Consists of a name, data type and data format eg. gender domain: one character string with
allowed values of M and F
4. Tuple: A set of related attributes describing a particular instance of the relation /entity – in file
terminology called a row
Primary key: an attribute or minimal set of attributes which uniquely identify each tuple;
Foreign key: an attribute(s) in a relation that exists in the same or another relation as
Primary Key;
1. In any relation, tuples must be unique. However, in many cases, the set of all the attributes in
a relation is not considered a candidate key. Why not?
Although all of the attributes in a relation is a superkey, the candidate key is selected on the
basis of a minimum superkey. For a given relation there is usually a smaller set of
attributes that provide a superkey so there is no need to consider the full set of attributes as
a starting point.
On the other hand, suppose we do have a relation where the set of all attributes is a
candidate key. In this case, show that this set must, therefore, be the only candidate key
and hence the primary key.
Page 2 of 5
If the set of all attributes is a candidate key (ie. a minimum superkey), there can be no other
superkey and hence it must be the only candidate key and the primary key.
The foreign keys are order_id and prod_no in ORDERLINE. order_id in ORDERLINE refers
to order_id in ORDER and prod_no in ORDERLINE refers to prod_no in PRODUCT.
Candidate keys:
(dentist_id, appointment_datetime)
(patient_id, appointment_datetime)
(surgeryroom_no, appointment_datetime)
Primary key:
One of the candidate key
Page 3 of 5
4. List all names of hotels which have presidential suite room
5. List the price and type of all rooms at the Grosvenor Hotel
6. List all names and addresses of guests currently staying in deluxe room of any hotel
(assume that if the guest has a tuple in the BOOKING relation, then they are currently
staying in the hotel)
7. List all names and addresses of guests currently staying at the Grosvenor Hotel (assume
that if the guest has a tuple in the BOOKING relation, then they are currently staying in the
hotel)
Page 4 of 5
4.2.2 Relational Algebra Operators
– CUSTOMER table:
Cust_ID Name
1 Green
2 Blue
ORDER table:
Page 5 of 5