ucc dbms exam april 2012

Upload: duval-pearson

Post on 03-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 UCC DBMS Exam April 2012

    1/13

    UNIVERSITY COLLEGE OF THE CARIBBEANIncorporating Institute Of Management Sciences &

    Institute Of Management & ProductionA Member of the Commonwealth & OAS Consortia of Universities

    DATABASE MANAGEMENT SYSTEMS [ITT104]EOM EXAMANSWER KEY

    APRIL 2012

    INSTRUCTIONS TO MARKERS:MARKING STUDENTS SCRIPTS

    1. Always refer to the marking scheme when marking.

    2. For simplicity, uniformity and comparison purposes, mark the same question throughout all the

    scripts first and then mark the next question (i.e. Q2) throughout.

    3. Ignore any names of students that may be on the script to help avoid bias.

    4. Use the margin to enter your evaluation of the work in relation to each part of the marking

    scheme.

    5. 1ST Marker please mark in red biro/ink only.

    6. 2nd Marker please use green biro/ink only.

    7. Close attention must be placed on the level of English displayed when marking. More marksshould be awarded to students who show the ability to understand and answer the questions at

    an appropriate, searching and analytical level.

    8. Enter the final marks and any comments at the end of the answer and enter the mark on the

    front cover page.

    9. Enter any pertinent comments in the area assigned on the cover page, for ExaminersComments . Your signature and the date should be inserted as an indication that you have

    completed the marking process.

  • 7/28/2019 UCC DBMS Exam April 2012

    2/13

    SECTION A - Compulsory Question

    Question 1. (30 marks)

    SALES DEPOT

    Create a database that could be used to produce a report of customer details.

    You are not expected to write a report, just define a database to contain theinformation that the report would be based on. The report should list the

    customers name, account balance, credit limit, and other customer detailssuch as the products they have purchased. The report will also list thecustomers account representative (one of the sales employees). Each salesrepresentative manages many customers but each customer will be managedby only one representative at any one time. Your design should allow forcustomers being managed by many account representatives over time as it ispossible that some of our employees may leave the company- thus requiringnew account representatives for a customer.

    a) Develop a suitable Entity Relationship Diagram and set of relations (a schema)that may be used to implement yourdatabase. (5 marks)

    The above question should be answered by the candidate drawing a suitablediagram to define the following three relations.

    CustomerPurchasedProductsAccountsSales

    For each relation, the candidate should define their attributes and the relationshipbetween each relation. The relationship is below.

    Customer 1:1 AccountsCustomer 1:N PurchasedProductsPurchasedProducts N:1 CustomerAccounts 1:N Customer

    b) Write the SQL to create all of the tables and their attributes, data types andkey fields (10

    marks)The criteria to judge this question against are:

    1. Has the candidate created a suitable number of tables?2. Does each table contain capture enough information?3. Does each table define a primary key?

    2 marks for each table that contains enough information with a correct primary key2 additional marks for good column names and appropriate data types.8

  • 7/28/2019 UCC DBMS Exam April 2012

    3/13

    Ignore if the candidate has got the syntax wrong as its not appropriate to test acandidates recollection of syntax in an exam.

    createtable Customer(

    CustId intprimarykey,CustName nvarchar(50),AccountId int,

    PurchasedId int,

    ManagedBy int);

    createtable PurchasedProducts(PurchaseId intprimarykey,

    ProductId int,ProductName nvarchar(50)

    )

    createtable Accounts(

    AccountId intprimarykey,AccountBalance int,CreditLimit int,

    );

    createtable Sales(ManagedBy intprimarykey,RepresentativeName nvarchar(50)

    );

    c) Identify and describe how you would develop two (2) queries that youconsider relevant to the daily operations of thebusiness. (6 marks)

    Candidate needs to ask what information would be business need to know each day.

    Three (3) marks per query.1. 1 mark for legal SQL grammar (would the DB execute the query)2. 1 mark for the query being something they would need to know daily3. 1 mark for description of how they developed the query

    Types of query that should be awarded marks

    1. Any query to check the referential integrity of the database2. Which customer bought the most3. What is the most popular product4. What is the least popular product

    d) Identify and describe how you would develop one (1) report that you could useeach month to show which sales representative made the most sales and to whichcustomers eachmonth. (4 marks)

    2 marks for a description of what information would go into thereport2 marks for the SQL query

  • 7/28/2019 UCC DBMS Exam April 2012

    4/13

    e) Identify and describe at least one other query or report that managementwould be able to use in assisting them to grow the business and satisfy theircustomers. (5 marks)

    Suitable queries are:

    1.Are Sales staffmanaging a roughly equal number of customers?2.What is the average amount of credit for all customers?3.Are there any accounts with negative balances?4.Any query to maintain the referential integrity

    For such queries, allocate marks:

    1 mark for correct SQL grammar2 marks for the query logic --- does it do what the candidate expects2 marks for the description of what that query/report would do to meet

    requirements

    SECTION B - Optional Questions[20 marks each]You must answer three (3) of these questions. You may answer any three.

    f) SQL

    Present the main features of a Structured Query Language (SQL) and suggestthe reasons why these programming languages are so vital in the creation andmaintenance of commercialDatabases. (20 marks)

    Give two (2) marks for each sub-answer, outlined below.

    Main features of SQL

    1. Divides queries up into a number of kinds, e.g., select, delete, insert,update2. Presents standardized way to query and manipulate data in a relational DB3. Declarative language (what not how), rather than procedural4. Examples of queries:

    1. select query. What is selected, from which table and use of where2. delete. What is deleted3. insert. What is inserted4. update. What is updated and how is update controlled (where clause)

    5. Types are abstract across machine types1. nvarchar(50) is same on Windows, Unix, and Mac and 32bit and 64bit

    machines6. Expression of transactions is straight-forward

  • 7/28/2019 UCC DBMS Exam April 2012

    5/13

    1. What to do on transaction failure or success is apparent forprogrammer7. Security is an integral part of SQL, specified through SQL language

    1. Grant and Revoke permissions per user

    Reasons why SQL is so vital in creation and maintenance of commercialdatabases

    f)..1 SQL is a standard, allowing industry to focus on one solutionf)..1..1 Code is portable between different DB vendors

    f)..2 General purpose programming language for database development.f)..3 SQL is quite abstract, a lot of optimizations (but not all) are handled by

    the DBf)..3..1 This makes it easier to use

    f)..4 SQL is similar to a managed language like Java or C#f)..4..1 So a SQL programmer is free to concentrate on their solution, not

    the detail of the computer they are working withf)..5 SQL allows the programmer to specify what should be done, not how

    f)..5..1 A query is described, but the programmer does not have to saywhich table is searched first, for example.f)..6 Give credit for any reasonable reason.

    g) Normalization

    g)..1 Explain the purpose of normalization. (3marks)

    Reduce redundancy

    Reduce dependency Organise data more efficiently

    Reduce the potential for data anomalies

    .1 Define clearly, using examples, the normalization rules for 1NF, 2NFand 3NF. (12 marks)

    See next page

  • 7/28/2019 UCC DBMS Exam April 2012

    6/13

    The table above is in 1NF, given definition of 1NF used in the lectures.

    Above table is in 2NF. Candidate must give the above 2NF definition forthe mark and they should show what they mean by that definition withreference to an example, either with reference to a number of tables, or

    the above kind of table defi

    nition. Either isfi

    ne.

    The above slide illustrates a step in going from 2NF to 3NF. Studentsshould be given credit for partially defining the step from 2NF to 3NF.

    Above is now in 3NF.For each 1NF, 2NF and 3NF, give 2 marks for definition and 2 marks forillustration of definition.

    .2 The following table is already in 1NF & 2NF, but not in 3NF.Normalize the table into third normal form (3NF). Show any extratables that are created through the normalization process. (5marks)

    Employee Department Assignment

    Employe

    e ID

    Employee

    Surname

    Addres

    s

    Phone Employee

    Job Title

    Department Dept

    Number

    Dept

    Location

    Q123 Brown Portmor

    e

    333-838

    3

    Operator Servicing D 02 Block A

    AB56 King Barbica

    n

    511-998

    7

    Tech Servicing D 02 Block A

    Q123 Brown Portmor

    e

    333-838

    3

    Operator Accounts D 11 Block F

    A relation is in 3NF if and only ifit is in 2NFand there are no non-key attributes

    determined by another non-key attribute. The term non-key attribute means an

    attribute that is neither (1) a candidate key itself, nor (2) part of a composite

    candidate key.

    Department, Dept number and Dept location should be placed into new table

    Department

  • 7/28/2019 UCC DBMS Exam April 2012

    7/13

    and a foreign key created for the above table to reference it. These three columns

    are a candidate key.

    2 marks for the candidate showing what the operations are to go from 2NF

    to 3NF.

    2 marks for creation of new table and putting 3 columns into it

    1 mark for change to above table to reference new table

    3. Semantic Objects [20 marks]

    A motor vehicle garage business operates as an all inclusive service business. Forallvehicles that it repairs it is a one stop destination. A customer simply drops off their

    vehicle, where the vehicle gets tested, the parts are provided and they are fitted bya

    service mechanic.

    The customer receives one bill for each vehicle serviced belonging to thatcustomer.Each vehicle specifies Make, Serial Number, License Number, Year, Color. Detailsalsoinclude Service Date for the given vehicle, Service Details, and Service Charge.

    The customer is also billed for parts fitted, where Part Number, Part Name, SalesPriceand Quantity are itemized for that vehicle, as well as the details of the technician

    who serviced the vehicle such as Technician Code Technician First Name, Technician

    Last Name and Experience Level.

    It is a norm for one customer such as car rentals to send more than one vehicle at a

    time to be serviced. It is also a given that a given vehicle might need to be serviced

    more than once before it is released form the garage.

    a) Draw a semantic object diagram of a garage bill that reflects the above (8

    marks)Situation. Include all the cardinality relationships as appropriate.

    b) Write the relational representation that describes the situation, showing (4marks)all the relationships.

  • 7/28/2019 UCC DBMS Exam April 2012

    8/13

    c) Draw the appropriate corresponding relational model that represents (6

    marks)the outline of the above situation. The diagram should only be at a generallevel of abstraction, but must include details such as indication for primaryand foreign keys.

    d) State what type of object category this model would fall under. (2marks)In about two or three lines, explain your reason for saying so.

  • 7/28/2019 UCC DBMS Exam April 2012

    9/13

    4. Relational Database Design

    a. List any three (3) advantages of a relational database over either

    the network or hierarchical database models. (3 marks)

    1. Hierarchical model has a parent child relationship, one parent with

    many children, but a child could have only one parent. Relational can

    model N:M, but hierarchical cant.

    2. SQL is declarative

    3. More flexible in that relational data does not have a fixed structure

    as networks and hierarchical imply

    4. Hierarchy database may require the whole database to be redefined

    when data is added

    Give credit for any other sensible suggestion. 1 mark for each.

    List and explain the six (6) properties of relational tables. (6 marks)

    1) Values are atomic.

    2) Column values are of the same kind.

    3) Each row is unique.

    4) The sequence of columns is insignificant.

    5) The sequence of rows is insignificant.

    6) Each column must have a unique name.

    b.

    c. What is a secondary key? (1 mark)

    A secondary key is a field that is identified as being suitable for indexing the data such as a surname,

    It is used to sort the data in a different order to the primary key, A table can have many secondary keys

    in fact every field could be a secondary key.

    Define and explain the term referential integrity. How is referentialintegrity maintained in a database system such as Microsoft Access? (4 marks)

  • 7/28/2019 UCC DBMS Exam April 2012

    10/13

    Referential integrity is a data property that requires every value of one attribute (column) of a relation

    (table) to exist as a value of another attribute in a different (or the same) relation (table).

    For referential integrity to hold in a relational database, any field in a table that is declared a foreign keycan contain only values from a parent table's primary key or a candidate key. For instance, deleting a

    record that contains a value referred to by a foreign key in another table would break referential integrity.Some relational database management systems (RDBMS) can enforce referential integrity, normallyeither by deleting the foreign key rows as well to maintain integrity, or by returning an error and not

    performing the delete. Which method is used may be determined by a referential integrity constraintdefined in a data dictionary.

    1 mark for definition of referential integrity as above in first paragraph.

    1 mark for reference in answer to properties have to be defined for every attribute.1 mark for an example, e.g., above the delete example1 mark for how it is maintained in a database like Microsoft Access, but this part of the answer could be

    for any relational database from any manufactuer.

    d. Name the three (3) types of relationships that can exist between

    entities. (3 marks)

    one-to-one

    one-to-many

    many-to-many

    e. Describe how many-to-many relationships are resolved. (3 marks)

    Through the use of another table and a key into that table from a

    referring table.

    1 mark for stating a new table is necessary

    1 mark for stating a key into that table is required

    1 mark for stating the referring table may have many rows that refer

    to many other rows in the new table, through that new tables primary

    key (via the foreign key from the referring table).

    5. Database Management

    Define what is meant by a database management system and identify

    three (3) advantages and two (2) disadvantages of using a database

    management system. (20 marks)

  • 7/28/2019 UCC DBMS Exam April 2012

    11/13

    5 marks for a diagram of the 5 components of a DBMS

    Users, database applications, SQL, DBMS and Database (data on disk)

    5 marks for describing them in more detail (saying what they are)

    5 marks for an essay-type description of how the components work together to

    provide the functionality of a database management system. Does the candidate

    show an understanding of how the parts of the system contribute to the behavior

    of the whole?

    3 advantages are

    Data integrity

    Data security

    Data atomicity

    Transactional modifications

    Ease of query with SQL compared to other technologies, e.g., XML-based

    queries

    2 disadvantages

    Cost

    Technical lock-in to a particular vendor

    6. Data Modelling

    f)..3..2 What is data

    modeling? (3 marks)

    Data modeling is the process of creating a data model for an information system by applying some type of

    data modeling technique, be it formal or otherwise. This is done to further understand the requirements of

    the information system being modeled so that an engineer can implement the model using some for of

    (relational) database technology.

    1 mark for definition of data model

    1 mark for why its done (understand the requirements)

    1 mark for illustrating answer with example

    f)..3..3 Name another data modeling technique, other than the entity

    relationship model? (1 mark)

  • 7/28/2019 UCC DBMS Exam April 2012

    12/13

    semantic, data-structure, geographic, generic (any from section 3

    of this URL)

    For reference: http://en.wikipedia.org/wiki/Data_model

    f)..3..4 Define each of the following terms.

    Entity (2 marks)

    A piece of information that is captured about some element

    of the problem space being implemented within a database,

    or captured as part of a data model, e.g., Employee,

    Customer, Part. One mark for definition and one mark for

    illustration via example or with reference to a table or some

    part of a data model (assuming that the example is correct.

    0 marks if the example is wrong).Attribute (2 marks)

    A column in a table. A piece of data captured about an

    entity, e.g., for a customer table, their name or the

    customers address is an attribute.

    Primary Key (2 marks)

    A primary key is a combination of columns which uniquely specifys a row. E.g., for a

    Customer table, a CustomerId would be a primary key assuming that the CustomerId

    was unique for each row. Or there could be a combination of attributes that uniquely

    identified a row, that is also a primary key.

    One mark for definition (in particular the notion of it uniquely identifying ONE row)

    and one mark for an illustrative example.

    Relationship (2 marks)

    A relationship between two relations (tables), e.g., one-to-

    one, one-to-many or many-to-many. Illustrate with an

    example for the 2nd mark.

    d. Describe how each of the terms in part (c) is usually represented

    in an entity-relationship diagram. Two marks for each. (8

  • 7/28/2019 UCC DBMS Exam April 2012

    13/13

    marks)

    Diagram taken from http://en.wikipedia.org/wiki/Entity-relationship_model for referenceAn attribute is some piece of information associated with an entity, e.g., for an artist it would be theirname, the recording label that are signed to, their back catalogue and so on.

    End of Paper