Professional Documents
Culture Documents
a. 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.
If a foreign key exists in a relation, either the foreign key value must match a candidate
key value of some tuple in its home relation or the foreign key value must be wholly
null.
c. The following tables form part of a database held in a relational DBMS. Answer all
questions below based on the following tables.
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.
Hotel
Room
Booking
Guest
There can be no two bookings for the same room in the same hotel on the same
day.
For the Booking relation, dateFrom must be before dateTo.
Room price must be greater than 0 and less than RM150
d. 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
Order
Product
1115 HE3002 1
e. 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. 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.
Customer
Vehicle
Vehicle_type
i. Figure 1 above shows the relational tables for a simple bibliographic database that stores
information about book title, authors, and publishers.
i. Define each primary key and foreign key show in the table provided to shows the
relationship of the table.
ii. 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.
iii. From relational table provided, find author name who published book for Algodata
InfoSystems (Hint: you can use any method to retrieve this info. Show in details)
SQL
a. Describe a situation in which you would need to write a query using the HAVING clause.
Filters group
Column names in HAVING clause must also appear in GROUP BY list or
be contained within an aggregate function.
b. Explain the function of each of the following clauses in the SELECT statement.
c. 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. (Hint:
For this question, you need to prepare the database and tables in order to manipulate the
data. You need to print screen each of the output and the coding to retrieve the output).
i. List full details of all students under programme AT20, alphabetically ordered by
name.
Table Student
Table Lecturer
Table Appointment
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 Haliza.
vi. Change the record of student named Chong Wai into new data as following:
StudentName = Chong Wai Chi
Address = Alor Star, Kedah
ProgrammeID = AC10
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.
i. Have a one-to-one relationship between attribute(s) on the left and right-hand side of a
dependency
ii. Hold for all time
iii. Are non-trivial
Normalization is a technique for producing a set of relations with desirable properties, given
the data requirements of an enterprise. Normalization supports database designers by
presenting a series of tests, which can be applied to individual relations so that a relational
schema can be normalized to a specific form to prevent the possible occurrence of update
anomalies.
e. Describe briefly about First Normal Form (1 NF) and Third Normal Form (3 NF) anduse the
example to support your answer.
The Primary key is usually a single column, but sometimes more than one column can be
combined to create a single primary key. For example consider a table which is not in First
normal form
Student Table:
Alex 14 Maths
Stuart 17 Maths
In First Normal Form, any row must not have a column in which more than one value is
saved, like separated with commas. Rather than that, we must separate such data into
multiple rows.
Student Table following 1NF will be:
Student Age Subject
Adam 15 Biology
Adam 15 Maths
Alex 14 Maths
Stuart 17 Maths
Third Normal form applies that every non-prime attribute of table must be dependent on
primary key, or we can say that, there should not be the case that a non-prime attribute is
determined by another non-prime attribute. So this transitive functional dependency should
be removed from the table and also the table must be in Second Normal form. For example,
consider a table with following fields.
Student_Detail Table :
In this table Student_id is Primary key, but street, city and state depends upon Zip. The
dependency between zip and other fields is called transitive dependency. Hence to
apply 3NF, we need to move the street, city and state to new table, with Zip as primary key.
New Student_Detail Table:
Address 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. Show
the process of normalizing the table step by step.
Partial dependency
PatientNo (fName, WardNo, WardName, BedNo)
DrugNo (DrugName, Desc, Dosage, Method, UnitPerDay)
Transitive dependency
WardNo WardName
We may assume that a patient is can take two medicine per day. Also, a patient may
can take one medicine only.