Group Assignment
Group Assignment
Group Assignment
GROUP ASSIGNMENT
Due : 17/07/20
Question 1
Describe how a data model is represented in a relational database, and explain how
one might specify a relational database schema. [5 marks]
Each year the number of tourists coming to Cambridge increases by 10%. Most
of the pressure falls on a limited number of identified sites in the city centre. The
Tourist Board has restricted the size of any group visiting such a site to 20, and
requires a group of ten people or more to get a permit in advance. Most bookings
are made either by tour operators or directly by independent guides: the Tourist
Board will arrange guides for groups if asked to do so.
The Tourist Board issues permits to visit an identified site at a given time on a
given day, specifying the booking agent and the number in the group. Bookings
can be made up to 6 months beforehand. Permits are issued to registered tour
operators and guides on account, but in all other cases payment must be made in
advance. The data held for registered guides includes not only account details but
also their working hours and charges.
Design a schema for the relational database that is to record this information for
the Tourist Board. You may find it helpful to use domain types DATE, TIME and
MONEY in addition to standard programming language datatypes. You do not need
to specify the transactions that maintain the database, but you should state clearly
any assumptions that influence the schema design.
[15 marks]
1
Question 2
You have been invited by the university to assist in recording details of its
fund-raising. The main purpose is to coordinate the activities of agencies such
as the university and college development offices in their dealings with prospects.
The latter may be alumni of some college, charitable foundations or major
companies with an educational commitment; it is important to record their interests
(bioscience, student welfare, sport) so that they can be approached in a favourable
context; also their potential resources, in order to maximise the possible benefit
to the university. At any time a number of projects need funding: each will be
developed by a single agency, requiring that a target sum be raised by a given date;
projects will have one or more purposes which may be linked with the interests of
prospects. The other main use of the database is to keep a diary of interaction
with prospects; in order to retain their goodwill it is essential to know who has
been invited where and when, and in what context.
Design the schema for a relational database that will record this information. State
clearly any assumptions that you need to make in order to complete the design,
and indicate any difficulties that you foresee in maintaining the database.
[16 marks]
2
Question 3
where the underlined attributes represent the primary keys of the associated
relation. The table OwnedBy implements a relationship between persons and cars
using foreign keys. The table P articipatedIn implements a relationship between
persons, accident reports, and cars, where tuple (p, r, c) indicates that the person
p was the driver of the car c associated with the accident report r.
(a) Write an SQL query to return those pid’s of persons driving in at least one
accident, with no duplicates. [2 marks]
(b) Write an SQL query to return all tuples (pid, c), where c is the number of cars
owned by person pid (records where c = 0 do not have to be generated).
[2 marks]
(c) Write an SQL query to return all tuples (cid, c), where c is the number of
persons owning car cid (records where c = 0 do not have to be generated).
[2 marks]
(d ) Write a (nested) SQL query to return all tuples (pid, rid) where pid was
driving in the accident reported in rid, but the car driven by pid is not owned
by pid. [4 marks]
(e) Write an SQL query to return all tuples (rid, c), where c is the number of
drivers involved in the accident reported in by rid (records where c = 0 do not
have to be generated). [2 marks]
(f ) Write an SQL query to return all tuples (rid, c), where c is the number of cars
involved in the accident reported in by rid (records where c = 0 do not have
to be generated). [2 marks]
(g) Do the functional dependencies implied by the schema imply that the results
of queries (e) and (f ) will always be the same? Explain. [2 marks]
(h) Perhaps there is something wrong with this schema. How would you fix the
schema to ensure that results of queries (e) and (f ) would always be the same?
[4 marks]
(i) Convert your SQL statements from (a) to (h) to Relation Algebra [20 marks]