Database Design and Implementation Exam June 2006 - UK University BSC Final Year
Database Design and Implementation Exam June 2006 - UK University BSC Final Year
Level Three
(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. [5 marks]
(b) Consider the diagram in Figure 1 below which shows occurrences of the
Sailing relationship: A Captain can only sail a specific Ship(s) with particular
Crew Members.
C1
M1 Sails S2
Boards
M2 SR1 Assigned To S3
C2
M3 S4
SR2
M4 C3 S5
SR3
SR4 S6
C4
SR5
Sailing
Figure 1
(iii) Identify the ships that can be sailed by more than one captain. [1 mark]
(iv) Identify all captains who can sail more than one ship. [1 mark]
(v) Identify the captain that travels with most crew members. [1 mark]
(c) For the occurrence diagram in Figure 1 above, produce the Entity
Relationship Diagram. Identify the cardinalities and the participation
constraints for all relationships. Do not include any attributes on your
diagram. [5 marks]
(d) The relational structure in Figure 2 below captures a snapshot of the Course
database table of the external collaboration office at the School of Computing
& Mathematical Sciences of UoG. A course is coordinated by one or more staff
members and moderated by one staff member. A staff member can coordinate
or moderate more than one course.
tblCourse
CourseID CourseTitle SDate FDate Coordinator Dept Credit Moderator OfficeNo
COMP1108 Project (Computing) June 98 mp02 CS 30 cp08 QM333
COMP1302 Database Design & Implementation June 03 aa01 IS&MD 15 cp08 QM236
COMP1303 Distributed Information Systems June 98 ar26 CS 15 mk05 QM310
COMP1304 Information Systems Engineering June 03 cp08 IS&MD 15 mk05 QM365
COMP1305 IT Project and Quality Management June 03 sr65 IS&MD 15 dm65 QM366
COMP1306 Mobile Computing June 03 sp02 CS 15 ar26 QM423
COMP1307 Object-Oriented SW Development June 03 wg05 CS 15 mk05 QM364
COMP1308 eCommerce June 03 dm65 IS&MD 15 sr65 QM333
COMP1309 Web Engineering June 03 mk05 CS 15 ar26 QM413
Figure 2—A snapshot of the Course database table for the External Collaboration Office
(i) Provide the output when the Structured Query Language (SQL) code
below is run against the database snapshot. [3 marks]
SELECT Coordinator
FROM tblCourse
WHERE Coordinator IN
(SELECT Moderator FROM tblCourse
GROUP BY moderator HAVING Count(*)>2);
For each department in the course table, list the name of the department,
the number of coordinators and the number of moderators.
(ii) In SQL, the aggregate function COUNT(*) counts all rows of a table,
discarding any nulls or duplicate values.
(iii) In SQL, the SELECT clause may not contain constants in its list.
(iv) A fan trap suggests the existence of a relationship between entity types,
but the pathway between certain entity occurrences does not exist.
(v) Relational algebra operations consist of two types. These are Basic and
Derived set operations. The Join operation is one of the traditional set
operations.
(vi) The clustering attribute is not sequentially ordered in the index file.
(vii) Insertion and Deletion of a key value in a B-tree must not violate the
condition of M/2 -1 ≤ K ≤ M-1 where K is the number of Keys per
node and M is the order of the tree.
(viii) If transaction had not committed at failure time, Recovery Manager has
to rollback any effects of that transaction for atomicity.
(ix) In the out-of-place recovery technique, a shadow page refers to the newly
created page rather than the original data page.
tblAccount tblCustAcc
Refno Accno
Accno Balance Type BranchName
120768 £234.56 D Greenwich 2345 120768
348973 £12,567.56 C Crawley 2345 348973
678453 -£456.78 C Crawley 3456 876543
745363 -£23.67 D Greenwich 4567 987653
876543 -£1,770.00 C Greenwich 7654 987654
987653 -£966.00 C Bugstone 8764 348973
987654 £789.65 C Bugstone 8764 678453
8764 745363
tblCustomer
Refno Name Address Status
2345 P Abdul 23, High Street Business tblBranch
3456 A Ali 35, Kings Hill Domestic BranchName Address Manager_No
4567 B Brass 12, Avery Hill Business Bugstone 12 Low Street 9823
7654 K Smith 45, The Ash Domestic Crawley 1 High Street 1768
8764 P Jones 17, Low Street Business Greenwich 30 Park Row 8530
9999 Y Omotayo 18, Greenwich Park Domestic Avery Hill 12 Falconwood Rd 8503
(i) Mr. P Jones was in Greenwich and he withdrew £200.00 in cash from his
sole account there. Reflect this in the DB. Mr. P Jones has an overdraft
agreement with his Greenwich branch manager of £500.00 (i.e. he can
withdraw money provided that his balance remains within the overdraft
allowance).
[5 marks]
(ii) Give the sum of all balances for accounts held by the customer P Abdul.
[5 marks]
(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.
[3 marks each]
(i) SELECT count(c.refno) AS DemAcc
FROM tblCustomer AS c, tblCustAcc AS ca
WHERE c.status='Domestic' And c.refno=ca.refno;
3. (a) There are several strategies defined during the logical database design process
for maintaining referential integrity in a relational databases. List four of these
strategies and briefly explain each strategy. [12 marks]
(b) The Short Course Institute (SCI) offers training courses on various IT subjects.
The diagram below is part of a conceptual schema of the SCI database. It states
that a course may be offered any number of times. Each course presentation
(i.e. Offering) commences on a given start date at a given location. Employees
of the institution can be authorized as lecturers or originators. In special
circumstances when there is no lecturer available to deliver a particular course,
the designer of the course, i.e. the originator, will be asked to deliver a run of
that course. The unique identifier for each entity is underlined.
(i) Explain why the Entity Relationship Schema below is incorrect for this
application. [3 marks]
(ii) Correct and redraw the Entity Relationship diagram for the schema
shown below in Figure 5 below according to the Extended Entity
Relationship model. Show the same attributes in your answer that are in
the original diagram (i.e. do not add more attributes). [5 marks]
CourseID
Lecturer 1 N Offering
Presents
Figure 5
(c) Consider the following schema: Offerings (Course, Semester) and Enrolment
(StudId,Course,Semester). The SQL code below represents a trigger.
CREATE TRIGGER WatchEnrollment
AFTER DELETE, INSERT, UPDATE ON Transcript
FOR EACH STATEMENT
DELETE FROM Offerings
WHERE EXISTS
( SELECT E.Course, E.Semester FROM Enrolment E
WHERE E.Course = Course AND E.Semester = Semester
GROUP BY E.Course, E.Semester HAVING count(E.StudId) < 10 );
(i) SQL triggers are classified by their levels; identify the level of the
above trigger and how many times the code is executed when the
event occurs? [2 marks]
(ii) Briefly explain the purpose of the above trigger and how it works.
[3 marks]
T0 Tc Tf
Xat1
Xat2
Xat3
Xat4
Figure 6
For each transaction, determine what action (undo or redo) is required, if any,
to recover the database to a valid state. Explain your decision.
[8 marks]
(i) For each schedule give the final balance of the CCA. [6 marks]
(c) Consider a relation stored as a randomly ordered file for which the only index
is an un-clustered index on a field called Salary. If you want to retrieve all
records with Salary > £25000, is using the index always the best alternative?
Explain your answer.
[5 marks]
5. (a) The two relations below represent a portion of a distributed relational schema
for a library system. The primary keys are underlined.
Assume that staff at the Bexley branch want to find which of the other
branches stock copies of a book with a given ISBN.
There many query plans exist to execute the above query. For simplicity
consider the two query plans below:
Query plan 1:
• Transmit the Copy fragments from the other 49 branches to Bexley.
• Search each fragment for a row with the given ISBN (on average
500 rows need to be searched for each fragment).
• For each fragment with a matching row, use branchNo to find the
name and address of the branch from the Branch replica at Bexley.
Query plan 2:
• Transmit the ISBN to each of the other 49 branches.
• At each branch use the index on the Copy fragment to find whether
there is a copy at that branch; if so transmit the branchNo back to
Bexley.
• Use the branchNo to find the name and address of the branch from
the Branch replica at Bexley.
(i) List and briefly discuss the most important factors that you need to
consider in distributed query optimization. [9 marks]
(ii) Study the two query plans above and pick the one that you think is
more efficient for the given scenario, and justify your answer.
[6 marks]
(b) How Object Oriented DBMSs and Object Relational DBMSs are compared in
terms of data modelling? Present your answer in a table.
[10 marks]
Your task is preparing a report addressing the above statement. Your discussion
should give a high-level overview of how to use XML with databases, the factors
that influence your choice between using XML-enabled database or native XML
databases. You may want to give examples to support your arguments from either the
above application or any other suitable applications.
[25 Marks]