Professional Documents
Culture Documents
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.
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.
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 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.
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.
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. 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 all
questions 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 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.
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.
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.
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. ii. iii. iv. v. FROM WHERE GROUP BY HAVING
ORDER BY
CustName Abernathy Construction Abernathy Construction Manchester Lumber Amalgamated Housing Abernathy Construction Tri-City Builders Manchester Lumber
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
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.
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
10
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 as
following: StudentName = Chong Wai Chi Address = Alor Star, Kedah ProgrammeID = AT24
11
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.
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.
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
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
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
h.
The table below shows sales order form for Fiction Company.
Sales Order
Fiction Company 202 N. Main Mahattan, KS 66502
CustomerNumber: 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
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