You are on page 1of 6

Mekelle University Faculty of Business & Economics

Computer Science Department

ICT 252: Theory of Databases

Mid-term Written Exam – May 2005 - Time Allowed: 2 hours

Marking Scheme

1. [15 marks total]


a) What is a data model? [2 marks]
A way of describing the data structures used in a database. OR
Describes the way data is stored in a db.

b) Name 2 data models that pre-date (came before) the relational model. [2 marks]
1 each for any 2 of: File-based processing model, Network model, Hierarchical
model
c) Describe the characteristics of the 2 data models you named for part (b). Use
examples to back up your answers. [8 marks]
File-based (1 mark for each point, to a max of 3; 1 for good examples):
 Flat text files (.5); data grouped into records (.5)
 File = an entity e.g. Customer in a bank system (.5); row of text = a record;
file = a record type (.5).
 Programmers – specific programs to access data/carry out tasks (.5); a lot
of work – different tasks need different programs (.5)
 Data duplication in different files (1)

Hierarchical model (1 mark for each point, to a max of 3; 1 for good examples):
 Recognition that data in a system related to other data in the same system –
can be modelled in a hierarchy (1)
 Can model 1-M relationships e.g. Customer has Accounts, Account contains
transactions (1)
 Tree structure used to store data (.5) – records of data, links between them
– showing parent-child relationships (.5)
 Record types for entities e.g. Customer (.5); data records in flat files (.5)

Network model (1 mark for each point, to a max of 3; 1 for good examples):
 Records & links between them (.5)– chained together in a network (.5)
 Record types for entities e.g. Customer (.5); records of the types stored in
network (.5)
 Relationships modelled as sets (.5) – of 1 owner record type & >= 1
member record type (.5) e.g. Customer & Accounts

Page 1 of 6
 A set occurrence relates one record of the owner record type to a set of
records of the member record type (1)e.g. Customer X has accounts A & B.

d) Why do you think the relational model is so widely used today? [3 marks]
Looking for demonstration/application of learning here – student should show why
they think relational model is better than previous models. Model answer below –
with points for which 1 mark each can be awarded highlighted in bold:

The relational model is an advance on the previous file-based and network


navigation models because it addresses the problems of those models, such as data
inconsistency due to having to store some data more than once.
The relational model also allows us to model more than just 1-Many & 1-1 relationships –
Many-many relationships can be modelled also (by converting to 2 1-many relationships).
A powerful query language, SQL, has been developed for the relational model – this language
makes it easier to retrieve data from the database than it was in the earlier models. This is
because SQL is a declarative, rather than a procedural, language. Thus it is easier to learn
and, provided the relational database has been well designed, allows the user to compose
complex queries.

2. [12 marks total]

a) In the relational model, what is a super key? [1 mark]


Attribute or combination of attributes that uniquely identify the tuples in a
relation/containing unique values for each tuple in a relation.
b) Based on the information given above, identify 2 super keys for Assignment-
Schema. [5 marks]
You will get more marks for giving super-keys that:
have more than one attribute in them
and
are different i.e. there is no attribute in common between the 2 super-keys

Possible superkeys:
(ass_sequence, crs_code) – because the sequence number is unique for the course.
(ass_code, ass_desc) – because ass_code is unique for the course
[any combination of attributes that includes ass_code or ass_sequence & crs_code is a
valid super key. Give 5 marks for any 2 combinations that meet this criteria.
Give 1 mark for ass_code on its own.
Give 0 marks for any other attribute on its own – as no other attribute uniquely
identifies tuples.
If the same attribute is specified in both answers e.g. ass_code or
ass_sequence/crs_code – deduct 1 or 2 marks – depends on actual answers.

c) Based on your answer to part (b), identify 2 candidate keys for Assignment-
Schema. Justify your answer by saying why your choices are candidate keys. [4
marks]
1 mark – answer are the minimal super keys based on answers to part b.

Page 2 of 6
1 mark – ass_code
1 mark – ass_sequence,crs_code
1 mark – they are candidate keys because they are minimal super keys i.e. subsets of a
super key for which there are no more subsets that are super keys.

d) Of the candidate keys you have selected in part (c), which would you choose to be
the primary key? Why? [2 marks]
Choose ass_code (1 mark) because it is less likely to change over time( sequence
number can be changed) (1 mark).

3. [24 marks total]

a) Draw the relational database schema for this database.


[10 marks]

Diagram should look something like the one shown below (this one has slightly different
attribute names – should be the attribute names given in the question).

1 mark for each table = 5


1 mark for each 1-m relationship = 4 (for each one, .5 for indicating FK on many side, .5 for
indicating PK on 1 side)
1 mark for showing that OrderLine has composite PK, OrdNo & ProdNo.

b) Answer the following questions.

Page 3 of 6
(i) Write a relational algebra expression to list all orders for January 2005 (note
that the dates are in the format dd/mm/yyyy). [1 mark]
OrdDate >= 1/1/2005  OrdDate <= 31/1/2005 (Order)
.5 for correct operator on correct relation, .5 for correct use of logical AND
(ii) Write a relational algebra expression to list the CustNo, CustName and
CustFathersName for all customers. [1 mark]
CustNo, CustName, CustFathersName (Customer)
1 for correct operator on correct relation
(iii) Write out the tuples that will be in the result of a projection operation to list the
CustKebele and CustTown attributes from the Customer relation. [1 mark]

Should have only 5 tuples – 17/Mekelle appears only once as duplicates


removed.
CustKebele CustTown
17 Mekelle
15 Mekelle
5 Mekelle
4 Bahir Dar
8 Bahir Dar

(iv) Write a relational algebra expression to show all orders, with the details of the
employees associated with them (using one operator). [1 mark]
Order Employee (natural join)

(v) How many tuples will be in the result of (iv)? [1 mark]


7 Order tuples have an EmpNo => 7 tuples in the result.

(vi) Show the 3 steps to derive the operation used in (iv), using the basic relational
algebra operations. Explain each step. [3 marks]
(1) Cartesian Product: Order x Employee
(1) Selection (to get only the matching rows): Order.EmpNo=Employee.EmpNo (Order x
Employee)
(1) Projection (to eliminate one of the EmpNo attributes):
OrdNo,OrdDate,CustNo,Order.EmpNo,EmpName,EmpFathersname,EmpPhone (Order.EmpNo=Employee.EmpNo (Order x
Employee))

(vii) What relations must be combined to show the OrdNo, OrdDate and ProdName
in the resulting relation? [2 marks]
Order, Product, OrderLine (1 for OrderLine, .5 each for Order, Product)
(viii) What relational algebra operator would you use to find products that are
contained in any order (the OrderLine relation shows the products contained in
an order)? [1 mark]

Page 4 of 6
Natural Join
(ix) What relational algebra operator would you use to find products that are
contained in every Order (the OrderLine relation shows the products contained
in an Order)? [1 mark]
Division
(x) Write a relational algebra expression to find how many orders each customer
has made. [2 marks]
CustNoGcount(OrdNo) (Order)
Uses aggregagte/summarise operator, count function on any attribute except
CustNo, grouped on CustNo.
1 mark – G operator; .5 for CustNo, .5 for count (x)

4. [9 marks total]
The E-R diagram in Figure 1 below is for the following system.

Employees are in Departments. A Department has many Employees in it.


Employees are also assigned to Projects. A Project has phases (e.g. Requirements Analysis,
Design, Development, Implementation). For each individual project, the start and end date of
each phase are stored.

Em ployee
EmpID Project
EmpName assigned_to ProjCode
EmpPhone ProjName
ProjStartDate

is_in
has

Departm ent
Phase
DeptID
DeptName PhaseName
EndDate
StartDate
Figure 1 – E-R Diagram

a) Give an example of a single-valued (functional) relationship from the diagram above


– specify the entity and the relationship. [1 mark]
The is_in (.5) relationship is single-valued for Employee (.5).
Or
Has (.5) for Phase (.5).
b) Explain why the example you gave is an example of a single-valued relationship. [2
marks]

Page 5 of 6
Because an instance of Employee can be related to a maximum of one instance of
Department. (1 mark)
Max cardinality is 1 (1 mark)

c) Give an example of existence dependency from the diagram above – specify the
entity and the relationship that it is existence dependent on. [1 mark]
Department is existence dependent on the has relationship.
Or Project/has, Phase/has, Department/is_in, Employee/is_in
.5 for the Entity, .5 for the relationship
d) Explain why the example you gave is an example of existence dependency. [2
marks]
Because the min cardinality is 1, meaning that an instance of Department must be
related to at least one Employee instance (or appropriate entity/relationship).

e) Give an example of an identifying relationship from the diagram above. [1 mark]


Has relationship (for Phase).
f) Fill in the gap and complete the rest of this sentence to define an identifying
relationship (write the completed sentence on your answer paper):

An identifying relationship is a relationship between a ___________ entity and


……..
An identifying relationship is a relationship between a weak entity and the entity from
which it gets part of its identifier/primary key.
1 mark – weak
1 mark – complete the sentence in a way that correctly defines it.

[2 marks]

END OF EXAM

Page 6 of 6

You might also like