Sei sulla pagina 1di 9

APPROVED

EXAMINATION PAPER: ACADEMIC SESSION 2010/2011

Campus Maritime Greenwich

School Computing and Mathematical Sciences

Department Information System & Multimedia

Level Three

TITLE OF PAPER Database Design & Implementation

COURSE CODE COMP1302

Date and Time Monday 29th November 2010 (2 hours)

BAHRAIN 15:00 BOTSWANA 14:00


GREECE 15:00 GHANA 13.00
HONG KONG 18:30 KENYA 15:00
LONDON 13:00 MALAYSIA 18:30
MALTA 14:00 MALAWI 14:00
MAURITIUS 16:00 MYANMAR 16:30
RWANDA 14:00 SAUDI ARABIA 15:00
SINGAPORE 17:30 SRI LANKA 17:30
SOUTH AFRICA 14:00 SYRIA 15:00
TANZANIA 15:00 TRINIDAD 09:30
VIETNAM 18:30 ZAMBIA 14:00
BANGLADESH 18:30

You MUST answer question 1 which is worth 40 marks.

Answer TWO questions from the remaining THREE questions, questions 2 to 4 which are
worth 30 marks each. If you answer all THREE questions from questions 2 to 4, marks will
ONLY be awarded for your TWO best answers.

CALCULATORS AND OTHER ELECTRONIC DEVICES ARE NOT PERMITTED


APPROVED

Section A – (Compulsory)

1. (a) Compare inheritance in the Enhanced Entity Relationship model to inheritance


in the Object Oriented model.
[8 marks]

(b) Database Views and Data Marts are alike in that they both have read-only
extracts from databases. However, Data Marts and Views are different in many
ways. Identify at least four of these differences.
[8 marks]

(c) Consider the diagram in Figure 1 below which shows occurrences of the
scenario of “Nurses assist Surgeons on certain operations for particular
Patients”.
Nurse N Operation O Patient P Surgeon S
S1
P1
Operated-on
N1 Performs S2
Assists

N2 S3
O1
P2

N3 S4
O2
P3
N4 S5
O3
P4

O4 S6

O5

Figure 1

(i) State the number of occurrences of the “Assists” relationship.


[1 mark]

(ii) From the given occurrences diagram, identify the degree of the
“Operated-on” relationship.
[1 mark]

(iii) From the given occurrences diagram, determine the cardinality of the
“Performs” relationship.
[2 marks]

(iv) Which patients have more than one operation?


[2 marks]

(v) Assume that a Surgeon can perform only one type of operation, which
patients have the same type of operation and by which surgeon?
[2 marks]

COMP1302 – Database Design & Implementation


Page 2 of 9
APPROVED

(d) The relational structure in Figure 2 below captures a snapshot of the EMP
database table of a small company.

EMP
EMPNO EMPFNAME EMPSALARY DEPTNAME BOSSNO
1 Ali £75,000.00 Management
2 Ole £45,000.00 Sales 1
3 Joi £25,000.00 Sales 2
4 Clare £22,000.00 Marketing 2
5 Mohammed £38,000.00 Accounting 1
6 Khan £22,000.00 Accounting 5
7 Choi £43,000.00 Marketing 1
8 Sarah £56,000.00 Purchasing 7
9 Sophie £35,000.00 Personnel & PR 1
10 Sami £46,000.00 Purchasing 2

Figure 2— A snapshot of the EMP database table for a small company

(i) Provide the output when the Structured Query Language (SQL) code
below is run against the database snapshot.
[4 marks]
SELECT WRK.DEPTNAME, COUNT(*) AS EmpCount
FROM EMP WRK, EMP BOSS
WHERE WRK.BOSSNO = BOSS.EMPNO AND
WRK.EMPSALARY >= BOSS.EMPSALARY
GROUP BY WRK.DEPTNAME;

(ii) Express the following request in SQL.

For all managers who manage more than one employee, list the
manager employee number and his/her first name and the total
number of employees he/she coordinates.
[4 marks]

COMP1302 – Database Design & Implementation


Page 3 of 9
APPROVED

(e) Only FOUR of the following statements are true. Write down the numbers of
the FOUR statements you believe to be TRUE. Only the FOUR first answers
will count.

DO NOT COPY ANY of the statements to your answer book. [8 marks]

(i) Embedded SQL is used in a Programming Language as the ideal solution


to solve the limitation of the relational system.

(ii) The process of Aggregation in object-oriented modelling is concerned


with the identification of objects with similar properties and behaviour
and group such objects into classes.

(iii) Concurrent transactions executing in serialized mode can only make


database changes that they could have made if the transactions ran one
after the other.

(iv) The SQL statement


“SELECT Position, SUM(salary) AS Total_Salaries FROM staff”
computes the total salaries for each position available in the table Staff(
StafNo, Fname, Lname, Addres, Position, Salary, DOB, BrchNo); The
statement produces the correct results?

(v) To maintain referential integrity across relational tables Null is only


allowed when the participation relationship is partial.

(vi) In a SQL statement, if more than one relation is specified in the FROM-
clause and there is no join condition, then the output will be restricted to
the tuples of the first table listed in the FROM-clause.

(vii) Executing the same program several times in one transaction relates to
the integrity property of a transaction.

(viii) Relational algebra is a set-oriented language in which all tuples, possibly


from different relations, are manipulated in one statement without
looping.

(ix) In the Discretionary Access Control authorisation approach, when a


relation is assigned to an owner account the owner has all access
privileges on the relation including passing control to other users.

(x) The selective replication approach is a data allocation strategy used in


distributed DB design. It is based on maintaining a complete copy of
database at each site.

COMP1302 – Database Design & Implementation


Page 4 of 9
APPROVED

Section B – (Answer any TWO questions)

2. The relational structure in Figure 3 below captures a snapshot of the database tables
of a small company that specialises in the sale of house furniture. The company’s
main customers are landlords of properties all over Scotland. Landlords rent
properties of various types. A landlord (i.e. a customer for the company) may place
many orders. Each order may contain many items (i.e. order lines). Items are ordered
from various suppliers but for simplicity, assume supplier name is unique. Each
order line is for a specific piece of furniture in various quantities. A company
employee is responsible for many orders and can supervise many employees. Most
employees share an open-plan office but only a few are allocated a single-room
office. Single room occupancy is recorded in the database.
The table relationships diagram for this DB schema is presented below in Figure 4 on
the following page. The primary key for each table is underlined.

EMPLOYEES ORDERITEMS
EmpNo FirstName LastName DateOfBirth DateEmployed SupervisorNo OrderNo ItemNo Quantity
1 Manny Tomanny 12-Apr-1956 01-May-1989 6 1 1 1
2 Rosanne Kolumns 21-Mar-1967 01-Jan-1990 6 1 4 1
3 Cas Kade 01-May-1967 01-Apr-1992 5
2 3 1
4 Norma Lyzation 03-Apr-1956 01-Apr-1992 5
3 3 4
5 Juan Tomani 12-Apr-1956 01-Apr-1992 6
6 Del Eats 01-May-1957 01-May-1994 3 4 1
4 1 1
CUSTOMERS ROOMS 4 2 1
CustomerNo Title FirstName LastName Town RoomNo EmployeeNo
4 3 1
1 Mr. Brian Thompson Edinburgh 1 2
5 2 1
2 Miss Sally Henderson Dundee 9 3
5 3 1
3 Mr. Harry McColgan Glasgow 23 1
4 Miss Sandra Wellington Perth 6 2 1
5 Mr. Joseph Whyte Edinburgh 6 4 1
6 Ms. Norah Cooper Glasgow 7 1 1
7 Ms. Helen Lynch Dundee
8 Mrs. Grace Falconer Aberdeen
9 Mrs. Mary Robb Dundee
10 Mr. George Pedersen Perth

ORDERS ITEMS
OrderNo CustNo EmpNo ItemNo Supplier Price Item
1 2 1 1 Harrison £235.00 Desk
2 1 4 2 Ford £350.00 Lamp
3 3 1 3 Ford £234.00 Chair
4 4 2 4 Harrison £415.00 Table
5 2 3 5 Simon £499.00 Sofa
6 4 2
7 2 2

Figure 3 —A snapshot of the database tables for the furniture database


(not all the data are displayed)

COMP1302 – Database Design & Implementation


Page 5 of 9
APPROVED

Figure 4— A relationship diagram for part of the furniture Database

(a) A set of applications has been planned against the database. You have been
asked to express the following queries in SQL (Structured Query Language).

(i) The company decided to decrease the price of all items currently not on
orders by 5%. Modify the DB to reflect this change.
[5 marks]

(ii) For all the orders placed by Miss Sally Henderson, give the order number
as well as the total value of each order.
[5 marks]

(iii) List the employee full name (first and last names) of all those employees
who share an open-plan office.

[5 marks]

COMP1302 – Database Design & Implementation


Page 6 of 9
APPROVED

(b) Another set of applications has been already coded in SQL. For each of the
given SQL code statements below produce the output using the data from the
above tables. Present your answer in a table format using column headers as
they appear in the query. Ignore any data modification that might have resulted
from executing the SQL statements that you have produced in section (a)
above.

(i) SELECT E.EmpNo, E.FirstName, E.LastName, Count(O.OrderNo) AS


TotOrders
FROM Employees AS E, Orders AS O
WHERE E.EmpNo=O.EmpNo
GROUP BY E.EmpNo, E.FirstName, E.LastName
HAVING Count(O.OrderNo) > 2;
[3 marks]

(ii) SELECT E.EmpNo, E.FirstName, E.LastName


FROM Employees AS E
WHERE E.DateOfBirth =
(SELECT Max(DateOfBirth) FROM Employees);
[3 marks]

(iii) SELECT Mngr.[FirstName]+" "+Mngr.[LastName] AS FullName


FROM Employees AS Worker, Employees AS Mngr
WHERE Mngr.Empno= Worker.SupervisorNo
ANDWorker.FirstName='Manny' AND
Worker.LastName='Tomanny';
[3 marks]

(iv) SELECT Count(*) AS NumberOfCustomers


FROM Customers
WHERE (Town='Edinburgh' Or Town='Glasgow') AND CustomerNo IN
(Select Distinct CustNo From Orders);
[3 marks]

(v) SELECT DISTINCT C.FirstName, C.LastName


FROM Customers AS C, Orders AS o, orderitems AS oi, items AS i
WHERE i.itemNo=oi.itemNo AND oi.orderNo=o.orderNo AND
o.CustNo= c.CustomerNo AND i.item ='Lamp' AND
c.town='Dundee';
[3 marks]

COMP1302 – Database Design & Implementation


Page 7 of 9
APPROVED

3. A student DB is used to record students’ grades in various subjects. The student has
to pass 5 modules in order to progress to the second semester of the year. Each
module consists of two equal assessment components, one exam and one coursework
(50%:50%). For simplicity, we are only concerned with the overall mark of the
module rather than its two components. The following grades were recorded for
Student S1: G1=70, G2: 70%, G3: 90%, G4: 80% and G5=60.

The student profile needs to be updated before a decision can be made. It was noticed
that the G3 coursework for S1 was submitted late and hence the overall mark should
be capped to 40%.

Moreover, it seems that student S1 was also reported for possible plagiarism in the
same late submitted coursework mentioned above (G3 cswk). The case was proved
later and the mark for G3 should be reduced to 0%.

The student affairs office compiles all requests for updating marks for all students and
runs them in a batch process to update all marks for all students just before producing
the final examination report that shows all students profile (i.e. student grades for all
subjects).

Three transactions (Xat) are executing concurrently. Xat1 and Xat2 are to update the
record profile of student S1 as submitted in the two above requests. Xat1 is to cap the
mark to 40%. Xat2 is to update the mark by assigning ZERO due to plagiarism. Xat3
is to find the average of all modules for all students, but for simplicity the table below
shows the calculation for student S1 only.

The following sequence of operations takes place (the initial values for S1 Grades in
all modules are as specified at the end of the first paragraph above). S1G3 holds the
coursework mark for G3 for student S1.

Time Ti Xat1: Xat2: Xat3:

T1 Begin transaction
T2 Sum S1=0
T3 Read (S1G1)
T4 Sum S1= Sum S1+ S1G1
T5 Read (S1G2)
T6 Sum S1= Sum S1+ S1G2
T7 Begin transaction Read (S1G3)
T8 Read (S1G3) Begin transaction Sum S1= Sum S1+ S1G3
T9 S1G3=40% Read (S1G3) Read (S1G4)
T10 Write(S1G3) S1G3=0% Sum S1= Sum S1+ S1G4
T11 Commit Write(S1G3) Read (S1G5)
T12 Commit Sum S1= Sum S1+S1G5
. Avg S1= Sum S1/5
. Write Average S1
‫׃‬
Sum S2=0
Read (S2G1)
Sum S2= Sum S2+ S2G1
Read (S2G2)
‫׃‬
Commit

COMP1302 – Database Design & Implementation


Page 8 of 9
APPROVED

(a) What are the final values in S1G3, Sum S1 and Avg S1 after the above
interleaved sequence of operations for transactions Xat1, Xat2 and Xat3 are
executed?
Comment on your results and identify any problems if any. Assume no
interruption to the schedule until completion (i.e. no hardware or software
failure).
[10 marks]

(b) If Xat1 starts at T11 and finishes at T15, Xat2 starts at T7 and finishes at T11, Xat3
starts at T1 as originally executed and shown in the above schedule, what are the
final values in S1G3, Sum S1 and Avg S1?
What is the main difference between this and the previous schedule in (i) above?
Are the previously encountered problems (if any identified) resolved in this
schedule? Comment on your results and identify any problems if any.
[10 marks]

(c) Discuss how you can avoid any of the encountered problems identified in (i) and
(ii) and identify any mechanisms or techniques to resolve the problems. Based
on the given initial schedule given above, show how your proposed solution can
be used to produce a correct schedule. What will be the final values in S1G3 and
Avg S1 after executing your proposed schedule?
[10 marks]

4. (a) “Object Databases are just about dealing with new data types”. Express your
view on the above comment and justify your agreement or disagreement with
it. Give examples whenever possible.
[10 marks]

(b) There are several strategies defined during the logical database design process
for maintaining referential integrity in relational databases. A strategy for
deleting or updating a tuple is defined at the time when the table is created.
Referencing SQL-92 (i.e. SQL II) standard, list these strategies and briefly
explain each strategy.
[10 marks]

(c) How can the primary key and foreign key constraints be enforced by a
Database Management System (DBMS)? Is the enforcement technique you
suggest difficult to implement? Can the constraint checks be executed in an
efficient manner when updates are applied to the database?
[10 marks]

COMP1302 – Database Design & Implementation


Page 9 of 9

Potrebbero piacerti anche