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

DITP1333 Sem1 Session 2013/2014 Page 1

DITP 1333
DATABASE
Lab Activity Week 2

At the end of this lab session you should be able to:
Identify Primary Key, Foreign Key and Relationship from database tables.
Create the ERD to show the relationship among the database tables.


1. Use the database shown in Figure 1, to answer Questions 1 a) 1 e).





















PRODUCT TABLE
ProductID Product Name
Standard
Cost List Price
Reorder
Level
Supplier
ID
3 Syrup RM7.50 RM10.00 25 5
5 Olive Oil RM16.01 RM21.35 10 4
17 Fruit Cocktail RM29.25 RM39.00 10 6
19 Chocolate Biscuits Mix RM6.90 RM9.20 5 1
43 Coffee RM34.50 RM46.00 25 3
48 Chocolate RM9.56 RM12.75 25 5
52 Long Grain Rice RM5.25 RM7.00 25 4
66 Tomato Sauce RM12.75 RM17.00 20 4
83 Potato Chips RM0.50 RM1.80 30 1
85 Brownie Mix RM9.00 RM12.49 10 2
86 Cake Mix RM10.50 RM15.99 10 2
87 Tea RM2.00 RM4.00 20 3
99 Chicken Soup RM1.00 RM1.95 100 4

SUPPLIER TABLE
Supplier Company Contact Contact

Contact Phone Address City Postcode
ID Name LName FName Job Title
1 Besta Abu Bakar Aina Sales Manager
(03)
6550100
123
1st Street
Kuala
Lumpur 56675
2
Carens
Cake &
Pastry Zakaria Zamarul Sales Manager
(03)
6540104
143
2nd Street
Kuala
Lumpur 51232
3
Alllys
Beverages Azman Raihana
Sales
Representative
(03)
6320230
183
3rd Street
Kuala
Lumpur 54376
4 Dapur Anda Lokman Suraya Sales Manager
(04)
5450100
43
4th Street Ipoh 36546
5
Sweet
Paradise Ahmad Amirul Sales Manager
(04)
5210104
83
5th Street Ipoh 32677
6
Marrys
Dessert Osman Faridah Sales Manager
(04)
5820387
1/3
6th Street Ipoh 34865

Figure 1 : The ProductSupply database tables
DITP1333 Sem1 Session 2013/2014 Page 2

a. For each table, identify the primary key and the foreign key. If a table does not have
a foreign key, write None in the space provided.
TABLE PRIMARY KEY FOREIGN KEY
PRODUCT
SUPPLIER

b. Do the tables exhibit entity integrity? Answer yes or no, and then explain you answer.
TABLE ENTITY
INTEGRITY
EXPLANATION
PRODUCT

SUPPLIER


c. Do the tables exhibit referential integrity? Answer yes or no, and then explain you
answer. Write NA (Not Applicable) if the table does not have a foreign key
TABLE REFERENTIAL
INTEGRITY
EXPLANATION
PRODUCT

SUPPLIER


d. Describe the type of relationship between PRODUCT and SUPPLIER.
__________________________________________________________________

e. Create the ERD to show the relationship between PRODUCT and SUPPLIER.





DITP1333 Sem1 Session 2013/2014 Page 3

2. Use the database shown in Figure 2, to answer Questions 2 a) 2 D).



























CUSTOMER TABLE
CustomerID Customer Name Phone Number Status
C0003 Zarina Zainol 016-2456712 Government
C0015 Muaz Mahmood 019-3498722 NA
C1670 Kamal Azman 010-3421876 Member
C2031 Nazmi Adam 016-3256782 Government
C0443 Nuraini Bakar 010-7663287 Member
C0994 Aisyah Kamarul 010-5789213 NA

BOOKING TABLE
BookingID CustomerId DateBooking
C0003 Zarina Zainol 016-2456712
C0015 Muaz Mahmood 019-3498722
C1670 Kamal Azman 010-3421876
C2031 Nazmi Adam 016-3256782
C0443 Nuraini Bakar 010-7663287
C0994 Aisyah Kamarul 010-5789213

BOOKING LIST TABLE
BookingID RoomID NightStay
C0003 RS1 2
C0003 RDB2 2
C1670 RS2 3
C0443 RDX2 1
C0994 RDB1 1

ROOM TABLE
RoomID Location ExtNumber RoomType PricePerNight
RS1
Level 1
Single RM130
RS2
Level 2
Single RM130
RDX1
Level 1
Deluxe RM450
RDX2
Level 2
Deluxe RM450
RDB1
Level 1
Double RM240
RDB2
Level 2
Double RM240

Figure 2 : The HotelBooking database tables

DITP1333 Sem1 Session 2013/2014 Page 4

a. For each table, identify the primary key and the foreign key. If a table does not have
a foreign key, write None in the space provided.
TABLE PRIMARY KEY FOREIGN KEY
CUSTOMER
BOOKING
BOOKING LIST
ROOM

b. Create the ERD to show the relationship among the tables.







c. Describe each relationship that exists in the ERD created for Question 2b.




d. Table ROOM contains some data duplications, what would you suggest to reduce the
redundancy? Draw a new ERD to illustrate your answer.

You might also like