Bahria University (Karachi Campus) : Database Management System)

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

BAHRIA UNIVERSITY (KARACHI CAMPUS)

MIDTERM ASSESSMENT – SPRING 2020


(COURSE TITLE: Database Management System COURSE CODE: CSC- 220)

Class: BSE-4A Max Marks: 20


Faculty Member: Bushra Fazal Khan Due Date: 29th May 2020

Student’s Name: Aakif Iqbal Reg. #: 57267


Note:
 All question should be answered in the same file using black font color.
 Write the answer in your own wordings and avoid copying/pasting.
 Your submitted report might be checked for plagiarism.

Question 1(CLO 4:Marks 5):


Create a Crow’s Foot notation ERD to support the following business operations:
• A friend of yours has opened Professional Electronics and Repairs (PEAR) to repair smartphones, laptops,
tablets, and MP3 players. She wants you to create a database to help her run her business.

• When a customer brings a device to PEAR for repair, data must be recorded about the customer, the device, and
the repair. The customer’s name, address, and a contact phone number must be recorded (if the customer has used
the shop before, the information already in the system for the customer is verified as being current). For the
device to be repaired, the type of device, model, and serial number are recorded (or verified if the device is
already in the system). Only customers who have brought devices into PEAR for repair will be included in this
system.

• Since a customer might sell an older device to someone else who then brings the device to PEAR for repair, it is
possible for a device to be brought in for repair by more than one customer. However, each repair is associated
with only one customer. When a customer brings in a device to be fixed, it is referred to as a repair request, or just
“repair,” for short. Each repair request is given a reference number, which is recorded in the system along with
the date of the request, and a description of the problem(s) that the customer wants fixed. It is possible for a
device to be brought to the shop for repair many different times, and only devices that are brought in for repair are
recorded in the system. Each repair request is for the repair of one and only one device. If a customer needs
multiple devices fixed, then each device will require its own repair request.

• There are a limited number of repair services that PEAR can perform. For each repair service, there is a service
ID number, description, and charge. “Charge” is how much the customer is charged for the shop to perform the
service, including any parts used. The actual repair of a device is the performance of the services necessary to
address the problems described by the customer. Completing a repair request may require the performance of
many services. Each service can be performed many different times during the repair of different devices, but
each service will be performed only once during a given repair request.

• All repairs eventually require the performance of at least one service, but which services will be required may
not be known at the time the repair request is made. It is possible for services to be available at PEAR but that
have never been required in performing any repair.

Database Management System [Midterm Spring 2020] Page 1 of 6


• Some services involve only labor activities and no parts are required, but most services require the replacement
of one or more parts. The quantity of each part required in the performance of each service should also be
recorded. For each part, the part number, part description, quantity in stock, and cost is recorded in the system.
The cost indicated is the amount that PEAR pays for the part. Some parts may be used in more than one service,
but each part is required for at least one service.

Answer:

Crow’s Foot notation ERD:

Question 2(CLO 4:Marks 5):


Normalize the following documents to create tables in BCNF

Database Management System [Midterm Spring 2020] Page 2 of 6


Answer:

1NF:
PatientBill (PatientID,PatientName, PatientAddress, City_State_Zip, Date, DateAdmitted, DischargeDate,
CostCenter, CostName, DateCharged, ItemCode, Desc, Charge, BalDue).

2NF:
PatientBill (PatientID,PatientName, PatientAddress, City_State_Zip, Date, DateAdmitted, DischargeDate).
Cost (CostCenter, CostName, DateCharged,BalDue, PatientID).
Item (ItemCode, Desc, Charge, CostCenter).

3NF:
There is no transitive dependency in 2NF so, tables in 3NF will be same as in 2NF.

BCNF:
Table is already in form of BCNF thus it satisfies following rules:
o Table should be in the form of 3NF
o The prime attributes of the table should not depend on the non-prime attributes of the table.

Database Management System [Midterm Spring 2020] Page 3 of 6


Question 3(CLO 3:Marks 2.5):
Consider this table.

Given this data, determine which of the following statements are apparently true or false.

F —> A = false
A —> F = false
[A, B] —> F = false
C —> G = true
[A, B, D] —> [C, E, F, G] = false

Question 4(CLO 3:Marks 5):


For the provided Schema solve the queries given below using Relational Algebra
Schema
Note: “breadth” is a boolean indicating whether or not a course satisfies the breadth requirement for degrees in
the Faculty of Arts and Science.

Student(sID, surName, firstName, campus, email, cgpa)


Course(dept, cNum, name, breadth)
Offering(oID, dept, cNum, term, instructor)
Took(sID, oID, grade)

i) Department and cNum of all courses that have been taught in every term when csc448 was taught.
Answer(i):
448Terms(term) = π term(σ dept="csc"∧cNum=448(Offering))
courseterms(dept,cNum,term)=π dept,cNum,term(Offering)
shouldhavebeen(dept,cNum,term)=π dept,cNum(course) ⨯ 448Terms
werenotalways(dept,cNum,term)=((shouldhavebeen) - (courseterms))
answer(dept,cNum)=(π dept,cNum,) - (π dept , cNum(werenotalways))

Database Management System [Midterm Spring 2020] Page 4 of 6


ii) Name of all students who have taken, at some point, every course Gries has taught (but not necessarily
taken them from Gries).
Answer(ii):

π surName,firstName (π SID((σinstructor='Gries'(offering))/Took)/Student)

iii) Department and course number of courses that have never been offered.
Answer(iii):

(πdept,cNum(Course)) - (πdept,cNum(Offering))

Question 5(CLO 3:Marks 2.5):


For the given tables below identify the following information (if it is applicable).
1 Primary Key
2 Foreign Key(s)
3 Unique Key(s)
4 Candidate Key(s)
5 Composite Key
6 Alternate Key(s)

Database Management System [Midterm Spring 2020] Page 5 of 6


Answer:
Truck Table Base Table
Primary Key: TNUM Primary Key: BASENUM
Foreign Key: BASENUM, TYPENUM Foreign Key:
Unique Key: TSERIAL Unique Key: BASEPHON
Candidate Key: TNUM, TSERIAL Candidate Key: BASENUM, BASEPHON
Composite Key: BASENUM, TYPENUM Composite Key:
Alternate Key: TSERIAL Alternate Key: BASEPHON

Type Table
Primary Key: TYPENUM
Foreign Key:
Unique Key:
Candidate Key: TYPENUM
Composite Key:
Alternate Key:

Good Luck

Database Management System [Midterm Spring 2020] Page 6 of 6

You might also like