COMP 124 - Fundamentals of Database Management Systems

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 8

KABARAK UNIVERSITY

UNIVERSITY EXAMINATIONS
MAIN CAMPUS
FIRST SEMESTER, 2022 ACADEMIC YEAR
EXAMINATION FOR THE DEGREE OF BACHELOR OF SCIENCE,
BACHELOR OF SCIENCE IN COMPUTER SCIENCE, BACHELOR OF
SCIENCE IN COMPUTER SECURITY AND FORENSICS

COMP 124: FUNDAMENTALS OF DATABASE MANAGEMENT


SYSTEMS

STREAM: Y1/S2 - REGULAR TIME: 9:00-11:00AM

EXAMINATION SESSION: JAN. - APRIL DATE :14/04/2022

INSTRUCTIONS TO CANDIDATES
1. Answer Question 1 and any other two questions in the answer booklet provided.
2. Do not write on your question papers. All rough work should be done in your
answer booklet.
3. Clearly indicate which question you are answering.
4. Write neatly and legibly.
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified

Page 1 of 8
5. Follow all the instructions in the answer booklet

As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified

Page 2 of 8
SECTION A: [Compulsory] TOTAL MARKS FOR THIS SECTION IS 30.

1.
(a) Define the following terms as used in database management systems [4 Marks]
(i) Data Model (iii) Attribute
(ii) Relation (iv) Tuple

(b) Enlist any four features of a Database Management systems [2 Marks]


(c) Differentiate between single-row functions and multiple-row functions. Provide examples
for each [4 Marks]
(d) Identify the commands under each of the following SQL languages; DCL and TCL
[2 Marks]
(e) Study the Employee Relation below and answer the following questions:
Emplno Fname Lname Starting_Salary
Empl001 Tulizo Mariam 45,660.00
Empl002 Japheth Samwel 54,000.00
Empl003 Wangio Muganda 34,900.00

(i) Emplno field is a Primary Key (PK) field. Explain what this means [2 Marks]
(ii) Use SQL to create two additional fields; Full_name and Current_Salary [2 Marks]
(iii) Use single-row function to merge Fname and Lname into Full_name field. Use
update script to post the merged values [2
Marks]
(iv)Use SQL to update the Current_Salary field for each employee with 5% increment of
the starting salary [2 Marks]

As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified

Page 3 of 8
(f) Explain the use of the following SQL functions. Use SQL scripts to demonstrate the use of
each. [4 Marks]

(i) LENGTH ( )
(ii) AVG ( )
(g) Discuss the three levels of data abstraction as used DBMS [6 Marks]

As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified

Page 4 of 8
SECTION B. TOTAL MARKS FOR THIS SECTION IS 40.
ANSWER ANY TWO QUESTIONS FROM THIS SECTION. EACH QUESTION IN
THIS SECTION CARRIES 20 MARKS.
2.
(a) Differentiate between the following; Use SQL examples for each
(i) GROUP BY and ORDER BY [4 Marks]
(ii) ROUND( ) and TRUNC( ) [4
Marks]

(b) Use the following students table to answer the questions below;
StudentNo StudentName Course FeeBalance
S001 Henry Paul Compute Science 3000.00
S002 Dedan Otieno General Science 3,660.00
S003 Sam Williams Computer Forensics 4,540.00

S004 Faith Alum Compute Science 30,980.00

(i) Use SQL statements to compute the average of fee balances proceeds for all
students [3 Marks]
(ii) Retrieve all students whose fee balances are more than 12000 and their names
contain letter “a” [4 Marks]
(iii) Create a view from students table for students doing computer science with the
following fields; StudentNo, StudentName and FeeBalance . Give your view the
name Student_feebal_view [5 Marks]

3.

(a) Discuss three different levels of abstraction [3 Marks]


As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified

Page 5 of 8
(b) Discuss the following cardinality ratios as used in DBMS. Provide examples for each
[6
Marks]
(i) M:N
(ii) M:1
(iii) 1:N
(c) Consider the following database schema to write nested queries in SQL
Supplier (id, name, city)
Parts(pno, pname, pdescription)
Supply(id, pno, cost)
(i) Find the names of the parts supplied by “Kamau” [2 Marks]
(ii) Find the names of the suppliers who supply “Nuts” [2 Marks]
(iii) Find the cost of bolts being supplied by Mache Hardware suppliers. [3 Marks]

(d) Use appropriate examples to explain the difference between RIGHT JOIN and LEFT
JOIN [4 Marks]

4.

(a) Distinguish between Primary key and foreign key as used in DBMS [4 Marks]
(b) Explain Three Schema objects used in MySQL DBMS [6 Marks]
(c) A bank has three types of accounts: checking, savings, and loan. The attributes of each
account are shown as follows:
Checking: Account_No, Date_Opened, Balance, Service_Charge
Savings: Account_No, Date_Opened, Balance, Interest_Rate
Loan: Account_No, Date_Opened, Balance, Interest_Rate, Payment

As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified

Page 6 of 8
Account_type is used to identify the type of accounts. Assume the account in the bank
can be only one of its subclasses.
(i) Draw an EER diagram for the bank. [5 Marks]
(ii) Draw a schema diagram for the bank [5 Marks]

5.
(a) Discuss five merits of using view objects over tables objects [5 Marks]
(b) Write an SQL script to create a table called users in a database; with the following
fields (assume the specific database has already been accessed) [5 marks]
a. id, which is the primary key and value is provided by the database server
b. username, which has an appropriate string format
c. password, with a format specific for the SHA encryption algorithm
d. reg_date, with an appropriate date format

(c) Based on the following tables answer the questions;

CREATE TABLE Books (


isbn char(20) primary key,
bname char(50),
type ENUM('technical', 'fiction', 'self-help')
);

CREATE TABLE Authors (


idn char(9),
isbn char(20),
primary key (idn, isbn)
);

(i) Use SQL to add an attribute - publisher into the Books table? [2 Marks]
(ii) Write an SQL query that will return the idns of authors who have written any book
that is not of TYPE 'fiction' [3 Marks]

As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified

Page 7 of 8
(iii) Write an SQL query that will return the isbns of books written by more than one
author. [2 Marks]
(iv) Write an SQL query that will return the idns of authors along with the number of
books written by each author. [3 Marks]

As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified

Page 8 of 8

You might also like