Post on 04-Jan-2022
1
SECTION A (60 MARKS) 1. Illustrate ONE (1) example of database system in the following domains:
a) Transportation
(2 marks)
Airline Ticketing System that stores related data about flights, crews, pilot,
airports and trips.
Customer can search their desired flight and destination and purchase their
ticket online
b) Education
(2 marks)
University Registration System that stores related data about students,
lecturer, courses.
Students can perform online registering of their courses before semester
starts.
2. Describe TWO (2) components of database system environment.
(4 marks)
Any 2 answers:
Hardware can range from a PC to a network of computers.
Software including DBMS, operating system, network software (if necessary) and
also the application programs.
Data that are used by the organization and consists of operational data and the
meta-data.
Procedures which are instructions and rules that should be applied to the design
and use of the DBMS.
People include various roles like Data Administrator, Database Administrator
(DBA), Database Designers, Database Application Programmers and End Users
(naive and sophisticated).
2
3. State TWO (2) phases of database design.
(2 marks)
a. Conceptual database design
b. Logical database design
c. Physical database design
4. List TWO (2) purposes of database administration.
(2 marks)
Management of physical realization of a database
Management of data resource including
5. Explain the concept of derived attribute in Entity Relationship Model. Provide ONE (1)
example of derived attribute.
(3 marks)
- Derived attribute: Attribute that represents a value that is derivable from value
of a related attribute, or set of attributes (e.g. the duration attribute is calculated
from start and finish attributes).
6. Draw a complete ER diagram with attributes to represent the business rule given below:
“A Company may offer a number of Jobs with some Jobs may be offered by
different Company”.
(3 marks)
3
Answer:
7. Explain the problem of chasm trap in designing Entity Relationship Model.
(2 marks)
A chasm trap problem where pathway does not exist between certain entity occurrences
although a model suggests the existence of a relationship between the entity types.
8. Give ONE (1) example of domain for attribute in a relation.
(2 marks)
Example: Matric Number is student identification number – a numeric value from 10000 – 30000 or any acceptable example.
9. Explain ONE (1) example of Enterprise Constraint in an Education system.
(2 marks)
Additional rules specified by users or database administrators.
Example: Student can takes 6 subjects for each semester or each subject can be taken by
100 students or any acceptable answer.
4
10. Answer the following questions based on the table shown below:
studID sName sAddress courseCode courseName
S233714 Hamizah Muhd Alor Setar, Kedah
BIT Information Technology
S230780 Amjadi Ali Bangi, Selangor MM Multimedia
S231760 Nurazean Noor Kuala Lumpur, WP
BIT Information Technology
S231075 Aidil Akmar Shuib
Kuala Lumpur, WP
COM Communication
S232441 Syed Rizal Razak Ipoh, Perak BUS Business
a. The above table is susceptible to update anomalies. Explain and provide ONE (1) example
for each of the insertion, deletion and modification anomalies. (6 marks)
Insertion anomaly Happen when a new row cannot be inserted unless all primary key values are supplied. Example - To insert new course information, we must know the student ID because this is primary key and we cannot assign NULL value for the primary key. [2 marks]
Deletion anomaly Deleting a row results in losing important information not stored elsewhere. Example – If we delete a record from the table that represents the student, for example, Amjadi Ali, the details about the course (i.e. Multimedia) also will be lost from the database. [2 marks]
Modification anomaly A simple update must be applied to multiple rows. Example – if we change the value of the courseName (e.g. from Information technology to Bachelor of Science in Information Technology), several records need to be changed. [2 marks]
b. Explain the concept of functional dependency and give TWO (2) example of functional
dependency from the above table. (4 marks)
5
Functional dependency describes relationship between attributes in a relation. If A and B of a relation R, B is functionally dependent on A if each value of A in R is associated with exactly one value of B in R. [2 marks] Examples: [2 marks]
studID functionally determines sName and sAddress
courseCode functionally determines coursename
11. List TWO (2) examples of data types and declarations in ISO SQL data types.
(2 marks)
1. boolean: BOOLEAN
2. character: CHAR VARCHAR
3. interval: INTERVAL
4. datetime: DATE TIME TIMESTAMP
5. approximate numeric: FLOAT REAL DOUBLE PRECISION
12. Discuss ‘CASCADE’ and ‘SET NULL’ as Integrity Enhancement Features based on Entity
Relationship Diagram below.
(3 marks)
Answer:
- CASCADE: A feature to delete row from parent (NEWSPAPER) and delete matching
rows in child (PROPERTY), and so on in cascading manner.
- SET NULL: Delete row from parent (NEWSPAPER) and set FK column(s) in child
(PROPERTY) to NULL (only valid if FK columns are NOT NULL).
NewsPaper
NewsName (PK) Description
Property
PropertyID (PK)
PropertyAddress
NewsName (FK)
Advertises 1..1 1..*
6
13. Based on the BOOK table below, write SQL statements to perform the following:
BOOK (bookID, bookTitle, author, unitPrice)
a) Create the BOOK table (use appropriate attributes and define the primary key). (4 marks)
Answer:
CREATE TABLE BOOK
(bookID INTEGER NOT NULL,
bookTitle TEXT(20) NOT NULL,
author TEXT(30) NOT NULL,
unitPrice INTEGER,
PRIMARY KEY (bookID));
b) Insert the following data into BOOK table.
(2 marks)
bookID=77
bookTitle='AGENT TECHNOLOGY FOR E-COMMERCE'
author='MARIA FASLI'
unitPrice=199
Answer:
INSERT INTO BOOK VALUES (77,'AGENT TECHNOLOGY FOR E-COMMERCE', 'MARIA FASLI',199);
14. Using SQL statements, create view of Student1 to display studentID, name, age and gender
from the Student table.
(2 marks)
CREATE VIEW Student1
AS SELECT studentID, name, age, gender
FROM Student;
7
15. Analyse the SQL statements below and describe the policy enforced by the assertion_Policy.
Create table Employee ( ID integer unique, salary integer, dept# integer) Create table Department ( dept# integer unique, salaryMax integer) Create assertion_Policy check ( Not exists (select * From Employee, Department Where Employee.dept# = Department. dept# And Employee.salary > Department.salaryMax))
(2 marks)
Answer: The above trigger states that after any insertion or update on the Employee or the Department table, there should not be any employee having a salary greater than the salary max in the corresponding department of the employee.
16. State TWO (2) purpose of using Triggers in SQL (2 marks)
Answer:
– Validating input data and maintaining complex integrity constraints that otherwise
would be difficult/impossible.
– Supporting alerts.
– Maintaining audit information.
– Supporting replication
8
17. Database Administrator or owner of the database can provide or remove privileges on a
database object to enforce security by using Grant and Revoke command. Based on the
following authorization requirements, write the correct SQL command to fulfill the stated
requirements.
a) Give DELETE, INSERT, SELECT, and UPDATE privileges on the table BONUS to the user
Michael.
GRANT ALL ON bonus TO Michael; [2 marks]
b) Give SELECT and UPDATE privileges on the view REPORTS to all users by granting the
privileges to the role PUBLIC:
GRANT SELECT, UPDATE ON reports TO public; [2 marks]
c) Provide statement to withdraw the UPDATE privilege on REPORTS from all users:
REVOKE UPDATE ON reports FROM public; [2 marks]
18. What happened to the database when:
a) Transaction is committed?
A COMMIT statement ends the transaction successfully, making the database changes
permanent.
(1 mark)
b) Transaction is aborted?
A ROLLBACK statement aborts the transaction, backing out any changes made by the
transaction.
(1 mark)
19. What does ATOMICITY property of a transaction means?
Atomicity requires that all operations of a transaction be completed; if not, the
transaction is aborted.
(1 mark)
9
SECTION B (40 MARKS) 1. Read the following case study:
Chef’s Cafe is a food catering company that offers food delivery. The manager intends to
develop an order management system to enhance their food order and delivery process. The
food and beverages items are recognized by item_ID, item_name, description and unit_price.
A customer can request for price details online. Each order is submitted by one customer.
However, a customer may not submit any orders. The attributes for customer are identified as
customerID, customer_name, customer_address and contact_number. Note that any items sold
by the company may not be requested on any order, or may get requested on one or more
orders.
Order details are associated with order_ID and order_date, and an attribute associated with
each order and item is quantity, or the number of units requested. Customers are categorized
into two groups consist of regular and member customers. Points are given only to member
customers based on the total of each purchase. One customer could receive more than one
delivery depending on the orders or purchase of items.
Chef’s Cafe has over 50 employees. The attributes for employee are employee_ID, name,
employee_address, phone_number and role. Each order should produce one delivery, but any
sale or delivery produced by the company may not be requested on any order. Each delivery is
conducted by one employee. Delivery details include the delivery_ID, date, time, and address of
the delivery.
Draw an Enhanced Entity Relationship (EER) diagram for conceptual data model based on
requirements above. Make sure you clearly state the relation name, attribute (at least three),
multiplicity, primary key, specialization or generalization and participation constraints. Steps and
documentation for the diagram must strictly follow Unified Modelling Language (UML) notation.
State any assumptions necessary to support your design.
(10 marks)
11
2. Map the following Enhance Entity Relationship (EER) diagram into Database Relational Model.
(10 marks)
12
ANSWER:
1. Customer (CustomerNo, Name, Address, Phone) PRIMARY KEY CustomerNo
2. Quotation (QuoteNo, OrderDate, Description, Price, CustomerNo) PRIMARY KEY QouteNo Foreign Key CustomerNo REFERENCES Customer (CustomerNo)
3. Delivery (DeliveryNo, Date, Destination, Cost, StaffNo, RegNo) PRIMARY KEY DeliveryNo Foreign Key StaffNo REFERENCES Staff (StaffNo) Foreign Key RegNo REFERENCES Vehicle (RegNo)
4. Staff (staffNo, Name, Adress, PhoneNo, supervisorid) PRIMARY KEY StaffNo
5. Allocate (QuoteNo, DeliveryNo) PRIMARY KEY QuoteNo, DeliveryNo Foreign Key QuoteNo REFERENCES Quotation (QuoteNo) Foreign Key DeliveryNo REFERENCES Delivery (DeliveryNo)
6. Vehicle (RegNo, Description, PurchaseCost, PurchaseDate) PRIMARY KEY RegNo
7. TwoWheelVehicle(RegNo, Description, PurchaseCost, PurchaseDate, EngineCapacity)
PRIMARY KEY RegNo
8. FourWheelVehicle(RegNo, Description, PurchaseCost, PurchaseDate, MaxMass, MaxSpeed) PRIMARY KEY RegNo
13
3. Examine the following Customer History Form:
DarulAman Art Gallery Customer History Form
Item Purchase(s):
Artist Title Purchase Date Sales Price
04 – Latif Maulana The Forgotten Heritage IV 09/01/2015 7500.00
13 – Satria Ulung Seaside Villages 05/03/2015 1800.00
05 – Pak Said Portrait of Coconut Tree 02/07/2015 4550.00
13 – Satria Ulung Seaside Villages 07/10/2015 2800.00
The DarulAman Art Gallery wishes to maintain data on their customers, artists and paintings.
They may have several paintings by each artist in the gallery at one time. Each artist is given a
unique id and each painting is assigned a unique art code. Paintings may be bought and sold
several times. In other words, the gallery may sell a painting, then buy it back at a later date and
sell it to another customer.
Based on the form and business constraints given, perform the process of normalization from
UNF until 3NF.
CUSTOMER: Nur Amalina bt. Zainudin No. 3828 A, Lebuhraya Sultan Abd Halim, 05400, Alor Setar, Kedah.
Phone (012) 439-9374
14
Answer
UNF (Contain repeating group such as item purchase repeat for each customer)
custNo, custName, custAddr, custPhone, artistID, artistName, artCode, artTitle, purchaseDate,
price
INF (Remove Repeating Group and identify all keys)
custNo, custName, custAddr, custPhone, artistID, artistName, artCode, artTitle, purchaseDate,
price [2 mark]
Keys:
custNo
custNo, artCode, purchaseDate
artCode
[Remark: the key chosen for the repeating group is the piece of art itself (artCode), however
because a piece of art may be bought by a customer more than once, the purchase date was
added as part of the key to make the rows unique]
2NF (Remove partial dependency)
custNo custName, custAddr, custPhone
custNo, artCode, purchaseDate price
artCode artTitle, artistID, artistName
3NF (Remove transitive dependency, where artistName dependent with artisID)
custNo custName, custAddr, custPhone
custNo, artCode, purchaseDate price
artCode artTitle, artistID
artistID artistName
Thus, the final tables are:
CUSTOMER (custNo, custName, custAddr, custPhone)
CUSTOMER_ART (custNo, artCode, purchaseDate, price)
ART (artCode, artTitle, artistID)
ARTIST (artistID, artistName)
15
4. The followings are information in two database relations
Salesman (salesman_id, name, city, commission) Customer (customer_id, cust_name, city, salesman_id, purch_amount)
Write SQL command to perform the following:
a) List commission for all salesman, arranged in descending order of commission.
(2 marks)
SELECT salesman_id, name, city, commission
FROM Salesman
ORDER BY commission DESC;
b) Calculate Average commission of a salesman.
(2 marks)
SELECT AVG (commission)
FROM salesman;
c) Compute Highest purchase amount for each customer according to their city.
(2 marks)
SELECT MAX (purch_amount)
FROM CUSTOMERS
GROUP BY city;
d) List Customers’ name and salesmen’s name who lives in the same city.
(4 marks)
SELECT Customer.cust_name, Salesman.name, Salesman.city
FROM Salesman, Customer
WHERE Salesman.city = Customer.city;
END OF QUESTIONS