B.Sc. Undergraduate Programmes in Mathematical Studies

Total Page:16

File Type:pdf, Size:1020Kb

B.Sc. Undergraduate Programmes in Mathematical Studies

CS/263/1/AS06

UNIVERSITY OF SURREY©

B.Sc. Undergraduate Programmes in Computing

B.Sc. Undergraduate Programmes in Mathematical Studies

Level HE2 Examination

CS263 Information Modelling

Time allowed - 1 Hour 30 minutes Autumn Semester 2006

Attempt TWO questions. Calculators are NOT permitted

CS/263/2/AS06

1 1. Consider the following schema for a TrainCompany database (primary key attributes are underlined)

TRAINS(trainNum, sourceCity, destinationCity) DEPARTURES(trainNum, date, trainType) PASSENGERS(passengerID, passengerName, passengerAddress) BOOKINGS(passengerID, trainNum, date, seatNumber)

Express the following queries in SQL: a) Find the cities that have direct (non-stop) trains to both London and Paris. [10 marks] b) Find the passengerID of all passengers who have a seat booked on a train of type “diesel” from Manchester to London (do not return any duplicate values). [10 marks] c) Find the passengerName of all the passengers who have a seat booked on at least one train of every type [14 marks] d) Output an ordered list of all source cities and the number of distinct destination cities that they have direct (i.e. non-stop) trains to. The list should be ordered in decreasing number of destinations and should contain only those source cities that have trains to 10 or more distinct destinations. The output should look something like: sourceCity numDestinations

London 25 Paris 18 Manchester 10 … etc. [16 marks]

CS/263/3/AS06

2 2. An employment agency supplies softwaredevelopment staff to other companies. A database is required that keeps a record of the staff ID number (empID), the contract number (contractNum), the days they worked on a given contract (days), their name (empName), the given company they worked for (recorded by companyName) and location of the company (City) in the following table (which is already in 1NF):

EmpID contractNum days empName companyN City ame 1135 C1024 16 Smith J SuperSoft London 1057 C1024 24 Bloggs F SuperSoft London 1068 C1025 28 White T BuggySoft Seattle 1135 C1025 15 Smith J BuggySoft Seattle

Make the following assumptions:  Each company may have more than one contract.  A staff member may work on multiple contracts in a certain period.  A staff member may work for multiple companies in a certain period.  The primary key for the above-mentioned relation is the composite key comprising (empID, contractNum).

a) Identify the dependencies in the above data that are preventing it being in 2NF, and describe and illustrate the process of normalization of the data in the above table to 2NF. Write down the 2NF solution, indicating any primary keys by an underline and any foreign keys by a dashed underline.

[30 marks] b) Using you answer to part a), identify any transitive dependencies in the data, and write down the 3NF solution, indicating any primary keys by an underline and any foreign keys by a dashed underline. [20 marks]

CS/263/4/AS06

3. You have been asked to create an Entity-Relationship diagram for an orchestra. The following things need to be considered: 3 Concert season. This is the season during which a series of concerts will be performed. It has an opening date (Day, Month, and Year).

Concert. A concert is a performance of one or more compositions. It is identified by the concert number. Concerts have a concert date (Time, Day, Month, and Year). Each concert typically has more than one concert date.

Composition. These are musical compositions to be performed at each concert. They have an ID number, consisting of the following: Composer name and Composition name.

Conductor. This is the person who will conduct the concert. They have an ID number and name.

Soloist. This is a solo musician who performs a given composition at a particular concert. They have an ID number and name.

Assume the following:

A concert season schedules one or more concerts. A particular concert is scheduled for only one concert season.

A concert involves the performance of one or more compositions. A particular composition may be performed at one or more concerts, or may not be performed.

For each concert there is one conductor. A conductor may conduct any number of concerts, or may not conduct any concerts.

Each composition may require one or more soloists, or may not require a soloist. A soloist may perform one or more compositions at a given concert, or may not perform any composition.

a) Using the ‘Crow’s Foot’ notation, create a simple Entity Relationship diagram that captures the information above without taking note of any ‘fan trap’ issues. Make sure you identify the entities, relationships, attributes, primary keys and cardinality constraints in the diagram. State any assumptions you make. [30 marks]

b) Write down the pairs of entities in your simple diagram that are susceptible to the ‘fan trap’ problem [3 marks] c) Write down how you can solve the ‘fan trap’ problem on your diagram [3 marks]

d) Draw a modified ER diagram that avoids the ‘fan trap’ problem [14 marks]

CS/263/5/AS06

4. a) Briefly describe three disadvantages of legacy file server systems.

4 [9 marks] b) Briefly describe three advantages of database servers. [9 marks] c) Briefly describe two disadvantages of database servers. [6 marks] d)Briefly describe four advantages of three-tier architectures [12 marks] e) What is ‘middleware’? Explain this term and briefly describe one type of middleware. [14 marks]

END OF PAPER

INTERNAL EXAMINER: DR ANTONY BROWNE/DR WILLIAM MITCHELL EXTERNAL EXAMINER: PROFESSOR PHIL PICTON

5 SAMPLE ANSWERS

Question 1. a) SELECT DISTINCT sourceCity FROM Trains F WHERE F.destinationCity = “London” AND F.sourceCity IN (SELECT sourceCity FROM Trains F2 WHERE destinationCity = “Paris”) (can also be done in other ways, such as with self join on trains. Credit will be given for other appropriate solutions) [10 marks] b) SELECT DISTINCT B.passengerID FROM Trains F, Departures D, Bookings B WHERE B.trainNum = D.trainNum AND B.date = D.date AND F,trainNum = D.trainNum AND F.sourceCity = “Manchester” AND F.destinationCity = “London” AND D.trainType = “diesel” (as key of DEPARTURES is composite of trainNum and date, need both to do the join) [10 marks] c) SELECT DISTINCT passengerName FROM Passengers P WHERE (SELECT COUNT(DISTINCT D.trainType) FROM Departures D, Bookings B WHERE D.trainNum = B.trainNum AND D.date = B.date AND B.passengerID = P.passengerID = (SELECT COUNT(DISTINCT D.trainType) FROM Departures D)

(there are other acceptable solutions to this problem) [14 marks]

d)

6 SELECT sourceCity COUNT(DISTINCT destinationCity) as numDestinations FROM Trains F GROUP BY sourceCity HAVING numDestinations >= 10 ORDER BY numDestinations DESC

(other acceptable solutions exist) [16 marks]

Question 2 a) Candidates should identify the following dependencies: FD1 empID, contractNum Days (Primary key) FD2 empID  empName (Partial dependency) FD3 contractNum  companyName, City (Partial dependency) Candidates should transform the relation into 2NF by the creation of new relations so that the non-primary-key attributes are removed along with a copy of the part of the primary key on which they are fully functionally dependent. An example of this results in the creation of three new relations called Staff, Hour, and ContractCompany (there are other acceptable solutions to the problem, and credit will be given for these) Staff (empID, empName) Hour (empID, contractNum, days) ContractCompany (contractNum, companyName, City)

Candidates should then identify that City is transitively dependent on companyName: FD4 companyName  City (Transitive dependency)

To transform into third normal form, we must first remove this dependency should be removed by creating two new relations (such as Contract and Company, but other valid solutions exist and will be given credit) Contract (contractNum, companyName) Company (companyName, City)

7 Question 3.

a) Candidates should draw an ER diagram using the ‘crow’s foot’ notation that does not take into account problems caused by ‘many-to-many’ relations, correctly identifying entities, primary keys, relations, attributes and cardinality constraints. Some flexibility is allowed depending on reasonable assumptions made by the candidates during their analysis. Marks will be apportioned in the following manner:  Entities correctly identified – 5 marks  Attributes correctly identified (including multivolume attributes for dates) – 5 marks  Primary keys correctly identified – 8 marks  Relationships and cardinality correctly identified – 12 marks b) Candidates should identify the ‘fan trap’ problem between the entities: soloist and concert; soloist and composition; concert and composition. 3 marks c) Candidates should create 3 new associative entities between these entities, such as: soloist_has_concert, soloist_has_composition, and composition_has_concert.

3 marks d) Candidates should redraw the ER diagram inserting these associative entities, adding appropriate relation names and setting the appropriate cardinality for the relations. 14 marks A sample complete ER diagram follows, but other solutions are acceptable:

8 Question 4. 9 a) Candidates should briefly discuss the three limitations of legacy file servers, possibly including (but not exclusively)

Create a heavy network load – sever does little work, client busy with extensive data manipulation, network transferring large blocks of data

Require full version of DBMS on each client – uses lots of resources, each client must be powerful to provide adequate response time.

Require complex programming to manage shared database integrity – each application program must recognise locks and use them properly. Other complex programming required to deal with concurrency, recovery and security.

[9 marks] b) Candidates should briefly describe three advantages of database servers, possibly including (but not exclusively) Reduced network traffic – as only database server requires processing power adequate to handle database and can be tuned to optimise database processing performance.

Reduced power required for each client as only database server needs power to handle database.

Centralised user authorisation, integrity checking, data dictionary maintenance (through stored procedures)

[9 marks] c) Candidates should two disadvantages of database servers, possibly including (but not exclusively) . Writing stored procedures takes more time than using tools such as VB or powerbuilder to create an application.

Stored procedures proprietary nature reduces their portability.

Each client must be uploaded with the application that that will be used at that location – complex individual upgrades of clients.

[6 marks] d)Candidates should briefly describe four advantages of three-tier architectures, possibly including (but not exclusively)

Scalability – middle tier can be used to reduce load on the database server.

Technological flexibility – easier to change DBMS engines, middle tier can be moved to a different platform, easier to change interfaces.

Lower long-term costs using off-the shelf components or services in the middle tier.

10 Better match of system to business needs, newmodules can be built to support specific business needs rather than building more general complete applications.

Improved customer service as multiple interfaces can access the same business process.

[12 marks] e) Candidates should explain the term ‘middleware’ and briefly describe one type of middleware, such as ODBC or JDBC. [14 marks]

11

Recommended publications