0% found this document useful (0 votes)
16 views6 pages

1718 Sem 3

This document contains instructions and questions for an exam on database principles. It has 6 pages total including the cover page. There are 4 questions on the exam. Question 1 contains 7 parts asking students to write SQL statements to create tables, add/modify columns, set constraints, and create views. Question 2 contains 9 parts asking students to write SQL statements to insert/delete records, display data, perform aggregations and sorting. Students are instructed to answer all questions.

Uploaded by

anson232323
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

1718 Sem 3

This document contains instructions and questions for an exam on database principles. It has 6 pages total including the cover page. There are 4 questions on the exam. Question 1 contains 7 parts asking students to write SQL statements to create tables, add/modify columns, set constraints, and create views. Question 2 contains 9 parts asking students to write SQL statements to insert/delete records, display data, perform aggregations and sorting. Students are instructed to answer all questions.

Uploaded by

anson232323
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

© Vocational Training Council

IVE Information Technology

Information & Communications


Technology

Programme Board

Instructions:
(a) This paper has a total of SIX pages HIGHER DIPLOMA IN
including the covering page.
(b) This paper contains FOUR questions. SOFTWARE ENGINEERING
(IT114105)
(c) Answer ALL questions.
MOBILE APPLICATIONS DEVELOPMENT
Note: The result of this assessment will not be
(IT114112)
counted if you do not meet the minimum CLOUD AND DATA CENTRE ADMINISTRATION
attendance requirement (if any) (IT114115)
governed by the general academic
regulations of your programme/course
unless approval of the campus principal
has been granted.

MODULE TITLE:

DATABASE PRINCIPLES
MODULE CODE: ITP4903

SEMESTER THREE
MAIN EXAMINATION

18 July 2018
7:00 PM TO 9:00 PM (2 hours)
© Vocational Training Council

Information Technology Discipline Page 1 of 5


Course/Programme/Year: IT114105/1, IT114112/1, IT114115/1

This paper contains FOUR questions.


Answer ALL questions.

Q1 Given the following relations of the library system and the database schema with sample
data found in the Appendix on page 5:

CLIENT ( ClientNo, ClientName, Address, Phone, Age, Sex )


BOOK ( BookNo, BookName, AuthorName, Publisher )
BORROW ( ClientNo, BookNo, StartDate, Period, Fee )

Where the underlined attributes are the primary key attributes.

Assume that the tables CLIENT and BOOK had been created with the primary keys in the
database and given the following details of the BORROW table:

BORROW
Column Name Type: Length Null? Key(s)
(1) Composite primary key attribute
ClientNo Character: 4 No
(2) Foreign key, refers to CLIENT table
(1) Composite primary key attribute
BookNo Character: 5 No
(2) Foreign key, refers to BOOK table
StartDate Date No
Period Number: 2 No
Fee Number: 3

Write a SINGLE SQL statement for each of the following questions:

(a) Create the table BORROW using the above details with BORROW_pk, BORROW_fk1
and BORROW_fk2 as the constraint names for the primary key and the two foreign
keys respectively. [8 marks]

(b) Change the name of column Fee in table BORROW created in Q1(a) to BorrowFee.
[2 marks]

(c) Limit the column Period so that the input date must be between 0 and 10.
[2 marks]

(d) Add a new column named Reserved to the BOOK table to record one character ‘Y’ or
‘N’ for each record. The data type of the column Reserved is Character. [2 marks]

(e) Set a default value on column StartDate so that the start date of all borrowing is always
today’s date of the system. [2 marks]

(f) Create a view named PromoBook from the BOOK table that includes BookName and
Publisher attributes. [2 marks]

(g) Remove the tables CLIENT, BOOK and BORROW in a correct order. [2 marks]

Database Principles (ITP4903) Main Examination Semester 3 (2017/2018)


© Vocational Training Council

Information Technology Discipline Page 2 of 5


Course/Programme/Year: IT114105/1, IT114112/1, IT114115/1

Q2 Given the following relations of the library system and the database schema with sample
data found in the Appendix on page 5:

CLIENT ( ClientNo, ClientName, Address, Phone, Age, Sex )


BOOK ( BookNo, BookName, AuthorName, Publisher )
BORROW ( ClientNo, BookNo, StartDate, Period, Fee )

Where the underlined attributes are the primary key attributes.

Write SQL statement(s) for each of the following questions:

(a) Add a new record to Client table with the following information. [3 marks]
ClientNo ClientName Address Phone Age Sex
C005 Chan Tai Man 6/F, Happy Building, Shatin 91239123 18 M

(b) Remove the borrowing record of client number ‘C003’ with book number ‘T0212’.
[3 marks]

(c) Display all the ClientNo, ClientName and their Age in table CLIENT. [2 marks]

(d) Display the ClientName and Address for all the clients who live in ‘Shatin’. [3 marks]

(e) List the ClientName, number of book borrowing of all clients who have borrowed
more than one book. [6 marks]

(f) Show the BookNo and increase all fee by 10%, display the new fee with a heading
New_Fee.
[2 marks]

(g) List all information about the clients who did not provide their phone number from
CLIENT table. [2 marks]

(h) List the ClientName, BookName and Fee of all borrowing records made on 30 May
2018. Short the result by ClientName in ascending order. [6 marks]

(i) Modify the client record with client number ‘C004’ who changed his/her phone
number to ‘52665266’. [3 marks]

Database Principles (ITP4903) Main Examination Semester 3 (2017/2018)


© Vocational Training Council

Information Technology Discipline Page 3 of 5


Course/Programme/Year: IT114105/1, IT114112/1, IT114115/1

Q3 The table below shows the details of course record in a school.

Use the Course table below, answer part (a) and (b).

Table: Course
CourseNo CourseName DeptID Dept SID SName Result CourseAvg
IT001 Basic Programming IT Information 16002 Chan Tai Man 71 56
Technology 16003 Wong Wing Yu 54
16004 Au Tsz Fung 43
LA005 English LAN Language 16001 Ho Yu Tung 69 42
16004 Au Tsz Fung 15
LA020 Chinese LAN Language 16003 Wong Wing Yu 84 84
EN213 Introduction to ENG Engineering 16001 Ho Yu Tung 56 42.5
Electronic Circuit 16002 Chan Tai Man 53
16003 Wong Wing Yu 14
16004 Au Tsz Fung 47
BA522 Accounting BA Business 16002 Chan Tai Man 48 48

Where
CourseNo = Course Number, SID = Student ID,
CourseName = Course Name, SName = Student Name,
DeptID = Department ID, Result = Course Result,
Dept = Department Name, CourseAvg = Average Result of Course

Assumption:
1. Each course, department or student has a unique CourseNo, DeptID and SID respectively.
2. Each department runs one or more than one course.
3. The student can choose not taking any course or taking multiple courses at the same time.
4. Each course has at least one student.

a) Name and describe the THREE types of database anomalies that may happen in the above
Course table. [6 marks]

b) (i) Write down the unnormalized form (UNF) for the Course relation. [2 marks]

(ii) Normalize the Course relation to the third normal form (3NF). Show ALL your steps
from 1NF to 3NF by listing out all the relations in 1NF, 2NF and 3NF. Underline the
primary key attribute(s) for each relation in your answer. [12 marks]

(iii) Draw an entity relationship diagram to represent the normalized relations in 3NF of
your answer in Q3 (b)(ii) with the given assumptions. Make sure that all entities must
be labelled and all relationships must be drawn with the correct symbols. [10 marks]

Database Principles (ITP4903) Main Examination Semester 3 (2017/2018)


© Vocational Training Council

Information Technology Discipline Page 4 of 5


Course/Programme/Year: IT114105/1, IT114112/1, IT114115/1

Q4 Given the following relations of the online shop system of a trading company:

CUSTOMER ( CustomerNo, CustomerName, PhoneNo )


PRODUCT ( PNo, ProductType, Price )
ORDER (OrderNo, CustomerNo, PNo, Quantity )

Where the underlined attributes are the primary key attributes.


Assume a customer can have more than one order. Each order can only be placed by
one customer.

Sample Data of CUSTOMER table


CustomerNo CustomerName PhoneNo
C001 Chan Wan Wan 90229022
C002 Chow Tsz Hin 67216721
C003 Li Lei Sze 51115111

(a) (i) Define the meaning of Composite Primary Key and give ONE example in the
online shop relations. [3 marks]

(ii) Define the meaning of Foreign key and give ONE example in the online shop
relations. [2 marks]

(iii) Describe the meaning of Metadata. [2 marks]

(iv) Provide TWO examples of metadata of the PhoneNo in the CUSTOMER relation.
[2 marks]

(b) Describe the meaning of the following database terms and give a value for each of
them using the above sample data in the CUSTOMER relation.

(i) Attribute [2 marks]

(ii) Tuple [2 marks]

(c) (i) Describe how the Entity Integrity rule can be enforced in the CUSTOMER
relation. [2 marks]

(ii) Describe how the Referential Integrity rule can be enforced in the ORDER
relation. [2 marks]

(iii) Describe THREE advantages of using Database Management System. [3 marks]

***** END OF PAPER *****

Database Principles (ITP4903) Main Examination Semester 3 (2017/2018)


© Vocational Training Council

Information Technology Discipline Page 5 of 5


Course/Programme/Year: IT114105/1, IT114112/1, IT114115/1

APPENDIX

Database schema of the library system with sample data:

CLIENT ( ClientNo, ClientName, Address, Phone, Age, Sex )


BOOK ( BookNo, BookName, AuthorName, Publisher )
BORROW ( ClientNo, BookNo, StartDate, Period, Fee )

where
ClientNo = Client number, ClientName = Client name,
Address = Client’s address, Phone = Client’s telephone number,
Age = Client’s age, Sex = Client’s gender,
BookNo = Book number, BookName = Name of book,
AuthorName = Name of author, Publisher = Name of book publisher,
StartDate = The date of book borrowing, Period = Borrowing length.

Note: The primary key attributes are underlined.

CLIENT
ClientNo ClientName Address Phone Age Sex
C001 Peter Chan RM05, ABC Building, Pretty St, Shatin, HK 51110234 23 M
C002 Amy Yu 01K, Lan Han Rd 1, Chai Wan, HK 51231478 45 F
C003 Cherry Lau 401, Blk 2, Choi Yuen Estate, Shun Shui, HK 67875312 21 F
C004 Raymond Li 311, Blk 1, Choi Yuen Estate, Shun Shui, HK 67875312 34 M

BOOK
BookNo BookName AuthorName Publisher
H0003 Harry Potter J. K. Rowling ABC Printing
B0004 Blueprints Fernando Pizarro YY Ltd.
T0212 Thinkertoys Michael Michalko Sky Publishing
D0728 DRAGON GI JAZZ DRUM Youth Book Ltd.

BORROW
ClientNo BookNo StartDate Period Fee
C001 D0728 28-MAY-18 6 60
C003 T0212 30-MAY-18 5 50
C004 B0004 30-MAY-18 7 70
C004 H0003 31-MAY-18 9 90

***** END OF APPENDIX *****

Database Principles (ITP4903) Main Examination Semester 3 (2017/2018)

You might also like