You are on page 1of 10

[CSC2024]

NEWCASTLE UNIVERSITY

SEMESTER 2 2013/14

DATABASE TECHNOLOGY

Time allowed - 2 Hours

Instructions to candidates:
Answer ONE question from Section A
Answer ONE question from Section B
Write each answer in a SEPARATE answer book
The total marks available for this exam are 100
Marks shown for sub-sections are indicative only
[Turn Over]

[CSC2024]
SECTION A
Answer ONE question in this section
Question 1
a) Define the following terms:
i)

Entity

[5 marks]

ii) Attribute

[5 marks]

iii) Relationship

[5 marks]

b) A takeaway pizza shop decides to create a database


storing details of its products, customers, the orders placed
by customers and the deliveries which take the pizzas to
the customers. This question will require you to draw some
entity-relationship diagrams. In all the diagrams you
construct, you should show clearly the name of each entity
set, the name and degree of each relationship, and the
attributes of each entity. Identify suitable primary keys for
each of the entities in your designs. Remember to state any
assumptions that you make.
i)

Initially, the shop decides to store only details of


customers and the orders they place. The information
required for customers is a customer number, name, a
delivery address and a contact phone number. Orders
have their own ID number and need to be associated
with a customer. The shop also wants to record the
date and time an order is placed and the ID number of
the staff member who entered the order. No further
staff details are required. Draw an entity-relationship
diagram which illustrates this information.
[9 marks]

ii) The shop decides to extend the database to include


details of all of the pizzas that are available to order.
Each pizza has a numeric code (displayed in the shops
Page 2 of 10

[CSC2024]
menu), a price, a topping and a type of crust. You may
assume that an order may contain multiple pizzas. It is
possible that an order contains a request for more than
one of the same type of pizza; therefore it is necessary
to not just indicate which pizzas are required in an
order but also the quantity. Draw an entity-relationship
diagram which illustrates this information. IMPORTANT
NOTE if you wish to incorporate any entities in this
diagram which you first introduced in part i) of this
question and which you have not altered in this new
diagram, you do not need to show all the attributes of
these entities again.
[7 marks]
iii) Finally, the shop decides to extend the database further
by including details of the deliveries required to
transport the cooked orders to their destination. Orders
now need to be associated with a delivery you may
assume that an order will only occupy one delivery.
However, one delivery may contain multiple orders
being sent to different customers. The shop needs to
know the date and start time of each delivery and the
approximate distance it will cover. They also need to
record the ID number of the staff member making the
delivery. Again, no further staff details are required.
Draw an entity-relationship diagram which illustrates
this information. IMPORTANT NOTE if you wish to
incorporate any entities in this diagram which you first
introduced in part i) or part ii) of this question and which
you have not altered in this new diagram, you do not
need to show all the attributes of these entities again.
[9 marks]
c) When creating a database based on an entity-relationship
model, a table must be created for every strong entity in the

Page 3 of 10

[CSC2024]
entity-relationship
relationships too.
i)

diagram

and

for

some

of

the

List all the database tables that would be required if


you were to implement a database from the entityrelationship diagram you drew in your answer to Part b)
of this question. Note that you do not need to indicate
table contents or primary keys.
[5 marks]

ii) Occasionally, an entity-relationship diagram may


contain a weak entity. Describe what is meant by the
term weak entity.
[5 marks]
Question 2
a) Explain the following:
i)

Two important concepts when establishing a database


using the relational model are primary keys and foreign
keys. Explain each of these terms.
[5 marks]

ii) Give an example of an aggregate operator in SQL and


explain its purpose.
[5 marks]
b) A museum decides to introduce guided tours around its
exhibits. These tours have to be booked in advance by
customers. Each tour has a theme, e.g. Roman history,
with only one theme per tour. The museum designs and
implements the following database.
Customers
CustNo

CustName

CustAddress

Page 4 of 10

[CSC2024]
Reservations
CustNo

TourID

Tours (note that time is the start time and duration the
length of the tour in hours).
TourID

Theme

Date

Time

Duration

Price

Construct SQL statements for the following:


i)

Display every different theme in alphabetical order.


[2 marks]

ii) Display the number of reservations held in the name of


H. Pointer.
[2 marks]
iii) Increase the cost of tours T005 and T006 by 2.
[3 marks]
iv) Add a new customer, J. Watson, with address 221B
Baker Street and customer number 25 to the
database.
[1 mark]
v) Delete customer number 20, M. Ashley, from the
database.
[1 mark]
vi) State the durations of the most expensive tours.
[3 marks]
vii) Display the average price of a tour for all of the themes
in the Tours table.
[3 marks]

Page 5 of 10

[CSC2024]
viii) For all customers, list their customer number, name,
themes of tours they have attended and the dates they
attended.
[3 marks]
ix) There is a half-price offer on tour T007 where the
customer pays half the price shown in the database.
Display the price that the customer actually pays.
[2 marks]
c) Consider again the schema from part b) above.
i)

Explain why the following SQL is not a correct way for


finding customer numbers of those people booked both
on to any tour about natural history and any tour about
art.
SELECT R.custNo FROM Reservations R,
Tours T where T.tourID = R.tourID AND
T.theme = Natural history AND T.theme
= Art;
Suggest alternative, correct, SQL for finding customer
numbers of those people booked on to any tour about
natural history and any tour about art.
[10 marks]

ii) When the museum created the database, the foreign


keys were set up using the default option of ON
DELETE NO ACTION. Explain what would happen if
the museum attempted to delete a customer from the
Customers table.
[5 marks]
iii) If the museum had used ON DELETE CASCADE
instead, what would have happened if they attempted
to delete a customer from the Customers table?
[5 marks]

Page 6 of 10

[CSC2024]
SECTION B
Answer ONE question in this section
Question 1 (Transaction management).
a) Define the following terms, in the context of database
transaction management:
i)

Atomicity

[3 marks]

ii) Consistency

[3 marks]

iii) Isolation

[3 marks]

b) Consider the following schedule:


time

T1

T2

R(y)

W(y)

T3

200

R(z)

R(Y)

R(x)

W(x)

20

R(y)

W(y)

W(z)

10

R(y)

11

R(x)

12

Commit

13
14

X=10 Y=100 Z=1000

Rollback
CRASH

Page 7 of 10

300
2000

[CSC2024]
i)

Construct the serialization graph for S and use it to


determine whether S is conflict-serializable. Show the
graph.
[10 marks]

ii) At time 12, T2 commits. At time 13, T1 is rolled back


(for instance due to some application error). What
problem does this situation generate?
[6 marks]
c) During execution of the schedule above, log records are
generated so that recovery may take place in case of
failure. Suppose a checkpoint is made just before time 1.
i)

List the entries in the log. These have the following


format:
[Transaction ID, time, operation, object, before value, after value]

(remember: read operations are not logged)


[12 marks]
ii) At step 14, the DBMS fails. Show the undo/redo
operations that must performed using the log after
restart, in order to bring the database back to a working
state.
[13 marks]

Page 8 of 10

[CSC2024]
Question 2 (index management)
Consider a data file consisting of 50K records of fixed size
128B, which are stored in 2KB blocks.
The records are ordered on the value of a key field X.
The records also contain a non-key field Y. The values for X
have fixed size 64B. The values for Y have fixed size 32B.
a) Explain the difference between dense and nondense
(sparse) index. Explain under which conditions each type
can be used.
[6 marks]
b) Calculate:
i)

the blocking factor for the data (number of records per


block)
[4 marks]

ii) the number of blocks required to hold the records


[4 marks]
iii) the average number of block read from disk for a binary
search (for instance, when searching on X) [4 marks]
iv) the average number of block read from disk for a linear
search (for instance, when searching on Y)
[4 marks]
c) Two indexes are defined on the data file. The first is a
primary key, nondense index on X. The second is a dense
secondary index on Y.
The records for each of the indexes include a field with the
indexed value, of respective sizes (64B for the primary
index and 32B for the secondary index), and a pointer of
size 32B to the data record. Block size is still 2KB.
For each of the two indexes, calculate:
i)

The blocking factor (number of index entries per block)


[8 marks]

ii) The number of blocks required to store the entire index


[8 marks]
Page 9 of 10

[CSC2024]
iii) The average number of block reads required for a
binary search in the index
[8 marks]
d) What operations are required on the data file and on each
of the index files when a new record is inserted into the
database?
[4 marks]

Page 10 of 10

You might also like