D03 Tutorial Updated

You might also like

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

D03 Relational Database Tutorial

0. Please read up on the following concepts and remember the definitions:


a) 3.3.1 Determine the attributes of a database: table, record and field.
b) 3.3.2 Explain the purpose of and use primary, secondary,
composite and foreign keys in tables.
c) 3.3.3 Explain with examples, the concept of data redundancy and
data dependency.
d) Explain with examples, the concept of data integrity, data privacy and
data consistency

1. An order form used by the customer of a supplier of goods has the


following form:

1. Each customer may send many orders.


2. Each order may have multiple lines for products.
3. One line contains the details for the order of an individual product.
Description refers to a comment/phrase related to this product only.
4. A product can appear only on one line on an order.
5. A product may occur on many different orders.

(a) Identify the tables that will give a normalized solution to this problem. Draw
an E-R diagram that shows these tables and the relationships between
them.

Customer (one-many) Order (one-many) ProductList (many-one) Product

(b) A table description can be expressed as:


TableName(Attribute1, Attribute2, Attribute3, …)

Give the table descriptions for the tables.

Product(ProductID, Description, Price)


Order(OrderNo, CustomerID*, Date)
ProductList(OrderNo*, ProductID*, Qty)
Customer(CustomerID, CustomerName, Address, TelNo)

2. Identify the tables in a normalized solution, with table descriptions and


draw the E-R diagram.

RV IP Subject Combination Selection Form


Name: Xiao Ming MatricNo: RV19_032S
Class: 4A GPA: 3.1

Subject Name Subject Code Subject Name Subject Code


1st Choice
H2 Mathematics 9758 H2 Computing 9569
H2 Physics 9749 H2 Economics 9757
2nd Choice
H2 Mathematics 9758 H2 Chemistry 9729
H2 Physics 9749 H2 Economics 9757
3rd Choice
H2 Mathematics 9758 H2 Chemistry 9729
H2 Physics 9749 H1 Economics 8823

Student(MatricNo, Name, Class, GPA)


Subject(SubjCode, SubjName)
Choice(MatricNo*, Choice, SubjCode1*, SubjCode2*, SubjCode3*,
SubjCode4*)

3. The Friendly Neighborhood Clinic (FNC) is shifting is service from hard


copy to a relational database management system. A typical Patient
Record Form can be found below.
The manager of the clinic told you that there are several doctors taking
shifts to serve the patients, they could be identified by their staff ID. Not all
patients need a medical certificate (MC). Patient Record Number, MC
Tracking Number and Medicine Serial Number are unique values to
identify patient records, MC records and Medicines.

Patient Record Form


Patient Record No: Appointment Date:
Patient Name: NRIC:
Address:

Doctor Name: Staff ID:


Specialization: Contact:

Medical Certificate: Yes/No MC Tracking No:


Start Date: End Date:

Medicine Serial No Description Symptom Unit Quantity


Price

a) You are required to design a relational database solution for the clinic.
Identify the tables that will give a normalized solution. Show the
process of normalization.
[6]

1NF:
PatientRecord(RecordNo, Date, NRIC, Name, Address, DoctorName, StaffID,
Specialization, Contact, MC, TrackingNo, StartDate, EndDate, SerialNo,
Description, Symptom, Price, Quantity)

2NF:
PatientRecord(RecordNo, Date, NRIC, Name, Address, DoctorName, StaffID,
Specialization, Contact, MC, TrackingNo, StartDate, EndDate)
MedOrderRec(RecordNo*, SerialNo*, Quantity)
MedicineInfo(SerialNo, Description, Symptom, Price)

3NF:
Patient(NRIC, Name, Address)
Record(RecordNo, NRIC*, Date, StaffID*, MC, TrackingNo*)
Staff(StaffID, DoctorName, Specialization, Contact)
MCRecord(TrackingNo, StartDate, EndDate)
MedOrderRec(RecordNo*, SerialNo*, Quantity)
MedicineInfo(SerialNo, Description, Symptom, Price)

b) Based on your solution in (a), draw a fully labelled ER diagram to show


how the entities are related. [4]

Patient
one-many
Staff one-many Record one-one MCRecord
one-many
MedOrderRec many-one MedicineInfo
4. Given the following scenarios, identify the necessary tables in the
normalized form, with potential fields for table descriptions. Then draw an
E-R diagram to show the relationships between these tables.

(a) The school library currently stores their data in flat files. These files contain
information about students, books and their loaning details.

A book can be borrowed by any student, and a student can borrow any
book. Students need to fill up a loaning record form each time he/she
wants to borrow a book. A student is entitled to borrow up to 5 books each
time using the same loaning record form.

Student(StudentID, Name, Class)


Record(RecordNo, BorrowDate, StudentID*)
Loan(RecordNo*, SerialNo*, ReturnDate)
Book(SerialNo, Title, Publisher)

Student (one-many) Record (one-many) Loan (one-one) Book

(b) A hospital keeps the hospitalization records for the patients. The system
should record down information of patients staying and related information
such as bed number.

(c) A school keeps the records of subject information of teachers who teach
the subject and students who take the subject.

Student(StudentID, StudentName, Class)


Teacher(TeacherID, TeacherName, SubjCode*)
Combi(StudentID*, SubjCode*)
Subject(SubjCode, SubjName)

Student (one-many) Combi (many-one) Subject (one-many) Teacher

You might also like