Introduction to Database Systems - Exam

THE UNIVERSITY OF DODOMA
COLLEGE OF INFORMATICS AND VIRTUAL EDUCATION
SCHOOL OF INFORMATICS

UNDERGRADUATE UNIVERSITY EXAMINATIONS
SECOND SEMESTER 2018/2019

CS 125: INTRODUCTION TO DATABASE SYSTEMS
Date: 01st July, 2019
Time Allocated: 3 Hours


SECTION A (60 Marks)

Question One

Choose the most correct answer and write its letter in the answer book provided: -
[1 Mark Each]

i. Software that defines a database, stores the data, supports a query language, produces reports and creates data entry screens is a:
A. Data Definition Software
B. Database management system (DBMS)
C. Decision support system
D. Relational database

ii. The separation of the data definition from the program is known as:
A. Data integrity
B. Data dictionary
C. Data independence
D. Referential integrity

iii. In the client / server model, the database:
A. is downloaded to the client upon request
B. is shared by both the client and server
C. resides on the client side
D. resides on the server side

iv. The database design that consists of multiple tables that are linked together through matching data stored in each table is called a:
A. Hierarchical database
B. Network database
C. Relational database
D. Object oriented database

v. Which of the following items is not the advantage of a DBMS?
A. Improved ability to enforce standards
B. Improved data consistency
C. Local control over the data
D. Minimal data redundancy

vi. In relational database model, after conceptually designing your database, the information contained in a single class would be stored in a:
A. Table
B. Database
C. Field
D. Property

vii. With SQL, how do you select all records from a table named “Persons” where the value of the column “FirstName” is “Peter”?
A. SELECT [all] FROM Persons WHERE FirstName LIKE ‘Peter’
B. SELECT * FROM Persons WHERE FirstName<>‘Peter’
C. SELECT [all] FROM Persons WHERE FirstName=‘Peter’
D. SELECT * FROM Persons WHERE FirstName=‘Peter’

viii. Given the basic ERD and relational models, which of the following is INCORRECT?
A. An attribute of an entity can have more than one value
B. An attribute of an entity can be composite
C. In a row of a relational table, an attribute can have more than one value
D. In a row of a relational table, an attribute can have exactly one value or a NULL value

ix. Which is TRUE about ORDER BY Clause as used in SQL:
A. Alters the order in which items are returned
B. Aggregate records by the specified columns
C. Filter the records if the condition specified is met
D. Specifies the tables involved in a query

x. Key to represent relationship between tables is called:
A. Primary key
B. Secondary Key
C. Foreign Key
D. None of the mentioned

xi. What does SQL stand for?
A. Structured Question Language
B. Structured Query Language
C. Strong Question Language
D. Structured Queue Language

xii. The following is the property of a database system:
A. It is an integrated collection of logically related records.
B. It consolidates separate files into a common pool of data records.
C. Data stored in a database is independent of the application programs using it.
D. All of the above.

xiii. In the relational database modal, cardinality is termed as:
A. Number of tuples
B. Number of attributes
C. Number of tables
D. Number of constraints

xiv. COUNT function when combined with DISTINCT in SQL will:
A. Return the values after count Null and repeating values in column
B. Return the values after counting only not null and non-repeating values in a column
C. Both A and B
D. Return the values after counting all values in a column

xv. Which is NOT true about HAVING Clause as used in SQL?
A. Can be applied to group of columns that appear in GROUP BY Clause
B. Can be applied to column(s) that appear in aggregate function
C. Can be applied to the rows in the results set
D. Can be applied to sorted columns


Question Two

Briefly discuss the following terms as used in Database System:
[3 Marks Each]

a. Conceptual Schema

b. Composite Key

c. Database

d. Derived Attribute

e. Weak Entity


Question Three

a. With example differentiate between Data Definition Languages (DDL) and Data Manipulation Languages (DML) as applied in database systems.
[5 Marks]

b. Briefly explain three major steps of the database design (data modeling) process.
[4 Marks]

c. Briefly explain two types of participation constraints that you can have in an E-R model.
[3 Marks]

d. State three roles of View in a Database Management System?
[3 Marks]


Question Four

a. A database approach addresses several problems and challenges associated with the traditional file-based approach. Using a DBMS to control how data is shared with different applications and users, through applications such as views, has a number of advantages. However, the implementation of a database approach has its own challenges, such as expense. Discuss the various costs associated with the implementation of a database approach.
[6 Marks]

b. With help of diagram explain the main objectives of the ANSI-SPARC architecture for a DBMS.
[6 Marks]

c. What are the roles of Application Program in ANSI-SPARC architecture in 3(b)?
[3 Marks]


SECTION B (40 Marks)

Question Five

a. Briefly explain any three types of integrity constraints in database system
[3 Marks]

b. The following tables form part of a database held in a relational DBMS:
Hotel(hotelNo, hotelName, city)
Room(roomNo,type, hotelNo price)
Booking(hotelNo, guestNo, dateFrom ,dateTo,roomNo)
Guest(guestNo, guestName,guestAddress)

i). Define Room relation in SQL so that every room is guaranteed to have price and the price values ranges between 40,000.00 and 100,000.00 respectively
[3 Marks]

ii). Define Booking relation in SQL such that hotelNo and guestNo, have the same values as in Hotel and Guest relations. Also ensures that when user modify the values in Hotel and Guest relations those values should be reflected in Booking relation or when the user delete the values in either Hotel or Guest relation the values in Booking relations should be set to NULL
[5 Marks]

iii). Define Hotel relation such that the values for city are Dar es Salaam, Dodoma, Arusha or Singida
[2 Marks]

iv). What will happen on Room relation when user try to run the following command:-
INSERT INTO Room VALUES (‘B15’, ‘SINGLE’ 2, 50,000.00) while 2 does not exist in Hotel relation, assume integrity constraint has been enforced on Room relation?
[3 Marks]

v). The following SQL statement violates some rules for creating an updatable view. Carefully identify errors present and rewrite the SQL statement so that it correctly defines the updatable view.
[4 Marks]

CREATE VIEW GuestBooking(hotelNumber, guestName, guestAddress, roomNumber)
AS SELECT DISTINCT *
FROM Guest g, Booking b
WHERE g.guestNo = b.guestNo

Question Six

Use the given information to develop a database that will store information about journals. Each journal has a journal identification number and name. Each journal may have any number of issues (for example monthly issues or three-monthly issues etc). Each issue is identified by its number and date issued. Each issue contains a number of articles. The length in terms of number of words is kept for each article, together with the number of diagrams in the article. Each article may be written by one or more writers. The writer’s name and address as well as fee paid to a writer for an article is also recorded. A writer may contribute as many articles to any journal.

a. Draw a complete ERD to represent the given information.
[6 Marks]

b. From the ERD in a) draw the logical schema
[4 Marks]

c. From the logical schema in (b) create any two data dictionaries
[4 Marks]

d. From the data dictionaries in (c) create any three physical schema
[6 Marks]


Question Seven

The University of Dar es Salaam has a booking system for its rooms. The system contains a relational database with information on events, organizers, rooms and room bookings. The tables are:

Event (eventID, type, duration)
Organizer (organiserID, firstName, lastName, email)
Room (roomID, capacity, projector, whiteBoard)
Booking (eventID, organiserID, roomID, bookingDate, bookingStartTime)

Where
Primary keys are underline
type is Lecture, Seminar or Laboratory;
duration is the event planned duration given in whole hours; the maximum duration is 4 hours;
capacity specifies the maximum number the room can accommodate; and
Projector/whiteboard are Booleans (1 or 0) specifying whether the room has the said facilities;

Required:
Write SQL statements to solve the following:

a. Add column Sex with data type varchar and size of 10 in the schema Organizer.
[2 Marks]

b. Write the query to delete Booking schema
[1 Mark]

c. Re-implement the schema Booking by enforcing all necessary integrity constraints available in the booking table
[3 Marks]

*d. To upload data from file named organizer.txt located in C:\Users\CS125 in the schema organizer
[3 Marks]

e. Write the query to list all organizer details
[2 Marks]

f. Write the query to produce a list of rooms that have both a projector and a whiteboard
[3 Marks]

g. Display a list of the organizers’ first names and last names together with the total number of hours they have booked in February 2019.
[3 Marks]

h. For an event with eventID= 205, create a timetable (in chronological order) which includes the type of event and all bookings for the event including the beginning and end time of each activity.
[3 Marks]


END OF EXAMINATION PAPER