0% found this document useful (0 votes)
87 views5 pages

Database System II

This document contains a past exam paper for the course Database System II from Uganda Christian University. It includes 7 questions related to database concepts like data modeling, SQL, integrity constraints, security and more. Question 1 asks students to model a database for a hostel management system and write SQL statements. Other questions cover topics like data definition, queries, joins, views, roles, privileges and ACID properties.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views5 pages

Database System II

This document contains a past exam paper for the course Database System II from Uganda Christian University. It includes 7 questions related to database concepts like data modeling, SQL, integrity constraints, security and more. Question 1 asks students to model a database for a hostel management system and write SQL statements. Other questions cover topics like data definition, queries, joins, views, roles, privileges and ACID properties.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

UGANDA CHRISTIAN UNIVERSITY

FACULTY OF SCIENCE AND TECHNOLOGY


BACHELOR OF SCIENCE IN COMPUTER SCIENCE
THIRD YEAR SEPTEMBER SEMESTER EXAMINATION
IN
DATABASE SYSTEM II
Date: December 2011

Time: 3 Hours

Instructions
1. Attempt only five questions from the whole paper
2. Question one is compulsory

Question one
In a bid to make Global Students hostel a home away from home, the director wishes to create a
database application. Study the specifications below and answer questions that follow.
Global students hostel admits students from year one to year three. During admission, a students
file is opened which contains the students details i.e. RegNo, Name, Course, Home District,
Parents Contact, Next of Kin Contact. Every students file has a unique file number.
The hostel is composed of four blocks i.e. North America, Africa, Europe and Asia. Every Block
contains rooms which are named corresponding to the countries in each block e.g. in Africa block,
you will find rooms named Uganda, Kenya, Rwanda and etc.
Every student is assigned to a room and a room cannot have more than three students.
The warden also wishes to keep track of students payments who normally pay in installments
throughout the semester. In addition to that, the hostel management has always faced a problem of
overbooking where some rooms are overbooked and sometimes frustrating students on the opening
day.
a. Construct a data model showing the entities, relationships and constraints.

(10 Marks)

b. Write SQL statements to create one of the relations identified in a) above.

(5 Marks)

c. Write SQL to populate the relation created in b) above with sample data.

(5 Marks)

Question two
a) With examples, differentiate between the following terms as used in database systems. ( 3 marks@ )

i.
ii.
iii.

Single Valued and Multi Valued Attribute


Simple and Composite Attribute
Cardinality and Degree of a relation

b) The SQL standard provides facilities to protect the database from becoming inconsistent. These
are referred to as Integrity Enhancement Features (EIF).
(3 Mark @)
i. Domain Constraints
ii. Entity Integrity
iii. Referential Integrity
c) Define DML and DDL
(2 Marks)
Question Three
a. You have been hired a Database Administrator at MTN Uganda. All employees in this
organization have user accounts that they use to access the Database Management System. A
new employee by the name of MUGERWA has been hired as a staff member . Show how
you would use SQL to :i.

Add him as user to your database management system with a password Uganda.
( 2 marks)
ii. Authorize him to be able to update entries of the Sales relation of your database, and be
able to pass on the privilege to other employee he deems fit.
( 3 marks)
b. Assuming you wanted MUGERWA to share certain privileges with other MTN Uganda
members, Illustrate the SQL you would need to ;
i. Create a role named Super_warriors
ii. Award the privileges of INSERT & UPDATE to the role
iii. Assign the role to him ( MUGERWA)

( 3 marks)
( 3marks)
( 3 marks)

c. Within a month of getting the Job, Mugerwa is transferred to another department that does
not need to access the database, how would you,
i.
ii.

Revoke the privileges you awarded him in (b) above.


Remove him as a user from the database

( 3 marks)
( 3 marks)

Question Four
a. Below is a part of a logical design of the ABC Company database schema. Use it to respond
to questions which follow
Employees (employeeID Varchar(5), fName Varchar(30), lName Varchar(30), Designation
Varchar(20), GrossSalary int, address Varchar(10))
Department (Dnumber Varchar(7), Dname Varchar(10), Manager_SNN Varchar(10),
Manager_StartDate date , employeeID *)
Dept_Locations (DNumber varchar(10*), Location varchar(10));
2

Constraints
fName and lName cannot be without values,The underlined attributes are primary
keys and the attributes with an asterisk(*) are foreign keys.
Gross salary should accommodate 8 digits before the decimal point and only 3 digits
after the decimal point. Eg( 67568323.894)
Dnumber in the Department relation is UNIQUE and should not less than zero.
The default value of Location in the Dept_Locations relation is Kampala.
Write SQL Queries to;
i.

Create the structures of the tables above with all the necessary constraints inclusive
(8 Marks)

ii.

Add another attribute called Date_of_Birth and give it appropriate specifications. The
attribute Date_of_Birth should be after the Attribute fname in the employee relation.
(2 Marks)

iii.

List all employees with a Gross salary between 20,000 and 30,000. (Starting and Ending
values inclusive).
( 1 mark)

iv.

Retrieve details of all employees whose first_name starts with letter e.

v.

Give all employees a 3% pay increase.

( 2 marks)

vi.

Delete all employee records that relate to employeeID = SL21.

( 2 marks)

vii.

Change the Gross Salary column to accommodate a maximum of 13 integers assuming


initially it was accommodating 7 integers
( 2 marks)

viii.

Give ALL DETAILS of the employee with the least GROSS SALARY .

(1 mark)

( 2 marks)

Question Five
a) Relational Algebra is said to a theoretical language with operations that work on one or more
relations. Briefly discuss the five major operations that perform most data retrieval operations in
relational algebra
( 5 marks)

b) Consider the STAFF relation below


Dept

STAFF
FName
Junior
Brain
Maureen
David
Liz

LName
Akampulira
Kasozi
Niwagaba
Tusiime
Babirye

DeptNo
D001
D005
D002
D003
D004

Salary
10000
30000
20000
40000
450000

DeptNo
D001
D003
D002
D005

DeptName
Accounts
Sales
IT
Marketing

Location
Kampala
Entebbe
Masindi
Kampala

Derive Relational Algebra expressions that will satisfy the following conditions
i.

Select all staff with a salary greater than 2,500.

(2 Marks)

ii.

You want to retrieve all staff, whether or not they have matching departments in the
departments table. Which algebraic operation would you use?
(2 Marks)

iii.

Select Staff tuples whose department number is D002 or those whose salary is greater than
30,000 :
( 3 marks)

iv.

Give the fname and salaries of all staff with salaries between 10000 and 20000.
( 2 marks)

c) Consider the two relations DELL and TOSHIBA. A customer wants to buy a DELL or
TOSHIBA but is puzzled with making the rightful decision in terms of cost.
( 6 marks)
TOSHIBA
TOSHIBA
Model
Toshiba slide
Toshiba 1600
Toshiba X101

DELL
TOSHIBA Price
30000
20000
48000

DELL Model
DELL E101
DELL G700
DELL K750

DELL Price
40000
12000
60000

Derive a theta join table that will satisfy the conditions below
i.

A customer who does not want to spend more money for the DELL than for the
TOSHIBA Laptop.

ii.

A customer who may have a different thought of NOT spending more on the TOSHIBA
than for the DELL laptop.

Question Six
a) A constraint is a limitation that is enforced on fields for verifying data entered into a table.
Elaborate on any three different types of constraints that MySql provides on achieving maximum
optimization of data in a database.
(6 marks)
b) Constructing SQL statements. Given the following two tables

( 3 marks @)

Geography

Shoes
Town

Sales

Date

Kabale
Hoima
Mbarara
Jinja

1500/=
250/=
300/=
700/=

Jan-05-1999
Jan-07-1999
Jan-08-1999
Jan-08-1999

region_name Town
East
Jinja
East
West
West

Mbale
Hoima
Kabale

i.

In order to establish the sales by region, one would need to write a statement querying both
tables at the same time. Write the SQL statement that would show the total sales in each region.

ii.

What are the total sales in the towns of the west?

iii.

Which regions made sales in the first week of January 1999?

c) A view is a presentation of data selected from one or more tables. It contains no actual data but
rather derives what it shows from the tables and views on which it is based
Write an SQL statement that creates a view called staff, containing all individuals below 25yrs from a
base relation called employees one of whose attribute is Age.
(3 marks)
d).It is advised that new entrants of organizations should not access data directly from original base
relation but may access data from views. Why is this relevant?
( 2 marks)
Question Seven
a. Database security is a serious concern for organizations. Discuss atleast four ways in which
data controls are used to ensure data security.
( 6 marks)
b. Discuss the difference between a Role and Privilege as used in controlling user access to
database management systems.
( 4 marks)
c. Discuss the ACID properties of the database.

(10 Marks)

You might also like