20110420080454exercise_mtd3033 (3)

20
Exercise – MTD 3033 EXERCISE: MTD3033 ENTITY RELATIONSHIP DIAGRAM a. Describe what relationship types represent in an Entity- Relationship (ER) model and 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 of attributes 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 each employee works for one department. iii. Each of the employees in part (ii) may or may not have one or more dependants, and each dependant belongs to one employee. iv. Each employee in part (iii) may or may not have an employment history. 1

Upload: muhammad-faiz

Post on 21-Apr-2015

448 views

Category:

Documents


14 download

TRANSCRIPT

Page 1: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

EXERCISE: MTD3033

ENTITY RELATIONSHIP DIAGRAM

a. Describe what relationship types represent in an Entity-Relationship (ER) model and 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 of attributes 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 each employee works for one department.

iii. Each of the employees in part (ii) may or may not have one or more dependants, 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 many patients.

ii. An employee has one phone extension, and a unique phone extension is assigned to an employee.

iii. A movie theater shows many different movies, and the same movies can be shown at different movie theaters around town.

1

Page 2: 20110420080454Exercise_MTD3033 (3)

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 each

relationship. Represent each relationship as an ER diagram together with entity’s 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

Page 3: 20110420080454Exercise_MTD3033 (3)

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 the data requirements for the company.

3

Page 4: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

REALTIONAL MODEL

a. All updates to a base relation should be immediately reflected in all views that reference 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 is desirable 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. Relationii. Attributeiii. Domainiv. Tuplev. Degree vi. Cardinality

e. List four (4) properties of relations.

f. The following tables form part of a database held in a relational DBMS. Answer all questions below based on the following tables.

Hotel (hotelNo, hotelName, city)Room (roomNo, hotelNo, type, price)Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)Guest (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 each primary 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

Page 5: 20110420080454Exercise_MTD3033 (3)

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.

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 each primary 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 integrity rules.

h.

5

CUSTOMER

Cust_ID(PK)Cust_NameCust_Add

ORDER

Order_ID (PK)Order_DateCust_ID (FK)

PRODUCT

Product_ID (PK)Product_DescUnit_Price

ORDER_LINE

Order_ID (PK)Product_ID (PK)Order_Qtty

Places

Includes

Is_ordered

1..1 0..*

1..1 0..*

1..1

0..*

Page 6: 20110420080454Exercise_MTD3033 (3)

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 for Algodata InfoSystems.

6

Page 7: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

SQL

a. 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 clauses in 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. FROMii. WHEREiii. GROUP BYiv. HAVINGv. ORDER BY

f. The following tables form part of a database held in a relational Database Management System (DBMS). Based on the following table structure, create SQL statement for each of the following questions.

SALESPERSONName Age SalaryAbel 63 120,000

Baker 38 42,000Jones 26 36,000

Murphy 42 50,000Zenith 59 118,000Kobad 27 34,000

ORDEROrderNo CustName SalespersonName Amount

100 Abernathy Construction Zenith 560200 Abernathy Construction Jones 1800300 Manchester Lumber Abel 480400 Amalgamated Housing Abel 2500500 Abernathy Construction Murphy 6000600 Tri-City Builders Abel 700700 Manchester Lumber Jones 150

CUSTOMERName City IndustryType

Abernathy Construction Willow BManchester Lumber Manchester F

Tri-City Builders Memphis B

7

Page 8: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

Amalgamated Housing Memphis Bi. 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. Delete all orders for Abernathy Construction.

vii. Insert new record into table Customer using the following data:

Name = WestCourt FurnitureCity = LondonIndustry Type = F

viii. Change the record of Salesperson named “Jones” into new data as following:

Name = ParksAge = 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.

PATIENTPatientNo Name Age Address

P100 Ali 58 122, Jln Mawar, Tmn Mawar MerahP209 Ahmad 45 8, Pesiaran Putra 4, Bdr Baru PutraP238 Fatimah 34 74, Jln MM 5, Bdr Baru TambunP266 Mei Lin 28 17, Jln WM 3/22, Bdr Behrang 2020P390 Raju 12 45, Simpang 3, Tanjong MalimP397 Kamil 35 3A, Lrg 4, Tmn Tjg 3

PATIENT_MEDICATIONPatientNo DrugNo StartDate EndDate UnitPerDay

P100 D1023 12/08/2008 15/08/2008 3P100 D2050 12/08/2008 18/08/2008 4P238 D3044 08/08/2008 12/08/2008 3P266 D1023 10/08/2008 14/08/2008 3P266 D3044 10/08/2008 12/08/2008 4

DRUGDrugNo DrugName Description Dosage MethodD1023 Morphine Painkiller 10mg/ml OralD2022 Ibuprofen Fever 0.5mg/ml IVD2050 Tilcotil Cough 5mg/ml Oral

8

Page 9: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

D3044 Tagamet Wind 10mg/ml Oral

9

Page 10: 20110420080454Exercise_MTD3033 (3)

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 = RowatinexDosage = 15mg/mlMethod = IV

vii. Insert new medication for patient named “Ahmad” using the following data:

Drug Name = IbuprofenMedication Duration = 3 days from 10/08/2008Unit 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.

STUDENTMatricNo StudentName Address ProgrammeIDP001 Ahmad Ali Kuala Lumpur AT20P002 Saadiah Hassan Batu Pahat, Johor AT14P003 Chong Wai Ipoh, Perak AT20

LECTURERStaffNo StaffName RoomNo FacultyID

A0011 Halisa Abdul Hamid 3B-12 FTMKA0003 Mohd Kamal Ariffin 2A-11 FTMKA0034 Vikneswary a/p Marimuthu 2B-02 FST

APPOINMENTApmntNo MatricNo StaffNo ApmntDate ApmntTime1 P003 A0011 3/1/2007 3:00 pm2 P003 A0003 6/5/2007 3:00 pm3 P001 A0011 5/6/2007 9:00 am4 P002 A0034 3/7/2007 4:00 pm

i. List full details of all students under programme AT20, alphabetically ordered by name.

10

Page 11: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

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 = 5StudentName = Ahmad AliStaffName = Mohd Kamal AriffinApmntDate = 6/5/2007ApmntTime = 9:00 am

vi. Change the record of student named “Chong Wai” into new data as following:StudentName = Chong Wai ChiAddress = Alor Star, KedahProgrammeID = AT24

11

Page 12: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

NORMALIZATION

a. 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. Define a normalization terminology and describe the purpose of normalizing data.

e. Describe briefly about First Normal Form (1 NF) and Third Normal Form (3 NF) and use the example to support your answer.

f. The Table 1.0 below shows patient medication form for Slim River hospital.

Slim River HospitalPatient Medication Form

Patient Number: ___P20024___

Full Name: __Ahmad Azran__ Ward Number: __W3A__

Bed Number: __05__ Ward Name: _Orthopedic_

DrugNumber

Name Description DosageMethod of

AdminUnits Per

DayStart Date Finish Date

1023 Morphine Pain Killer 10mg/ml Oral 50 14/01/2008 14/02/2008

1033 Ibuprofen Antibiotic 0.5mg/ml IV 10 14/01/2008 19/01/2008

1023 Morphine Pain Killer 10mg/ml Oral 10 15/02/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

Page 13: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

g. Figure 2.0 below shows a transcript for student’s result.

Result TranscriptSem I 2009/2010

UPSIResult No: RFTMK20910002

Result Sem : I 2009/2010 Date : 12/07/2010

Matric No.: D2006102333 Program ID : AT20Name : Nur Ihsan Jasni Program Name : ITSemester : 7 Faculty : FTMK

No. Course Code Course Name Credit Grade1 MTD2013 Database System 3 B+2 MTS2013 Data Structure 3 B3 MTK1013 Distcrete Mathematic 3 B4 KMM1013 Business Management 3 C+5 MTG2023 Multimedia Authoring 3 A-

GPA : 3.15CGPA: 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

Page 14: 20110420080454Exercise_MTD3033 (3)

Exercise – MTD 3033

h. The table below shows sales order form for Fiction Company.

Sales Order

Fiction Company 202 N. Main

Mahattan, KS 66502

CustomerNumber: 1001 Sales Order Number: 405 Customer Name: ABC Company Sales Order Date: 2/1/2000 Customer Address: 100 Points Clerk Number: 210 Manhattan, KS 66502 Clerk Name: Martin Lawrence

Item Ordered Description Quantity Unit Price Total 800 801 805

widgit small tingimajigger thingibob

40 20 10

60.00 20.00

100.00

2,400.00 400.00

1,000.00

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