Exercise MTD 3033
EXERCISE: MTD3033ENTITY RELATIONSHIP DIAGRAM a. Describe what
relationship types represent in an Entity-Relationship (ER)
modeland provide examples of unary, binary, ternary, and quaternary
relationships. b. Describe how strong and weak entity types differ
and provide an example of each.
c. What is a recursive relationship? Give an example of recurse
relationship. d. Attribute is a property of an entity or a
relationship type. There are five types ofattributes which are
simple attribute, single-valued attribute, multi-valued attribute,
composite attribute, and derived attribute. Give an example of
derived attribute, multi-valued attribute and composite
attribute.
e. Describe what attributes represent in an ER model. Provide
examples of simple,composite, single-value, multi-value, and
derived attributes. f. Create an ER diagram for each of the
following descriptions: i. Each company operates four departments,
and each department belongs to one company.
ii. Each department in part (i) employs one or more employees,
and eachemployee works for one department.
iii. Each of the employees in part (ii) may or may not have one
or moredependants, and each dependant belongs to one employee.
iv. Each employee in part (iii) may or may not have an
employment history. g. Create an Entity Relationship (ER) diagram
for each of the following descriptions: i. A patient must be
assigned to only one doctor, and a doctor can have
manypatients.
ii. An employee has one phone extension, and a unique phone
extension isassigned to an employee.
iii. A movie theater shows many different movies, and the same
movies can beshown at different movie theaters around town.
1
Exercise MTD 3033
h. Read the following case study, which describes the data
requirement for a video rental company and answer the questions
below. The video rental company has several branches throughout
Malaysia. The data held on each branch is the branch address made
up of street, city, state, zip code, and telephone number. Each
branch is given a branch number, which is unique throughout the
company. Each branch is allocated staff, which includes a Manager.
The manager is responsible for the day-to-day running of a given
branch. The data held on a member of staff is his or her name,
position, and salary. Each member of staff is given a staff number,
which is unique throughout the company. Each branch has a stock of
videos. The data held on a video is the catalog number, video
number, title, category, daily rental, cost, status, and the names
of the main actors and the director. The catalog number uniquely
identifies each video. However, in most cases, there are several
copies of each video at a branch, and the individual copies are
identified using the video number. A video is given a category such
as Action, Adult, Children, Drama, Horror, or Sci-Fi. The status
indicates whether a specific copy of a video is available for rent.
Before hiring a video from the company, a customer must first
register as a member of a local branch. The data held on a member
is the first and last name, address, and the date that the member
registered at a branch. Each member is given a member number, which
is unique throughout all branches of the company. Once registered,
a member is free to rent videos, up to a maximum of ten at any one
time. The data held on each video rented is rental number, the full
name and number of the member, the video number, title, and daily
rental, and the dates the video is rented out and returned. The
rental number is unique throughout the company.
i. Identify the main entity types of the video rental company.
ii. Identify the main relationship types and specify the
multiplicity for eachrelationship. Represent each relationship as
an ER diagram together with entitys attributes. iii. Using your
answers for (i) and (ii), draw a single ER diagram to represent the
data requirements for the company (eliminate the attribute). d.
Read the following case study, which describes the data requirement
for an antique shop and answer the questions below. Aneka Antiques
buys and sells one-of-a-kind antiques of all kinds (e.g.,
furniture, jewellery, clothing, porceline). Each item is uniquely
identified by an item number and is also characterized by a
description, asking price, condition, and open-ended comments.
Aneka works with many different individuals, called clients, who
sell items to and buy items from the store. Some clients only sell
item to Aneka, some only buy items, and some others both sell and
buy. A client is identified by a client number and is also
described by a client name and address. When Aneka sells an item in
stock to a client, the owners want to record the commission paid,
the actual selling price, sales tax and date sold. When Aneka buys
an item from a client, the owners want to record the purchase cost,
date purchased, and condition at time of purchase.
iv.
Identify all of the main entities involved in this case
study.
2
Exercise MTD 3033
v.
Identify the main relationship types and specify the
multiplicity for each relationship. Represent all relationship as a
single ER diagram to represent the data requirements for the
company.You may use any assumption in order to develop a complete
diagram.
i. You are required to create a conceptual data model of the
data requirements for a company that specializes in IT training.
The Company has 30 instructors and can handle up to 100 trainees
per training session. The Company offers five advanced technology
courses, each of which is taught by a teaching team of two or more
instructors. Each instructor is assigned to a maximum of two
teaching teams or may be assigned to do research. Each trainee
undertakes one advanced technology course per training session. i.
Identify the main entity types for the company.
ii. Identify the main relationship types and specify the
multiplicity for each relationship. State any assumptions you make
about the data.
iii. Using your answers for (i) and (ii), draw a single ER
diagram to represent thedata requirements for the company.
3
Exercise MTD 3033
REALTIONAL MODEL a. All updates to a base relation should be
immediately reflected in all views thatreference to that base
relation. Identify the restrictions on types of modifications that
can be made through views.
b. Define the two (2) principal integrity rules for the
relational model. Discuss why it isdesirable to enforce these
rules. You may use some examples to support your answer. c.
Describe what is relational integrity of NULL represents for? d.
Discuss each of the following concepts in the context of the
relational data model: i. ii. iii. iv. v. vi. Relation Attribute
Domain Tuple Degree Cardinality
e. List four (4) properties of relations. f. The following
tables form part of a database held in a relational DBMS. Answer
allquestions below based on the following tables. Hotel Room
Booking Guest (hotelNo, hotelName, city) (roomNo, hotelNo, type,
price) (hotelNo, guestNo, dateFrom, dateTo, roomNo) (guestNo,
guestName, guestAddress)
where Hotel contains hotel details; Room contains room details
for each hotel; Booking contains details of the bookings for each
room in each hotel; and Guest contains guest details.
i. What is the difference between primary key and foreign key?
Define eachprimary key and foreign key in the table provided to
shows the relationship of the table.
ii. Produce sample table for each relation that observe the
relational integrity rules. Suggest some enterprise constraints
that would be appropriate for this schema.
4
Exercise MTD 3033
g. The following figure form part of an ER Model of a Customer
Invoice Module.Convert the following ER model into relations in a
relational data model. You can assume that each attributes contains
(at least) a suitably-named attribute containing a unique
identifying number.CUSTOMER Cust_ID(PK) Cust_Name 1..1 Cust_Add
Placess 0..* ORDER Order_ID (PK) Order_Date Cust_ID (FK) 1..1
Includes 0..* PRODUCT Is_ordered Product_ID (PK) Product_Desc 1..1
0..* Unit_Price ORDER_LINE Order_ID (PK) Product_ID (PK)
Order_Qtty
Figure 1.0: ER Model for Customer Invoice h. The following
relational data model form part of a database held in a relational
DBMS. Answer all questions below based on the following schema.
CUSTOMER(CSN, Name, Tel, Add, ICNo) VEHICLE(PlateNo, VehicleID,
Status, TtlFuel) VEHICLE_RENTAL(CSN, PlateNo, DateRent, DateReturn,
Charge) VEHICLE_TYPE(VehicleID, VehcCategory, VehcType, CC)
i. What is the difference between primary key and foreign key?
Define eachprimary key and foreign key in the schema provided to
show the relationship of the table. State NULL if the table is not
having any primary or foreign key.
ii. Produce sample tables for these relations that observe the
relational integrityrules. h.
5
Exercise MTD 3033
Figure 1: Relational Table i. Figure 1 above shows the
relational tables for a simple bibliographic database that stores
information about book title, authors, and publishers. i. What is
the difference between primary key and foreign key? ii. Define each
primary key and foreign key show in the table provided to shows the
relationship of the table. iii. Relational tables can be expressed
concisely by eliminating the sample data and showing just the table
name and the column names. From all tables provided, list out the
entities, attributes, primary keys and foreign key in logical data
model form.
iv. From relational table provided, find author name who
published book forAlgodata InfoSystems.
6
Exercise MTD 3033
SQLa. Structured Query Language (SQL) has two special pattern
matching symbols. State the symbols and provide an example to
support your answer.
b. ISO standard defines five (5) aggregate functions. State and
define each of the clausesin the aggregate function. c. Describe a
situation in which you would need to write a query using the HAVING
clause. d. What are the two major components of SQL and what
function do they serve? e. Explain the function of each of the
clauses in the SELECT statement. i. ii. iii. iv. v. FROM WHERE
GROUP BY HAVING
ORDER BY
f. The following tables form part of a database held in a
relational DatabaseManagement System (DBMS). Based on the following
table structure, create SQL statement for each of the following
questions. SALESPERSON Name Age Abel 63 Baker 38 Jones 26 Murphy 42
Zenith 59 Kobad 27 ORDER OrderNo 100 200 300 400 500 600 700
CUSTOMER Name Abernathy Construction Manchester Lumber Tri-City
Builders City Willow Manchester Memphis IndustryType B F B Salary
120,000 42,000 36,000 50,000 118,000 34,000 SalespersonName Zenith
Jones Abel Abel Murphy Abel Jones Amount 560 1800 480 2500 6000 700
150
CustName Abernathy Construction Abernathy Construction
Manchester Lumber Amalgamated Housing Abernathy Construction
Tri-City Builders Manchester Lumber
7
Exercise MTD 3033
Amalgamated Housing Memphis B i. List full details of all
Salesperson, alphabetically ordered by name. ii. Compute the
average age of a Salesperson. iii. Compute the number of
Customer(s).
iv. Show the names and salary of all Salesperson who do not have
an order with Abernathy Construction. v.Show the age of Salesperson
who have an order with a Customer in Memphis.
vi. vii.
Delete all orders for Abernathy Construction. Insert new record
into table Customer using the following data: Name = WestCourt
Furniture City = London Industry Type = F
viii.
Change the record of Salesperson named Jones into new data as
following: Name = Parks Age = 30
g. The following tables form part of a database held in a
relational DBMS. Based on the following table structure, create SQL
statement for each of the following questions. PATIENT PatientNo
P100 P209 P238 P266 P390 P397 Name Ali Ahmad Fatimah Mei Lin Raju
Kamil Age 58 45 34 28 12 35 StartDate 12/08/2008 12/08/2008
08/08/2008 10/08/2008 10/08/2008 Address 122, Jln Mawar, Tmn Mawar
Merah 8, Pesiaran Putra 4, Bdr Baru Putra 74, Jln MM 5, Bdr Baru
Tambun 17, Jln WM 3/22, Bdr Behrang 2020 45, Simpang 3, Tanjong
Malim 3A, Lrg 4, Tmn Tjg 3 EndDate 15/08/2008 18/08/2008 12/08/2008
14/08/2008 12/08/2008 UnitPerDay 3 4 3 3 4 Method
PATIENT_MEDICATION PatientNo DrugNo P100 D1023 P100 D2050 P238
D3044 P266 D1023 P266 D3044 DRUG DrugNo
DrugName
Description
Dosage
8
Exercise MTD 3033
D1023 D2022 D2050 D3044
Morphine Ibuprofen Tilcotil Tagamet
Painkiller Fever Cough Wind
10mg/ml 0.5mg/ml 5mg/ml 10mg/ml
Oral IV Oral Oral
9
Exercise MTD 3033
i. List full details of all drugs, alphabetically ordered by
drug name.ii. Compute the average age of a patient.
iii.
Retrieve the names of all patients who do not have a medication
of drug named Morphine.
iv. Show the age of patients who have a medication of a drug
which method of usage is by oral.
v.Delete all medications for Fatimah. vi.Change the record of
drug named Tilcotil into new data as following: Name = Rowatinex
Dosage = 15mg/ml Method = IV
vii.
Insert new medication for patient named Ahmad using the
following data: Drug Name = Ibuprofen Medication Duration = 3 days
from 10/08/2008 Unit Per Day = 3 times per day
h. The following tables form part of a database held in a
relational DBMS. Based on the following table structure, create SQL
statement for each of the following questions. STUDENT MatricNo
P001 P002 P003 StudentName Ahmad Ali Saadiah Hassan Chong Wai
Address Kuala Lumpur Batu Pahat, Johor Ipoh, Perak ProgrammeID AT20
AT14 AT20
LECTURER StaffNo StaffName A0011 Halisa Abdul Hamid A0003 Mohd
Kamal Ariffin A0034 Vikneswary a/p Marimuthu APPOINMENT ApmntNo
MatricNo 1 P003 2 P003 3 P001 4 P002 StaffNo A0011 A0003 A0011
A0034
RoomNo 3B-12 2A-11 2B-02 ApmntDate 3/1/2007 6/5/2007 5/6/2007
3/7/2007
FacultyID FTMK FTMK FST ApmntTime 3:00 pm 3:00 pm 9:00 am 4:00
pm
10
Exercise MTD 3033
i. List full details of all students under programme AT20,
alphabetically ordered by name. ii. How many students register for
Appoinment System? iii. List the names and matric number of all
students register for appointment on 3:00 pm. iv. List the names of
students register for appointment with Puan Halisa. v. Insert new
record into table Appoinment using following data. ApmntNo = 5
StudentName = Ahmad Ali StaffName = Mohd Kamal Ariffin ApmntDate =
6/5/2007 ApmntTime = 9:00 am
vi. Change the record of student named Chong Wai into new data
asfollowing: StudentName = Chong Wai Chi Address = Alor Star, Kedah
ProgrammeID = AT24
11
Exercise MTD 3033
NORMALIZATIONa. Describe the concept of functional dependency.
Use simple example to support your answer.
b.
Relations that contain redundant information may potentially
suffer from update anomalies. Describe the types of update
anomalies and use your own example to support your answer. c. What
are the main characteristics of functional dependencies that are
used when normalizing a relation?
d.data.
Define a normalization terminology and describe the purpose of
normalizing
e.
Describe briefly about First Normal Form (1 NF) and Third Normal
Form (3 NF) and use the example to support your answer.
f.hospital.
The Table 1.0 below shows patient medication form for Slim
River
Slim River Hospital Patient Medication Form Patient Number:
___P20024___ Full Name: __Ahmad Azran__ Bed Number: __05__Drug
Number 1023 1033 1023 Method of Admin Oral IV Oral
Ward Number: __W3A__ Ward Name: _Orthopedic_Units Per Day 50 10
10
Name Morphine Ibuprofen Morphine
Description Pain Killer Antibiotic Pain Killer
Dosage 10mg/ml 0.5mg/ml 10mg/ml
Start Date 14/01/2008 14/01/2008 15/02/2008
Finish Date 14/02/2008 19/01/2008 29/02/2008
Table 1.0 Fields in the original data table will be as follows:
PatientNo, fName, WardNo, WardName, BedNo, DrugNo, DrugName, Desc,
Dosage, Method, UnitPerDay, SDate, FDate Think of this as the
baseline one large table. Describe and illustrate the process of
normalizing data from the form shown in the above table to 3NF.
State your assumptions about the data shown in this table.
12
Exercise MTD 3033
g.
Figure 2.0 below shows a transcript for students result. Result
Transcript Sem I 2009/2010 UPSI Result No: RFTMK20910002 Result Sem
: I 2009/2010 Date : 12/07/2010
Matric No.: D2006102333 Name : Nur Ihsan Jasni Semester : 7 No.
1 2 3 4 5 Course Code MTD2013 MTS2013 MTK1013 KMM1013 MTG2023
Course Name Database System Data Structure Distcrete Mathematic
Business Management Multimedia Authoring
Program ID : AT20 Program Name : IT Faculty : FTMK Credit 3 3 3
3 3 Grade B+ B B C+ AGPA : 3.15 CGPA: 3.07
Figure 2.0: A Result Transcript of UPSI Student. Fields in the
original data table will be as follows: ResultNo, Date, ResultSem,
MatricNo, StudentName, Semester, ProgID, ProgName, Faculty,
CourseCode, CourseName, Credit, Grade, GPA, CGPA Think of this as
the baseline (0NF). Describe and illustrate the process of
normalizing data from the figure shown above to 3NF. State your
assumptions about the data shown in this figure.
13
Exercise MTD 3033
h.
The table below shows sales order form for Fiction Company.Sales
OrderFiction Company 202 N. Main Mahattan, KS 66502CustomerNumber:
Customer Name: Customer Address: 1001 ABC Company 100 Points
Manhattan, KS 66502 Sales Order Number: 405 Sales Order Date:
2/1/2000 Clerk Number: 210 Clerk Name: Martin Lawrence Quantity
Unit Price Total 40 60.00 2,400.00 20 20.00 400.00 10 100.00
1,000.00
Item Ordered 800 801 805
Description widgit small tingimajigger thingibob
Order Total
3,800.00
Fields in the original data table will be as follows:
SalesOrderNo, Date, CustomerNo, CustomerName, CustomerAdd, ClerkNo,
ClerkName, ItemNo, Description, Qty, UnitPrice Think of this as the
baseline one large table. Describe and illustrate the process of
normalizing data from the form table shown in above to BCNF. State
your assumptions about the data shown in this figure.
14