You are on page 1of 6

Candidate No ■ •••••••••■■■■■■■■•••••

UNIVERSITY COLLEGE LONDON Seat No.

EXAMINATION FOR INTERNAL STUDENTS

MODULE CODE : COMP202P

ASSESSMENT : COMP202PA
PATTERN

MODULE NAME : Logic and Database Theory

DATE : 05 May 2017

TIME : 10:00 am

TIME ALLOWED : 2 hours 30 mins

This paper is suitable for candidates who attended classes for this
module in the following academic year(s):

2015/2016,2016/2017

Under no circumstances are the


attached papers to be removed from
the examination by the candidate.

2016/17-COMP202PA-001 -EXAM-135
© 2016 University College London . . TURNOVER
COMP202P Logic and Database Theory Examination 2016-17

Time allowed: 2.5hrs.


Answer all questions.
Marks for each question are indicated in square brackets. [n]
Calculators are permitted.

1. DATABASES

Answer ALL parts of the question.

a) Some of the statements 1 to 12 below about databases and database design may be false. In your

answer books, say whether each statement is true or false. You will gain one mark for a correct

answer but you will lose half a mark for an incorrect answer (the lowest mark you can receive for

all of this part of the question is zero). You may state that you don't know the answer, in which

case no marks will be gained or lost. If you are unsure about an answer then you may provide a

brief explanation for the answer you have given and this will be taken into account if your answer

is incorrect. [12]

1) All of the following are often given as advantages of database management systems: (i)
control of data redundancy; (ii) data consistency; (iii) more information from the same
amount of data; (iv) improved data integrity; (v) improved security; (vi) sharing of data;
(vii) reduced vulnerability to catastrophic failure.

2) An attribute domain is the set of all the theoretically possible values an attribute might
have.

3) A multi-valued attribute is an attribute which has different utilities for different users.

4) A Weak Entity Type is an entity which depends only weakly on other entities.

5) Multiplicity is the restriction on relationships in terms of their cardinality and


participation.

6) The 'lossless-join' property of tables that have been decomposed through normalisation
means that the loss of data from joining those tables is reduced.

7) Boyce-Codd Normal Form requires that any field or combination of fields on which
another field is dependent could have been a primary key of the table.

8) The following statement would be represented by a one to many relationship in an entity


relationship diagram: "each property is managed by at most one member of staff and a
member of staff may manage zero, one or many properties".

9) When translating an entity relationship diagram into a database schema, if two entities
have a one-to-one relationship with mandatory participation on both sides, then you
should combine the two entities into a single table.

[Question 1 continues on next page]

COMP202P 1 TURN OVER


[Question 1 continued]

10) The relational data model requires that a many-to-many relationship between entities is
not recorded in a separate table.

11) A table with a primary key is automatically in first normal form (1NF).
12) A table whose primary key is a composite of every field must necessarily be in third
normal form (3NF).

b) The schema for a retailer's database is shown below (primary keys are underlined)
customers (custlD. firstname, familyname, town, state)

orders (orderlD. custlD, date)


lineitems (orderlD. itemlD. quantity, despatched)

items (itemlD. description, unitcost, stocklevel)

itemSupplier (supplierlD. itemlD)

supplier (supplierlD. sName, sAddress, telephoneNo, delivers)

i) Write a SQL query to find how many customers there are in each state [8]

ii) Write a SQL query containing a sub-query to find how many customers bought more than 2 of
the same item in a single order. [8]

c) The schema below is of a database that records who played what role in which film and for how
many minutes they were on screen etc. Primary key fields are underlined, each table has a

composite primary key.

Some of the statements about the schema that follow may be false. In your answer books, write the
index number for each statement and say whether the statement is 'true', or 'false', or you 'don't
know' whether it is true or false. You will gain one mark for a correct answer but you will lose
half a mark for an incorrect answer (the lowest mark you can receive for all of this part is zero).
[5]
Rolf

I98S AI500 JohnGetz Rav


FI101 2009 AIS67 Mike Stuhlbam LanvGoomV

Fl 101 2009 AI020 TiUb Swinton


2004 Val Shusttxov Kane Cox 25

Fim 2004 A1002 Hsuuh Fmmm KxUeCo*


2004 A1003 KmeCox

F0030 1949 AlexGuncu 23

F0030 1949 A0O4S Alex Guinea Horatio D"Aseoyne 22

FIO49 1967 Sidnev Paacr


1975 A0995 JunsCam JonulunE 80

2006 A2OO6 Janus Bond


2008

FlItnNa DlrNo DinctoiName


FI099 DO77 J Com
Fl 101 D077 J Com
FI101 D07S E Cooi
FII22 D091 1 Sotoxulz
F0030 D024 R Hamn
FI049 D088 N lemma
F1050 D0S8 N lewwm
FI312 D15O MCmuibcU
FI313 D151 MFoma

[Question 1 continues on next page]

COMP202P CONTINUED
[Question 1 continued]

i) The database is in first normal form.

ii) Update anomalies are possible with the Film/Director table.

Hi) The composite key of FilmNo and actorNo won't be sufficient for the Film/Actor/Role table
because an actor may play the same role in different films.

iv) Removing all partial dependencies from this schema results in three additional tables.

v) One additional table will be created in moving this database from second to third normal form.

[Total: 33 marks]

COMP202P 3 TURN OVER


2. a. State, but do not attempt to prove, Kleene's Theorem.
[6 marks]

b. For each of the following non-deterministic finite state machines with null transi

tions (NFSM-A) find an equivalent deterministic finite state machine (FSM).

1.

a,b ( q\ ) a, b

start—>( <?o

2.

start

[6 marks]

c. For each machine in the previous question, write down a regular expression that

defines the language accepted by the machine.


[6 marks]

d. For each of the following regular expressions, define a deterministic FSM that ac

cepts the language defined by the regular expression.

1. ({aaa)\(aba))*

2. b((aa) * \(aaa)*)b
[7 marks]

e. Prove that the following language is not a regular language: the set of words over

the alphabet {0,1,_} with strictly more Is than 0s.


[8 marks]

[Total=33 marks]

COMP202P CONTINUED
3. Let L be a first-order language with two constants C = {c, d}, no function symbols

F = 0 and four predicate symbols P = {R, S, =, E}, where R and B are unary and E, =

are both binary and written infix. Interpret the nodes satisfying R as 'red', the nodes

satisfying B as 'blue' and the pair of nodes satisfying E as the edges of a graph.

a. Write down first order formulas that express the following statements

1. The graph is symmetric.

2. Every blue node is adjacent to a red node.

3. There is a blue node, not adjacent to any blue node.

4. There is a path from c to d of length exactly four.

[6 marks]

b. State the compactness theorem, for first-order logic.

[6 marks]

c. Define a first-order formula <f>n{x, y) which holds when 'there is a path from x to y

of length at most n', where n > 0. You may use a recursive definition.
[7 marks]

d. Let E = {->4>n{c, d) : n > 0}. Let F be a finite subset of E. Define a connected

graph G such that G\= F.


[7 marks]

e. Using the compactness theorem, what can you conclude about the class of all con

nected graphs?
[7 marks]

[Total=33 marks]

COMP202P 5 END OF PAPER

You might also like