Part 1 Flashcards

1
Q

Give a brief explanation of the difference between the rerms information and data.

A

Information is any kind of knowledge that is interpretable by people in some context. Data is a representaion of information; it has no meaning without a context.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Give a sentence that represents your understanding of the information content of the form.

A

The cource with the title “Relational Databases: theory and practice” has code M359, cource manager John Sykes and 618 students enrolled on it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

“Students enrolled” on the form is an example of devirred data. Explain what this means in terms of data in a database.

A

The value for “Student enrolled” is a dirrived data becouse it is calculated from other data in the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

State the number of occurences of the Supplies relationship shown in Figure 1.

A

5 ( the number of occurrence lines).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What can you deduce about the degree and participation conditions of the Supplies relationship based on the occurrences given?

A

The participation of the Supplier in the relationship is optional. An occurence of Supplier may be related to many occurrences of Part via the Supplier relationship.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

“The participation of the Supplier in the relationship is optional. An occurence of Supplier may be related to many occurrences of Part via the Supplier relationship.”

draw an E-R diagram showing the Supplies relationship between the two entities typesSupplier and Part.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A

relation Staff

StaffNumber: StaffNumbers

Name: Names

primary key StaffNumber

relation Computer

Code: Codes

Type: Types

primary key Code

relation IsAssigned

StaffNumber: StaffNumbers

Code: Codes

primary key StaffNumber

foreign key StaffNumber references Staff

alternative key Codes

foreign key Code references Computer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Write down relational algebra epressions;

Each staff member is associated with at least one task

A

constraint ((project Staff over EmployeeNumber)

difference

(project Task over EmployeeNumber))

isEmpty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A staff member can be associated with a secretarial task only if his/her grade is 2 or above.

A

constraint

(select Staff join Task where Grade > 1 and TaskType = Secretarial)

is empty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Demonstrate that Vets has no functional dependencies with determinant PersonName and with the right-hand side consisting of a single attribute.

A

PersonName>Vet? No, because e.g. Barker is associated with two values of Vet.

PersonName>AnimanName? No, because e.g. Ahmad is associated with animals with names Fluffy and Tiger.

PersonName>AnimalType? No, Because e.g. Barker is associated with both a dog and a horse.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Consider the following decomposition of Vets into the relations Vets1 and Animals:

Vets1 alias (project Vets over Vet, PersonName, AnimalName)

Animals alias (project Vets over AnimalName, AnimalType)

Is this a non-lossy decomposition?

A

The first decomposition gives a relation which can be depicted by the first three columns of the table; the second gives a relation which can be depicted by the last two columns, When we join these two decompositions together, we get the following tuples.

The second tuble depicted was not in the orginal relation, so this is a lossy decomposition - the information that the second tuple is not part of Vets is lost.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Consider the following relation R with functional dependecies as shown;

R(a, b, c, d)

a,b -> c

a,b -> d

a -> c

Is R in third normal form?

A

R is not in second normal form because of a -> c. ( That is, c is not fully functionally dependent on the primary key.)

So R cannot be in third normal form as it is not even in second normal form.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SELECT b.a1, b1

FROM a,b

WHERE b.a1 = a.a1

AND a2 > 500

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

SELECT a1, a2

FROM a

WHERE (SELECT COUNT(*)

FROM b

WHERE b.a1 = a.a1)<2

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

SELECT c2, f

FROM c, (SELECT b2, COUNT(*) AS f

FROM b

GROUP BY b2) AS t1

WHERE b2 = c1

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

List the membership number, name and date of birth of each member for whom date of birth has been stored

A

SELECT member_no, name, date_of_birth

FROM member

WHERE date_of_birth IS NOT NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Give the membership number and name of each member who is currently borrowing one oe more CDs.

A

SELECT DISTINCT member.member_no, name

FROM member, loan

WHERE member.member_no=loan.member_no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

For each member of the library, list his or her membership number and the number of CDs that he or she is currently borrowing. Your solution should show 0 as the number of CDs borrowed for members who are not currently borrowing CDs.

A

SELECT member.member_no, COUNT(cd_name) AS

number_borrowed

FROM member LEFT OUTER JOIN loan

ON member.member_no=loan.member_no

GROUP BY member.member_no

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

The administrator of the CD library has defined a procedure make_loan. The definition contains the declaration: make_loan(IN member_nos, IN cs_names)

where member_nos and CD_names are the domains of membership numbers and CD name, respectively. When make_loan is called, a row is added to the loan table containing the membership number of the member borrowing the CD, the name of the CD and the return date, which is calculated by the procedure.

Give two reasons why using this procedure may be preferable to wrking directly with the loan table.

A

Access conrol: A user can be given access to the procedure, but not have any access privilages to the underlying tables.

Ease of use: The procedure means that the processing (calculation of the return date, and statements relating to the specific tables) cab be hidden from the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

In addition to the make_loan procedure, a function items_borrowed is define which returns the number of the CD that a member has borrowed. Its signatures is

items_borrowed (IN member_nos) RETURNS INTEGER

A member is allowed to borrow up to 3 CDs. The member with membership number m48 wishes to borrow “Best of Bach” and “Magic of Mozart”.

You are required to write a transaction which either successfully completes with the member borrowed more than 3 CDs. You should use the procedure make_loan and the function items_borrowed to answer this question.

A

BEGIN

CALL make_loan(‘m48’, ‘Best of Bach’);

CALL make_loan(‘m48’, ‘Magic of Mozart’);

IF items_borrowed(‘m48’) > 3

THEN ROLLBACK WORK;

ELSE COMMIT WORK;

END IF;

END

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Entity-relationship diagram

Entity types

Additional constraints

Assumptions

Limitations

A

Entity types

Employee(StaffNo, Names_)_

Book(ISBN, Title, Author, Cost)

Reservation(StaffNo, ISBN, DateReserved)

Additional consttaints

c. 1 Reservation is a weak entity tyoe dependent on the entity type Employee. So each value of the StaffNo attribute in the entity type Reservation must be the same value as the StaffNo attribute of the Employee instance to which the Reservation entity type is related by the relationship Makes(a consequence of weak-strong entity types).
c. 2 Reservation is a weak entity type dependent on the entity type Book. So each value of the ISBN attribute in the entity type Reservation must be the same value as the ISBN attribute of the Book onstance to which the Reservation entity type is related by the relationship IsForA (a consequence of the weak-strong entity types.)

Assumptions - None

Limitations - None

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Give three reasons why it may be necessary to restructure a database after it has been built and installed.

A
  1. Correcting errors or omissions in the database design and/or implementing that remained undetected after acceptance testing.
  2. Optimising performance.
  3. Satisfying new and changing requirements.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Give two reasons why denormalisation is not usually performed unless a performance need arises.

A

Denormalisation results in duplicated information which (1) may require more disk space to store (2) may result in insertion, amendment and deletion anomalies if the duplicated information needs to be updated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What do (i) OLAP and (ii) OLTP systems facilitate within an organisation?

A

i. OLAP systems enable decision makers to gain insight into an organisation’s data from different, and multiple, perspectives.
ii. OLTP systems support the day-to-day operations of an organisation, such as purchasing, inventory, manufacturing, banking, payroll and accounting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Brefly wsplain what is meant by the term ‘time variant’ for a data warehouse, and describe the main consequence of this in terms of multi-dimensional model.

A

The term ‘time variant’ means that historical data is recorded. Time is always one of the dimensions of a multi-dimensional model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Give one reason why it is customary to implement a data warehouse seperately from the operational systems that are the source of its data.

A

Processing conflicts (queries vs updating).

Different organisation of data.

No historical data in operational systems.

Multiple sources/formats.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Briefly describe a document type definition and a document type declaration, making clear the distinction between the two terms.

A

A document type definistion is a set of markup declerations that define a document type and its structure.

A document type decleration is an instruction to assosiate XML within document type definision.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Explain why neither of these two terms (document type declaration, document type definition) is relevant to the XML data types as defined by SQL/XML.

A

The XML data type as defined by SQL/XML has a value that is a well-formed (i.e. parsable) XML document, which does not require a document type declaration or associated DTD; if one is included, its not in use.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Java host variables are different from host variables in other programming languages for which embedded SQL can be used becouse they:

a. are not specified in a declare section.
b. do not require the prefix: in embedded SQL statements.
c. cannot be used in host language statements.

A

a. are not specified in a declare section.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

JDBC implicitly establishes a cursor after executing the method:

a. getConnection
b. createStatement
c. executeQuery

A

c. executeQuery

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

To optain a value from the current wor of a JDBC result set, you have to use a get method with:

a. the column number.
b. the data type of the column in the database.
c. the data type of the result.

A

c. the data type of the result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

If the prepareStatement methid is executed for an SQL query containing a parameter marker, the query can be executed:

a. imediately.
b. after a value has been set for the parameter marker.
c. after a database connection is estalished.

A

b. after a value has been set for the paremeter marker.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

An object-relational mapping tool enables a Java program to access a database without writing SQL by:

a. using mapping schema to translate classes to tables.
b. using Java procedures stored in the database.
c. using a pre-compiler to translate Java to the native DBMS interface.

A

a. using a mapping schema to translate classes to tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Data Administrators, Database Administrators, Database Developers, Application Developers, End Users

a) … : in many cases will neither know, nor care, that a database is involved in meeting their needs.
b) … : will be responsible for translating the logical database design into a physical realisation within a specific DBMS product, balancing performance characteristics and physical storage option.
c) … : have responsibility for implementing the data use policies and conceptucal models as well as the day-to-day running of the database systems.
d) … : have a role that includes understanding the business requirements of the organisation and overseeing the planning and development of new data systems and the maintenance and control of existing systems.
e) … : are tasked with building or customising user processes (programs and utilities, report generators and query tools) to meet the specific requirements of the end users.

A

a) End users
b) Database Developers
c) Database administrators
d) Data Administrators
e) Application Developers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Consider the following part of a conceptual data model for annual shows, the
clubs that host them and the sponsors who fund the shows (Note that the E-R
diagram is incomplete).

a.)The relationship ‘FundedBy’ is not shown on the entity-relationship diagram
above. Complete the entity-relationship diagram above by showing the
relationship, representing the degree and participation conditions required to
meet the description given below:
Each AnnualShow is funded by zero or one Sponsors.
Each Sponsor supplies funding for one or more AnnualShows

A

AnnualShow(Year, Theme, Venue, SponsorName)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

Consider the following part of a conceptual data model for annual shows, the
clubs that host them and the sponsors who fund the shows (Note that the E-R
diagram is incomplete).

b) Briefly explain why each of the following scenarios cannot be represented by
the conceptual data model for annual shows.
(i) The West Midlands show will be co-hosted by clubs in Birmingham,

(ii)A sponsor has agreed to sponsor the 2015 Milton Keynes annual show,
but the organisers are still looking for a club to host it in that year.
Solihull and Coventry.

A

(i) Because an attribute can only have 1 value, also IsHostFor states that each annualShow must have 1 club.
(ii) Value cannot be NULL, isHostFor states that each annual show must have 1 club.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

(i) Give one reason why this table is not a relational table.

(ii) Represent the same information in a relational table and give the
primary key for the associated relation.

A

(i) The first row has two values under StaffManaged. A relational table can only have one value per attribute (only atomic values are allowed)/

(ii)

S1 Oxford S3

S1 OxforSaved S4

S2 Oxford S1

S5 London S2

primaryKey (EmployeeNumber, Location)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Complete the following relational representation so that it corresponds to the E-R
model above.
You may assume that suitable domains, StaffIds, ModuleCodes, StaffNames and
ModuleNames have already been defined.

A

Relation AcademicEditor

SfattId: StaffIds

StaffName: Staff Names

ModuleCode: Module Codes

Primary Key StaffId

{mandatory parcipation in Edits}

foreign key (ModuleCode) reference Module

{Edits 1:1}

Alternate key(ModuleCoede)

Relation Module

ModuleCode: ModuleCodes

ModuleName: Module Names

Primary key ModuleCode

Relation Writer

StaffId: staff ids

StaffName: staff names

ModuleCode: module codes

Primary key StaffId

{mandatory participation in Writers}

foreign key ModuleCode References Module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

(a) Give the table that is returned by the following query, using the data in
Table 1.
SELECT part_no, supplier_name, stock_level
FROM part
WHERE price >= 75

(b) Give the table that is returned by the following query, using the data in Table 1.
SELECT part_no
FROM part
WHERE stock_level > (SELECT SUM(stock_level)
FROM part WHERE price >=75)

(c) Give the table that is returned by the following query, using the data in
Table 1.
SELECT supplier_name, COUNT(*) as how_many
FROM part
WHERE part_name <> ‘gearbox’
GROUP BY supplier_name
HAVING MIN(stock_level) = 50

A

(a)

p22 Newton 25

p35 Electra 30

(b)

p04, p07

(c)

suppliers_name | how_many

Newton | 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

Write SQL queries to answer the following requests.
(a) List the part number and part name for all parts whose supplier is located in
London.

(b) Give the total monetary value of all stock where stock levels are above 50.
(c) Give the names of suppliers who supply more than one part.

A

(a)

SELECT part_no, part_name

FROM part a, supplier b

WHERE location =’London’ AND a.supplier_name = b.supplier_name

(b)

SELECT SUM(price*stock_level) AS stock_monetary_value

FROM part

GROUP BY part_no, stock_level

HAVING stock_level >50

(c)

SELECT supplier_name

FROM (SELECT supplier_name, COUNT(supplier_name) AS sn_count

FROM part

GROUB BY supplier_name) AS supp_names

WHERE supp_names.sn_count>1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

(a)

CREATE TABLE supplier
(supplier_name VARCHAR(25) NOT NULL,
location VARCHAR(25) NOT NULL,
PRIMARY KEY (supplier_name),

(b)

CREATE TABLE part
(part_no CHAR(3) NOT NULL,
part_name VARCHAR(25) NOT NULL,
supplier_name VARCHAR(25) NOT NULL,
stock_level INTEGER NOT NULL,
price INTEGER NOT NULL,
PRIMARY KEY (part_no),

A

(a)

CONSTRAINT supplier_parts

CHECK supplier_name IN (SELECT supplier_name FROM part);

(b)

CONSTRAINT fk_supplier_name

FOREIGN KEY supplier_name REFERENCES supplier;

CONSTRAINT part_no_valid

CHECK(part_no(SUBSTR(VALUE, 1, 1)= ‘p’) AND

(CAST(SUBSTR(VALUE,2,2) AS INT) BETWEEN 0 AND 99)));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

The delivery company wants to record the estimated distance and estimated
journey time for each delivery from a depot to a customer.
In the space below produce a new conceptual model so that the additional
requirements of recording estimated distance and estimated journey time are
shown.

A

C.1 Delivery is a weak entity type dependent on Depot. So, each value of IdCode in the entity type Delivery must be the same value as the IdCode of the Depot Instance to which the Delivery entity type must related by the relationship Deliver(a consequence of weak-strong entity types).

C.2 Delivery is a weak entity type dependant on Customer. So each value of Reference of the entity type Delivery must be the same as value as the Reference of the Customer instance …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

(a) Explain what is meant by denormalisation. What reason is usually given in
order to justify it?

(b) List the three types of anomalies that may arise after updating an
unnormalised table.

A

(a) Denormalisation is the process of merging tables that are associated by l:m relationships and the reason for this is usually to speed up the query process
(b) insertion, deletion and amendment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

The following is a well formed tree of XML-elements containing some data about
a DVD library. This tree represents some details of a single DVD and the
recordings on the DVD (chapters).

Write down headings for relations that are capable of holding the same data as
the dvd_library XML structure. You should use two relational headings and
underline their primary keys, to allow the data for the details of several DVDs and
their chapters to be stored and recreated. Show how the above data would
appear in your relations.
(You can assume that the order of chapters on a DVD in the XML tree structure
does not need to be recreated).

A

dvd(catalogue_no, title, artist)

Chapters (chapter_no, title, dvd_cat_no)

dvd

catalogue_no | title | artist

B550361 | Spirited away | Hayao Miyazaki

chapters

chapter_no | title | dvd_cat_no

1 | midle of nowhere | B550361

2 | It’s just a dream | B550361

3 | Finding work | B550361

4 | Meeting Yubaba | B550361

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Complete the following sentences by inserting appropriate words into the
underlined spaces, one per space, by choosing words from the following
list. The same word may occur more than once in the sentences. Not all
the words listed are used in the sentences.
Words: security, logical, many, distributed, four, three, two, mobile,
schema, data, index, storage, space, user, management,
representation, external, model, server, transfer, exchange,
interaction, mapping, property, replicated.

(i) The _____________-schema architecture is a general model of
database representation that places importance on the separation of
the ______________, _____________ and _____________
schemas.
(ii) In this model, data independence is achieved by _______________
between schema representations. Logical data independence is
provided by the _______________ between _____________ and
_______________ schemas.
(iii) In the _______________-schema architecture there can be many
_______________ schemas, but only a single ______________
and _______________ schema defined for a database.

A

(i) three, logical, storage, external
(ii) mapping, mapping, logical, external
(iii) three, external, logical, storage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

(a) Give a description of the relationship, Signs, in Figure 1. Your answer
should include a description of the degree and participation information for
the relationship.

(b) What is the purpose of the Additional Constraints section of a Conceptual
Data Model?

(c) Illustrate your answer to part (b) by writing a suitable Additional Constraint
to ensure that, for each of the players signed by a team, the team’s age
limits (implied by the attribute names chosen for the entity types in
Figure 1) are appropriately enforced.

A

(a)

Team can be signs by zero, one or many Playesr

Player can be signs for zero or one Team

(b)

The additional constrains section records any conditions that, if not enforced, would permit the existance of inconsistent data in the database. Only those constraints that cannot be shown elswhere in E-R model are listed here.

47
Q

(a) Write down the relational representation of the part of the conceptual data
model shown in Question 2, Figure 1, using the relational theory taught in
Block 2 of the course.
You can assume that the domains TeamNames, Ages, PlayerNames,
RegistrationNumbers and Dates have all been declared so that you can
use them but do not need to declare them

(b) The situation modelled in Question 2, Figure 1, is to be changed so that
the entity type Team has mandatory participation in the relationship Signs.
To represent this new constraint, write down a relational expression that
could be added to the answer you gave in part (a) above.

A

Relation Represention

relation Team

Name: TeamNames

MinimumAcceptedAge: Ages

MaximumAcceptedAge: Ages

Primary key Name

relation Player

RegistrationNumber: RegistrationNumbers

Name: PlayerNames

DateOfBirth: Dates

Primary key RegistrationNumber

Relation Sings

Name: TeamNames

RegistrationNumber: RegistrationNumbers

Primary key RegistrationNumber

foreign key ReegistrationNumber References Player

foreign key Name References Team

(b)

CONSTRAINT ((project Team over Name)DIFFERENCE (project Sings over Name)) isEmpty

48
Q

The Hospital scenario used in the course materials has a relational
representation that includes the following relational headings:
Nurse(StaffNo, NurseName, WardNo)
Supervises(StaffNo, Supervisor)
Ward(WardNo, WardName, NumberOfBeds)
The attributes StaffNo of Nurse and Supervises and the attribute Supervisor
are defined using one domain. The attributes WardNo of Nurse and Ward are
defined using one domain. All other attributes have their own domains.
Note: You only require the information given in the above relational headings
and the domain descriptions to answer this question.
(a) Write down a relational algebra expression which will evaluate to give the
name of the nurse and the ward number for each nurse in the Nurse
relation.
[1]
(b) Write down a relational algebra expression which will evaluate to give the
staff number, ward name and the number of beds in that ward for each
nurse in the Nurse relation.
[2]
(c) Write down a relational algebra expression which will evaluate to give the
name of any nurse who is a supervisor.

A

(a)

PROJECT Nurse OVER NurseNumber, WardNo

(b)

PROJECT (Nurse JOIN Ward) OVER StaffNumber, WardName, NumberOfBeds

(c)

PROJECT(Supervises JOIN(Nurse rename(StaffNo as Supervisor))) OVER NurseName

49
Q

Explain why the Sample 1 data is not a valid representation of values of
the relation Company.

A

Because the Manager column on the table depicted does not have values for each row, a realation must have atomic values for each attribute.

50
Q

(b) Give the table that is returned by the following query.
SELECT budget_code, COUNT(DISTINCT staff_number) AS c
FROM project p, assignment a
WHERE p.project_code = a.project_code
GROUP BY budget_code
[1]
(c) Express the following query in English, and give the table that the query
returns.
SELECT project_code
FROM project p
WHERE person_hours > (SELECT SUM(hours)
FROM assignment a
WHERE a.project_code =
p.project_code)

A

(b)

budget_code | c

c43 | 2

f19 | 1

(c)

List the project codes where the person hours is greater than the total number of hours logged in assigment for that project

51
Q

(a) The owner of the tables executes the following statement, when the tables
contain the values shown in Table 1 in the Appendix.
INSERT INTO availability VALUES(‘4’, 45)
Give the table that is then returned by the query:
SELECT *

FROM v

(b) The owner of the tables executes the following statement, when the tables
contain the values shown in Table 1 in the Appendix.
UPDATE v
SET person_hours=15
WHERE project_code=’d’
Give the table that is then returned by the query:
SELECT *
FROM v
and the table that is returned by the query:
SELECT *
FROM project

A

(a)

project_code | person_hours

d | 60

(b)

b | 40

a | 30 | c43

b | 40 | c43

c | 20 | c43

d | 60 | f19

52
Q

(a) Name the two ways in which a table may be fragmented in a distributed
database, and for each one give the operation required to reconstruct the
original table.

(b) In the global optimisation stage of query optimisation for distributed
databases, what must be minimised?

(c) Who or what are the two main users of the metadata that should be stored
in the metadata repository associated with a data warehousing system?

A

(a)

Horizontally - UNION

Vertical - JOIN

(b)

Transfer of data

(c)

The decision makers in the organisation, and the data warehousing system itself.

53
Q

(a) The main organisation of an XML document is expressed in terms of
(i) entities
(ii) attributes
(iii) elements
[1]
(b) Valid XML must
(i) contain processing instructions
(ii) conform to a DTD or schema
(iii) be organised as a tree structure
[1]
(c) The SQL/XML function
(i) XMLELEMENT
(ii) XMLTABLE
(iii) XMLFOREST
is not an XML publishing function. [1]
(d) Shredding an XML document is a process that
(i) destroys the document
(ii) changes the order of the data content of the document
(iii) extracts data from the document and inserts it into database tables.
[1]
(e) In SQL/XML, the XML data type has values that must be
(i) parsed XML
(ii) stored as character strings
(iii) valid XML.

A

(a) - ellements
(b) - conform to a DTD or schema
(c) - XMLTABLE

(d) - extracts data from the document and inserts it into database tables.
(e) - stored as character strings

54
Q

Complete the following sentences by choosing the most appropriate term from
the list of three given below that sentence (circle or mark the chosen term
clearly).
(a) _________ data refers to data that will continue to be stored even when the
applications creating and using the data are no longer running.
static | persistent | updatable
[1 mark]
(b) Databases have many rules, usually known as _____________, that define
the valid data that can be stored in the database.
concerns | restrictions | constraints
[1 mark]
(c) OLAP systems include software to perform ___________________.
transaction processing | data mining | maintenance
[1 mark]
(d) The __________ schema is concerned with data as it is presented to user
processes.
external | storage | logical
[1 mark]
(e) A domain of discourse describes the information and data that is
____________________________ an organisation.
relevant to | owned by | trusted by

A

(a) - persistent
(b) - constraints
(c) - data mining
(d) - external
(e) - relevant to

55
Q

(b) The same company keeps records of deliveries undertaken by their van
drivers (typically several a day). Each delivery is to a single customer.
The following information needs recording for each delivery:
• the van registration number (RegistrationNo);
• the driver’s staff number (StaffNo);
• the date (Date);
• the time started (TimeStarted);
• the time completed (TimeCompleted); and
• the customer order number (CustomerOrderNo).
Write down all possible identifiers of the Delivery entity type.

A
56
Q
A
  1. Need for distinct rows - duplicate in row 1 & 7
  2. every collumn must have a value - missing value in Occupier
57
Q

(i) Write down a table representing the relation C difference A.
[1 mark]
(ii) Write down a relation B and a relational operator op such that
A op B = C.

A

(i)

Student | Cource | ExamMark | CourceWorkMark

Ian Smith | Interaction Design | 58 | 76

(ii)

UNION =

58
Q

(i)

relation Book
BookId: BookIds
Title: BookTitles
ExpectedPublicationDate: Dates

(ii)

relation Chapter
ChapterNumber: ChapterNumbers
BookId: BookIds
DateDue: Dates

(iii)
relation Writer
WriterRef: WriterRefs
Name: Names

A

(i)

Primary Key BookId

{mandatory participation of Book in ConsistOf relationship}

CONSTRAINT((project Book OVER BookID) DIFFERENCE (Project Chapter over BookID)isEmpty)

(ii)

Primary Key (ChapterNumber, BookID)

{mandatory participation of ChapterNumber in Writes relationship}

foreign key BookID Reference Book

(iii)

Primary Key WriterRef

59
Q

(a)
SELECT SUM(y) as total_y, SUM(b) as total_b
FROM alpha JOIN omega ON y = b
[1 mark]
(b)
SELECT x, COUNT(a) as how_many
FROM alpha LEFT OUTER JOIN omega ON x = d
GROUP BY x
[2 marks]
(c)
SELECT *
FROM alpha
WHERE EXISTS (SELECT *
FROM omega
WHERE x = d
AND y = b )

A

(a)

total_y | total_b

500 | 550

(b)

x | how_many

Bath | 1

Hull | 2

York | 1

Goole | 0

(c)

Hull | 200 | granite

60
Q

For each of the following requests, write an SQL query that answers the request.
(a) List the number of every script which contains an answer to question 2
where the mark for that answer is less than 25.
[1 mark]
(b) List the number and total mark of every script whose total mark (the sum of
the marks of the two questions answered) is 50 or more.
[2 marks]
(c) List the name of every marker who has marked at least one question 4.

A

(a)

SELECT Script_no

FROM marked

WHERE question = 2

AND mark < 25

(b)

SELECT Script_no, SUM(mark) AS total_mark

FROM marked

GROUP BY script_no

HAVING total_mark >49

(c)

SELECT DISTINCT name

FROM marked_by, marked

WHERE quiestion = 4

AND marked_by.script_no = marked.script_no

61
Q
A

ALTER table employee

ADD CONSTRAINT mandatory_participation_at_the_employee_end

CHECK (EXISTS(SELECT *

FROM project

WHERE employee.employee_no = project.employee_no))

ALTER table project

ADD CONSTRAINT relationship_works_on

FOREIGN KEY (employee_no) References employee

62
Q

(a) Briefly explain why the E-R model only allows each borrower to take a
particular book out on loan overnight on one occasion.
[1 mark]
(b) Revise the model to allow each borrower to take a particular book out on
loan overnight on more than one occasion but ensures that a book can be
on loan overnight to only one borrower at a time.
[2 marks]
(c) Explain why Loan is a weak entity type in the original model fragment.

A

(a)

If there were two occurrences of identical BorrowerNo and BookNo it would invalidate the model as each row in the table must be unique

BorrowerNo and BookNo must be unique and this is not the case if the book is on loan overnight on more than one occasion.

(b)

Loan(BorrowerNo, BookNo, Date)

(c)

The weak entity type Loan cannot exist without the existance of the entity type Borrower and Book.

63
Q

(a) What is database denormalisation? Why is it sometimes desirable to
denormalise a database? How can denormalisation result in inconsistent
data?
[3 marks]
(b) Give two reasons why it may be necessary to restructure a database after it
has been installed and accepted by the client.

A

(a)

Database denormalisation is the process of merging tables. It can improve the efficiency of the queries by reducing the number of joins that are needed to obtain data, It can result in duplicated data which can cause insertion amendmenmt and deletion anomalies.

(b)

Meet changes in requirements To optimise the performence if data retrival.

64
Q

(a)One approach applicable to managing distributed data is a replication
system. Name two other distinct approaches to managing distributed data.
[2 marks]
(b) A method of supporting transactions for multi-servers is two-phase commit.
Describe what happens in each of the two phases. What is the condition for
the second phase to begin?

A

(a)

Client multiserver system

Distributed database

(b)

First phase all locations involved in transaction sent a request asking to prepare to commit.

Second phase each sent a request to complete the commit.

The second phase starts once all locations have replied that they are ready to commit,

65
Q

The following is a well formed tree of XML-elements containing some data about
CD (compact disc) library. This tree represents some details of a single CD and
the recordings on the CD (tracks).

B550361

Walton Symphony Orchestra

1

2

3

4

Write down headings for relations that are capable of holding the same data as
the cd_library XML structure. You should use two relational headings and
underline their primary keys, to allow the data for the details of several CDs and
their tracks to be stored and recreated. Show how the above data would appear
in your relations.
(You can assume that the order of tracks on a CD in the XML tree structure does
not need to be recreated).

A

CD(CatalogueNo, Title, Artist)

Track(CatalogueNo, TrackNo, Title)

CatalogueNo | Title | Artist

B550361 | Beethoven’s 5th.. | Walton Symphony Orchestra

CataloqueNo | TrackNo | Title

B550361 | 1 | 1st

B550361 | 2 |2nd

B550361 | 3 | 3rd

B550361 | 4 | 4th

66
Q

Complete the following sentences by choosing the most appropriate term from
the list of three given below that sentence (circle or mark the chosen term
clearly).
(a) A database is a collection of ____________________ structured data.
static /persistent/ updatable
[1 mark]
(b) OLTP systems include software to perform ___________________.
transaction processing /data mining /productive maintenance
[1 mark]
(c) A domain of discourse describes the information and data that is
____________________________ an organisation.
relevant to/ owned by /trusted by
[1 mark]
(d) The ________________ schema in the three schema architecture is
concerned with how data is physically represented within the file system of a
DBMS.
logical /storage /external
[1 mark]
(e) COMMIT and ROLLBACK are SQL commands that support
______________ management.
change /transaction /security

A

(a) - persistent
(b) - transaction processing
(c) - relevant to
(d) - storage
(e) - transaction

67
Q

(i) “Office O32 is currently the location for a single employee E243.”
IS CONSISTENT IS NOT CONSISTENT
[1 mark]
(ii) “All of the company’s current employees, except employee E243, are
located in the same office O31.”
IS CONSISTENT IS NOT CONSISTENT
[1 mark]
(iii) “From tomorrow employee E243 will be located in O32 on Monday,
Tuesday and Friday, but will be located in office O31 on Wednesday
and Thursday.”
IS CONSISTENT IS NOT CONSISTENT

A

(a)

(i) -is consistent
(ii) - is not consistent
(iii) - is not consistent

68
Q
A
69
Q

(a) Entity-relationship diagram
[4 marks]
(b) Entity types

A

(b)

X(a1, a2)

Y(a3, a4)

Z(a7, a8)

70
Q

(a) Define what is meant by the transitivity property of functional dependencies.
[1 mark]
(b) Consider the relation with heading R(a, b, c, d, e).
(i) Given that the functional dependency F1: c → (a, b) holds in this
relation, show that the functional dependencies
F2: c → d
F3: c → e
both hold in the relation.
[2 marks]
(ii) The set { F1, F2, F3, F4, F5, F6 } is the complete set of non-trivial
functional dependencies with irreducible determinants on R,
where F1 … F6 are as follows:
F1: c → (a, b) F2: c → d F3: c → e
F4: (a, b) → c F5: (a, b) → d F6: (a, b) → e
Show that R is in BCNF.
[

A

a)

If A determines B and B determines C, then A must determine C

(b)

(i)

c –> a,b (F1)

a,b –> d and e (primary key)

(ii)

To be in BCNF any determinant must be a candidate key; (a,b) is a candidate key since it’s the primary key; and the other determinant (c) is a candidate key since it can determine all attributes

71
Q

(i) Write down the relational expression above replacing operator1 and
operator2 by two set operators introduced in Block 2.
[2 marks]
(ii) Write down a relational table for Relation3.
[1 mark]
(iii) Write down a relational table for Relation4.

A

(a) - no value for office

(b)

(i)

operator1 - difference, operator2 - union

(ii)

Con | Pat | Hos

C3 | P4 | H1

(iii)

Con | Pat | Hos

C2 | P5 | H2

72
Q

For each of the following SQL queries, give the table that the query returns.
Note: in your answer include the table headings.
(a)
SELECT country, spent
FROM budget
WHERE received > 50000;
[1 mark]
(b)
SELECT gift_id, donor_email, appeal_code
FROM appeal, donation
WHERE appeal.country = donation.country
AND donor_email IN (‘mrf3@easymail.com’,
‘jbc@yes.co.uk’);
[2 marks]
(c)
SELECT gift_id, donor_email, appeal_code
FROM appeal RIGHT OUTER JOIN donation
ON appeal.country = donation.country
WHERE donor_email IN (‘mrf3@easymail.com’,
‘jbc@yes.co.uk’);
[

A

(a)

country | spent

Belka | 240000

Costa Luna | 60000

(b)

gift_id | donor_email | appeal_code

D5 | jbc@ | A35

(c)

gift_id | donor_email | appeal_code

d5 | jbc | A35

d1 | jbc | NULL

d4 | mrf | NULL

73
Q

(a) Give SQL queries that can be used to answer the following requests:
(i) How many donations have been made by credit card?
[1 mark]
(ii) Give the email address of every donor who has made one or more
donations without specifying a destination country.
[2 marks]
(b) Rewrite the following query so that it uses a subquery in the FROM clause
instead of using a HAVING clause.
SELECT donor_email, COUNT (*) AS num
FROM donation
GROUP by donor_email
HAVING COUNT(*) >= 2;
[

A

(a)

(i)

SELECT COUNT (*) AS num

FROM Donation

WHERE Payment_type = ‘credit card’

(ii)

SELECT DISTINCT Donor_email

FROM Donation

WHERE Country IS NULL

(b)

SELECT *

FROM (SELECT Donor_email, COUNT(*) AS num

FROM Donation

GROUP BY Donour_email) AS s

WHERE num >1

74
Q

(a) Which solution would you recommend? Briefly justify your answer. (You
should identify one relevant difference between a trigger and a procedure.)
Note: You are not expected to implement the proposed solutions.

(b) What are the differences in the firing condition for the trigger defined, in one
case, as BEFORE UPDATE and, in the other case, as AFTER UPDATE? For
solution 2, would BEFORE UPDATE be more appropriate than AFTER
UPDATE? Briefly justify your answer.

A

(a) Procedure has to be invoked by a user. And trigger is invoked automaticly on update.

(b)

The trigger timing is specified AFTER that the triger is fired after the insertion into the table is complete. BEFORE - so that the trogger is fired before the insertion into the table.

I would like to use AFTER UPDATE because audit_limits record all value including current one. If audit table recorded only historical data, then we could use BEFORE UPDATE which copy previous value before it is overwritten by current value.

75
Q

(a) Briefly explain why the conceptual data (E-R) model given in the above
figure will fail to meet the requirements if a person can be qualified for a
number of different roles at the same level in the same sport, and a person
can be qualified in the same role but at different levels for the same sport.
For example:
Kathy could be qualified as an international lineperson and timekeeper
for hockey
Peter could be qualified as both a regional and international referee for
football.
[2 marks]
(b) Revise the model to overcome the limitation identified in part (a).
[1 mark]
(c) Explain why Qualification is a weak entity type in the model fragment.

A

(a) The primary key of the Qualification entity type forces a person and sports combination to be unique meaning a given person can only be associated with a given sport.
(b) Qualification(PersonId, SportName, Role, Level)

(c)

Occurences within the Qualification entity type are dependent on the existance of relevant occurences in the Person and SportsDiscipline entity types. Qualififacation cannot exist without participarion from these two entity types.

76
Q

(a) Explain what is meant by database reorganisation; and database
restructuring. Relate your answers to the three-schema architecture.
Note: a one sentence answer in each case should be sufficient.
[2 marks]
(b) Give three reasons why it may be necessary to restructure a database after
it has been installed and accepted by the client.

A

(a) Database reorganisation involves changes to the storages schema which specifies how the DB is stored and accessed. Database restructuringinvolves changes to the logical schema to mayby safisfy any new requiremnts.
(b) To correct anu errors in design, to incorporate any changes to requirements and to optimise retrival performance.

77
Q

(a) One approach applicable to managing distributed data is a client-multiserver
system. Name two other distinct approaches to managing distributed data.
[2 marks]
(b) A method of supporting transactions for multi-servers is two-phase commit.
Describe what happens in each of the two phases. What is the condition for
the second phase to begin?

A

(a)

Replicated systems and distributed database

(b)

1st phase; all involved are sent a request to prepare to commit, when all have replied with ‘ready to commit’ the 2nd phase begins

2nd pase; all involved are requested to complete the commit, if any one location involved doesn’t reply or replies with cannot commit the commits fails.

78
Q

(a) Give one advantage and one disadvantage of dynamic SQL against static
SQL.
[2 marks]
(b) Give two advantages of scripting languages in database applications.
[2 marks]
(c) Give one advantage of prepared statements.

A

(a) Advantage: your program ca accept user input to define the SQL statement(s) to execute

Disadvantage: performance is not as static SQL

(b) Simplified customisation for the user ease of text processing.
(c) more efficient

79
Q

Complete the following sentences by choosing the most appropriate term from
the list of three given below that sentence.
(a) A database is a collection of ____________________ data.
(i) static
(ii) simple
(iii) structured [1]
(b) OLAP systems include software to perform ___________________.
(i) transaction processing
(ii) data mining
(iii) productive maintenance [1]
(c) A domain of discourse describes the information and data that is
____________________________ an organisation.
(i) relevant to
(ii) owned by
(iii) trusted by [1]
(d) The ________________ schema in the three schema architecture is
concerned with a representation of the data that is independent of how it
is stored and how it is presented outside of the DBMS.
(i) logical
(ii) physical
(iii) external [1]
(e) The file-based approach to managing data is likely to suffer from
______________.
(i) impedance mismatch
(ii) inaccurate data
(iii) unproductive maintenance

A

(a) - structure
(b) - data mining
(c) - relevant to
(d) - logical
(e) - unproductive maintenance

80
Q

a) State if each of the following statements about the items and their
locations in display cases is TRUE or FALSE or UNKNOWN (that is their
truth cannot be determined from the information given).
(i) A display case must be the location for more than one artefact.
[1]
(ii) All artefacts must be located in display cases.
[1]
(iii) There is a display case that is not the location for any artefacts.

(b) The following sentences describe the relationship between Cars and their
Owners:
Each Car is owned by exactly one Owner. Each Owner owns one or more Cars.

A

(i) - false
(ii) - false
(iii) - false

(b)

81
Q

Question 3
Using as few entity types as possible, write down the E-R diagram and the
entity types A, B and C (underlining the identifiers of the entity types) that are
represented by the following relational model.
relation A
A1: DomA1
A2: DomA2
primary key A1
relation B
B1: DomB1
B2: DomB2
A1: DomA1
primary key B1
alternate key A1
{relationship R1}
foreign key A1 references A
relation BtoC
{relationship BtoC}
B1:DomB1
C1:DomC1
primary key (B1, C1)
foreign key B1 references B
foreign key C1 references C
relation C
C1: DomC1
C2: DomC2
primary key C1

A

A(A1, A2)

B(B1, B2)

C(C1, C2)

82
Q

(a)Identify the two possible candidate keys of the relation R, using the
information given in the above table.

(b)

In a certain organisation, each member of staff is identified by a unique
staff number. Consider the following three relations, in which you may
assume that attributes with the same name are defined over the same
domain and that attributes with different names are defined over different
domains.
Secretary(StaffNumber, SecretaryName)
Technician(StaffNumber, TechnicianName)
Salesman(StaffNumber, SalesmanName)
Write down a relational constraint definition that will enforce the constraint
that no member of staff can be both a technician and a secretary.

A

(a) Attribute1, Attribute3

(b)

CONSTRAINT((project Secretary OVER StaffNumber) intersection (project Technical OVER StaffNumber)) isEmpty

83
Q

(a)
SELECT *
FROM t
WHERE d2 = ( SELECT MAX(c2)
FROM s)
[1]
(b)
SELECT t.d1, COUNT(c1) AS num
FROM t LEFT OUTER JOIN s ON t.d1 = s.d1
GROUP BY t.d1
[2]
M359/S 9 [TURN OVER]
(c)
SELECT d1
FROM t
WHERE d2 IN (SELECT c2
FROM s
WHERE t.d1 = s.d1)

A

(a)

d1 | d2

bar | 3

baz | 3

(b)

t.d1 | num

foo | 1

bar | 2

baz | 2

ram | 0

(c)

d1

baz

84
Q

For each of the following requests, write an SQL query that answers the
request.
(a) List the number of every script which contains an answer to question 2
where the mark for that answer is less than 25.
[1]
(b) List the number and total mark of every script whose total mark (the sum
of the marks of the two questions answered) is 50 or more.
[2]
(c) List the name of every marker who has marked at least one question 4.

A

(a)

SELECT script_num

FROM marked

WHERE question =’2’ AND mark < 25

(b)

SELECT script_num, SUM(mark) AS total_mark

FROM marked

GROUP BY script_num

HAVING total_marks >49

(c)

SELECT DISTINCT name

FROM marked m, marked_by mb

WHERE m.script_num = mb.script_num AND question = ‘4’

85
Q

A partial implementation contains the following SQL (all relevant SQL domains
are defined, but only the constraints shown have been defined on the tables
and columns at this stage of development):
CREATE TABLE stacker (
staff_no staff_numbers,
grade grades,
PRIMARY KEY (staff_no) )
CREATE TABLE warehouse (
warehouse_id warehouse_ids,
capacity warehouse_capacities,
address addresses,
PRIMARY KEY (warehouse_id) )
It is decided to implement the WorksAt relationship with a foreign key. Give
the necessary ALTER TABLE statement(s) to add an appropriate column to
the relevant table and add any other required constraints. You may assume
that the tables currently contain no data.

A

ALTER TABLE Stacker ADD warehouse_id warehouse_ids

ALTER TABLE stacker ADD CONSTRAINT works_at FOREIGN KEY (warehouse_id) References warehouse ON DELETE RESTRICT

ALTER TABLE warehouse ADD CONSTRAINT mandatory_stacker_in_warehouse CHECK (NOT EXISTS ((SELECT DISTINCT warehouse_id FROM warehouse) EXEPT (SELECT DISTINCT warehouse_id FROM stacker))

86
Q

(a) During the database design task we may choose to replace a composite
primary key with a surrogate key. Give one advantage and one
disadvantage of employing surrogate keys.
[2]
(b) What is the purpose of adaptive maintenance? What does adaptive
maintenance involve?
[2]
(c) Database restructuring may involve modifying the columns of a table.
Under what circumstances does modifying the columns of a table become
difficult and need to be done with care?
[

A

(a) Advantage: improved indexing whcih will speed up searching

Disadvantage: the surrogate key is often unrelated to the data in the rows

(b)

adaptive maitenance involves restructuring the SB fro reasins of changes and additions to requirements of the DB

(c)?

87
Q

(a) What is the main aim of replication systems?
[1]
(b) Briefly describe the two main roles of a replication server?

A

(a)

The main aim of replication systems is to keep the processing locally, which minimises the number of remote connections and redueces the danger of remote site or connections failure.

(b)

  1. to receive or collect updates from the local DBMS and pass them onto the remote replication servers.
  2. to receive or collect updates from remote replication server and update the local DBMS.
88
Q

(a) Are the above code fragments examples of ODBC calls, Embedded SQL,
or JDBC calls?
[1]
(b) Write down the names of the Host Variables that appear in the above
statements.
[1]
(c) For each of the following statements state if it is true for ODBC, Objectrelational
Mapping, neither or both (underline the correct answer in each
case):
(i) This does not require the application programmer to know SQL.
ODBC Object-relational mapping Neither Both
(ii) In some circumstances this allows a database schema to be
automatically generated to meet the data storage requirements of
an application program.
ODBC Object-relational mapping Neither Both
(iii) This can be used interactively by the end-user to access a
database.
ODBC Object-relational mapping Neither Both

A

(a) - embedded sql
(b) - code name value

(c)

(i) - ODBC
(ii) - Neither
(iii) - ODBC

89
Q

Complete the following sentences by choosing the most appropriate term from
the list of three given below that sentence (circle or mark the chosen term
clearly).
(a) _________ data refers to data that will continue to be stored even when the
applications creating and using the data are no longer running.
static /persistent /updatable
[1 mark]
(b) Databases have many rules, usually known as _____________, that define
the valid data that can be stored in the database.
concerns /restrictions /constraints
[1 mark]
(c) Data is said to be ________________ if it is appropriate for the use to which
it is being put.
accurate /complete/ relevant
[1 mark]
(d) The __________ schema is concerned with data as it is presented to user
processes.
external /storage/ logical
[1 mark]
(e) _____________________ are SQL commands that support transaction
management.
COMMIT/ROLLBACK | INSERT/UPDATE | CREATE/DROP

A

(a) - persistent
(b) - constraints
(c) - relevant
(d) - external
(e) - commit / rollback

90
Q

(a) The E-R diagram is not complete. There are two relationships (CanUse and
WorksIn) whose degree and participation conditions are not given above.
Complete the diagram by representing the degree and participation
conditions given below:
Each employee can use one or many computers.
Each computer can be used by one or many employees.
Each employee works in exactly one office.
Each office has zero, one or more employees who work in it.
[4 marks]
(b) Is the following statement consistent or inconsistent with the given model?
No computer is located in office number 107.
(Circle your answer below)
CONSISTENT INCONSISTENT

A

(b) - Consistent

91
Q

Give a relational representation of the E-R model by defining two relations,
Department and Employee and any additional constraint(s).
You may assume that the domains DepartmentNames, StaffNames,
DepartmentalOffices and StaffNumbers have already been defined and that the
values of the attributes DepartmentName, StaffName, DepartmentalOffice and
StaffNumber are from these domains respectively.

A

Relation Department

DepartmentName: DepartmentNames

DepartmentalOffice: DepartmentalOffice

StaffNumber: StaffNumbers

primary key DepartmentName

{relationship HeadedBy is 1:1}

alternate Key StaffNumber

{mandatory participation of Departmenr in the ConsistOf relationship}

CONSTRAINT((project Deparment OVER DepartmentName) difference (project Employee OVER DepartmentName)) isEmpty

relation Employee

StaffNumber: StaffNumbers

StaffName: StaffNames

DepartmentName: DepartmentNames

primary key StaffNumber

{mandatory participation of Employee in the ConsistOf relantionship}

foreign key (DepartmentName) Reference Department

92
Q

(a) Why does the table not represent a relation?
[1 mark]
(b) Write down the heading of a relation Vet which conveys the same sort of
customer information as the table above. Do not forget to underline the
primary key and include a brief justification of your choice of primary key.
[1 mark]
(c) Write down a relational expression on the relation Vet to find the name and
address of each family which has (at least) one dog registered before
1/1/2000.
[

A

(a)

need a singe value (in First Registered)

(b)

Vet(FamilyName, Address, PetType, PetNames, FirstRegistered)

(c)

project(select Vet where FirstRegistered <‘Jan1, 2000’ and PetType =’dog’) OVER Familyname, Address

93
Q

(a) Match is not in second normal form (2NF). Use a non-loss decomposition to
decompose Match into two relations, both of which are in 2NF. You should
justify why each is in 2NF.
[2 marks]
(b) Define what is meant by a relation being in Boyce-Codd normal form
(BCNF).
[1 mark]
(c) Consider the relation with heading R(a, b, c, d).
The only functional dependencies with irreducible determinants in R are
F1: a→ b F2: a → d F3: c → a
Explain clearly why R is in BCNF.
[

A

(a)

HomeTeam (HomeTeamName, GroundAddress)

Match_2 (HomeTeamName, DATE, AwayTeamName, Result)

Both are 2NF as neither HomeTeamName nor Date determine any other attributes.

(b)

R is BCNF if any only when every one of its dependencies X->Y have at least one of following

  1. X as superkey of R
  2. X-> is a trival FD (FD trival if Y is subset of X)

(c)

In F1 and F2, the determinant is the primary key in F3 the determinant is an alternate key Each irreducible determinant of a non-trival FD is a candidate key and so R is in BCNF.

94
Q

(a)
SELECT SUM(y) as total_y, SUM(b) as total_b
FROM alpha JOIN omega ON x = d
WHERE x = ‘Hull’;
[1 mark]
Question 6
M359 October 2011 TURN OVER 9
(b)
SELECT COUNT(a) as how_many
FROM omega LEFT OUTER JOIN alpha ON b = y;
[2 marks]
(c)
SELECT *
FROM alpha
WHERE x IN (SELECT d
FROM omega
WHERE y = b );

A

(a)

total_y | total_b

400 | 400

(b)

how_many

4

x | y | z

Hull | 200 | granite

95
Q

For each of the following requests, write an SQL query that answers the request.
(a) List the cities where at least one traveller has visited since 2009 and that
visitor has stated nightlife to be its best feature.

A

SELECT city

FROM trip

WHERE year > 2008 AND best_feaure = ‘nightlife’

96
Q

(b) For each city, and each best_feature for that city, count the times the
travellers have rated that as the city’s best feature. When applied to the
trip table your query should return the following data:

(c) For each traveller who has visited London in 2009, report the
traveller_id and number of cities visited by that person in 2010.

A

(b)

SELECT city, best_feature, COUNT(best_feature) AS count_rated

FROM trip

GROUP BY best_feature, city

(c)

SELECT travel_id, COUNT(year) AS number_cities_visited_in_2010

FROM trip

WHERE traveller_id IN (SELECT travel_id FROM trip WHERE city = ‘London’ and year = 2009)

GROUP BY traveller_id, year

HAVING year = 2010

97
Q

(a) (i) Write an SQL view definition called nightlife that when evaluated
will return, for those trips where the reported best feature was
nightlife, the traveller_id, city and year of travel under the
column names who, where, and when, respectively.
[2 marks]
(a) (ii) Is it possible to insert rows into the base table by inserting values into
your nightlife view? Briefly justify your answer.
[2 marks]
(b) Briefly state one purpose of the SQL WITH CHECK OPTION clause.

A

(a) (i)

CREATE VIEW nighlife (who, where, when) AS SELECT traveller_id, city, year FROM trip WHERE best_feature = ‘Nightlife’

(a) (ii)

No, trip states that the collumn best_feature cannot be NULL and this would be the case because in the view nightlife, this collumn is omitted.

(b)

Prevents rows from being inserted into the view which then do not appear in the view itself.

98
Q

The analyst is given a new requirement: to incorporate information about actual
hotels. For each hotel it is important to know: the hotel’s name, the hotel’s email
address, the city it is in, the star-rating, and the Hotel chain it is part of. You are
asked to incorporate this information by decomposing the m:n relationship and
including an additional entity type.
Revise the E-R model fragment above (that is, re-draw the above E-R diagram
and give the additional entity type) so that the amended model fragment is
consistent with the new requirement.
(

A

Hotel(CityName, ChainName, HotelName, EmailAddress, StarRating)

Additional constraints

C.1 Hotel is a weak entity type dependent on City, So, each value of CityName in the entity type Hotel must be the same value as the Name of the City instance to which the Hotel entity type is related by the relationship IsIn ( a consequence of weak-strong entity types)

C.2 Hotel is a weak entity type dependent on HotelChain. So, each value of ChainName in the entity type Hotel must be the same value as the CHainName of the HotelChain instance to which the Hotel entity type is related by the relationship BelongsTo ( a consequence of weak-strong entity types)

Assumptions

a.1. A HotelChain doesn’t have two hotels with the same name in the same city.

99
Q

(a) Explain what is meant by denormalisation. What reason is usually given in
order to justify it?
[2 marks]
(b) List the three types of anomalies that may arise after updating an
unnormalised table.

A

(b) Insertion, Deletion and ammendment

100
Q

(a) What is an enterprise data warehouse? What is a data mart?
[2 marks]
(b) Give three considerations to take into account when building an enterprise
warehouse system.

A

(a)

The Data mart is a collection of information of use to a specific group within an organisation, or information about a specifiv product.

(b)

  • Checking for inconsistencies and inaccurate values
  • Accessibility of the data for example how can it be accessed from different locations
  • removing duplicates
101
Q

Write down headings for relations that are capable of holding the same data as
the patient_records XML structure. You should use two relational headings
and underline their primary keys, to allow the data for the details of several
patients and their treatments to be stored and recreated. Show how the above
data would appear in your relations.
(You can assume that the order of the treatments in the XML tree structure does
not need to be recreated).

A

Patient (id, name, gender)

Treatments ( patient_id, start_date, reason, doctor_id)

Patient

id | name | gender

p68 | Monroe | F

Treatment

patient_id | start_date | reason | doctor_id

p68 | 11/01/09 | pain relief | 110

p68 | 4/3/09 | low temp | 131

102
Q

(a) Complete the following sentences by choosing the most appropriate term
from the list of three given below that sentence (circle or mark the chosen
term clearly).
(i) Unproductive maintenance is a consequence of __________________
between the application processes and the stored data the application
uses.
inaccuracy / data independence / data dependence
[1 mark]
(ii) ____________________________differs from data inside a running
application because it will continue to be stored when the application
terminates.
Normalised data /Persistent data /Duplicated data
[1 mark]
(iii) ____________________________ database systems use a logical
data structure in which all data appears in a tabular form, and can be
manipulated by mathematical operations that produce results that are
also in tabular form.
Object-oriented /Relational/ Network
[1 mark]
(b) Briefly state the purpose of the Data Analysis stage in the waterfall model of
database development.
[

A

(a)

(i) - data independence
(ii) - persistent data
(iii) - relational

(b)

103
Q

Draw an entity-relationship (E-R) diagram and give the entity types described by
the following:
Each Teacher can teach on zero, one or many Courses.
Each Course is taught by exactly one Teacher.
Each Course is identified by its subject name and reference number so that, for
example, (Geography, R13) , (Geography, R11) and (History, R11) are different
courses. We are also interested in the course duration and cost. Each teacher has
a unique employee number and we are interested in the teacher’s appointment
date, and the highest qualification they hold.
Entity-relationship diagram
Entity types

A

Entity-relationship diagram

Teacher(EmployeeNo, apptDate, HighestQual)

Cources( Name, ReferenceNi, Durration, Cost)

104
Q

Entity-relationship diagram

Entity types

A

Entity types

A(x1, x2)

B(x3, x4)

C(x5, x6)

105
Q

(a) the names of all the customers living in Manchester.
[1 mark]
(b) those towns where there are customers but no shops.
[1 mark]
(c) the codes and names of those customers who live in the same town as one
or more shops.

A

(a)

project(SELECT Customer WHERE Town = ‘Manchester’) OVER CustomerName

(b)

(project Customer over Town)difference (project shop over town)

(c)

project ShopCustomer allias ((project Shop over Town) join (project Customer over CustomerCode, customerName, town)) over customerCode, customerName

106
Q

(a) (Patient, Clinic) is the only candidate key of R.
[3 marks]
(b) R is in second normal form (2NF).

A

(a)

Patient has no unique tuple, neither do clinic or doctor or (patient, doctor) or (clinic, doctor) therefore teh candidate key for R is (patient, clinic)

(b)

As we have identified patient, clinic is the only candidate key, it must be the primary key. As the doctor is fully functionaly dependent on the primary key the relation is in 2NF

107
Q

For each of the following SQL queries, give the table that the query returns.
(a)
SELECT *
FROM camera
WHERE price > 380
[1 mark]
(b)
SELECT order_id, customer_id, price
FROM order, lens
WHERE lens_code = code
AND camera_code IN (‘A50’, ‘P200’)
[2 marks]
(c)
SELECT order_id, customer_id, price
FROM order LEFT OUTER JOIN lens
ON lens_code = code
WHERE camera_code IN (‘A50’, ‘P200’)

A

(a)

code | level | price

A50 | am | 400

P200 | prof | 1200

(b)

order_id | customer_id | price

18 | c32 | 800

(c)

order_id | customer_id | price

18 | c32 | 800

27 | c91 | NULL

32 | c91 | NULL

108
Q

(a) Give SQL queries that can be used to answer the following requests.
(i) How many cameras with the code A30 have been ordered?
[1 mark]
(ii) Give the identifier of every customer who has ordered at least one
camera without a lens.
[2 marks]
(b) Rewrite the following query so that it uses a subquery in the FROM clause,
instead of a HAVING clause.
SELECT camera_code, COUNT(*) AS num
FROM order
GROUP BY camera_code
HAVING COUNT(*) >= 2
[

A

(a) (i)

SELECT COUNT(*) AS num_a30_ordered

FROM order

WHERE camera_code = ‘a30’

(ii)

SELECT DISTINCT Customer_id

FROM order

WHERE lens_code IS NULL

(b)

SELECT DISTINCT camera_code

FROM (SELECT camera_code, COUNT(*)AS num FROM order) AS t

WHERE t.num >1

109
Q

(a) Why does the following statement not change the contents of t?
INSERT INTO v2
VALUES (‘o’, 4, ‘ban’)
[1 mark]
(b) What effect does executing the following statement have on table t and view
v1? If executing the statement does not cause any changes, explain why not.
UPDATE v1
SET c = 4
WHERE a = ‘j’
[2 marks]
(c) What effect does executing the following statement have on table t and view
v2? If executing the statement does not cause any changes, explain why not.
UPDATE v2
SET c = 1
WHERE b = ‘n’

A

(a)

Because there is no collumn and hence value for the primary key of t interview v2

(b)

T will be updated with new value but v1 will not display it because of its criteria c<3

(c)

neither t or v2 will update, v2 says c>1 and it’s using the WITH CHECK OPTION which will inhibit the base table and view being updated if criteria are not met.

110
Q

(a) After a review it is decided to change the conceptual model to capture the
following requirement:
Each actor may act in a number of different series, and for each one he or
she has a contract with a start date and end date. An actor can only have one
contract for any particular series.
Modify the model above to reflect the revised requirement. (You need only
show those parts of the model changed or added.)
[3 marks]
(b) Identify the weak entity type(s) in the complete revised model, and state their
dependencies.

A

(a) Contract(StageName, SeriesTitle, startDate, endDate)
(b) Episod and Series are both weak entitty types.

111
Q

(a) Operational maintenance ensures that a database continues to satisfy the
informational requirements of an enterprise after it has been installed. What
are the two processes involved in operational maintenance?
[2 marks]
(b) Give three reasons why it may be necessary to restructure a database after it
has been installed and accepted by the client.

A

(a)

database restructuring

database reorganisation

(b)

  • to ensure that it meets with the customer’s orginal requirements ( correct any errors from the design phase)
  • to incorporate any new changes in requirements
  • to optimise retrival performance
112
Q

(a) In a data warehousing system, why is data cleaning (also known as
cleansing or scrubbing) necessary before data from a source can be entered
into the warehouse database?
[2 marks]
(b) Data extracted from a database may be expected to require less cleaning
than data held in a file-based system. Explain why.
[1 mark]
(c) What are the two steps generally necessary to carry out data cleaning?

A

(a)

to remove any errors or inconsistencies in the data

(b)

because database is managed by scheme and constraints controlling data integrity, whereas file based dataisn’t

(c)

data analysis and definition of rules for how it will be cleaned (because of dependencies)

113
Q

Write down headings for relations that are capable of holding the same data as
the patient_records XML structure. You should use two relational headings
and underline their primary keys, to allow the data for the details of several
patients and their treatments to be stored and recreated. Show how the above
data would appear in your relations.
(You can assume that the order of the treatments in the XML tree structure does
not need to be recreated).

A

patient (id, name, gender)

Treatment(Id, StartDate, Reason, Doctor_id)

Patient

ID | Name | Gender

p68 | Monroe | F

Treatment

ID | StartData | Reason | Doctor_id

p68 | 11/11/2009 | pain relief | 110

p68 | 9/3/2009 | low temp | 131