You are on page 1of 28

Chapter 8 Databases

Multiple Choice Questions

P08M001
Which of the following statements is not correct?
A. The data type of each field must be considered when designing a database.
B. The name of each field must be unique.
C. The key field of a table can only contain one field.
D. The data in a key field is unique to a specific record.
Answer
C

P08M002
A database table stores the customer information of a mobile phone service provider. Which
of the following fields can be a key field of the table?
A. Customer name
B. Cell phone number
C. Service plan
D. Fee
Answer
B

P08M003
Which of the following objects in Microsoft Access is used to store data?
A. Form
B. Report
C. Table
D. Module
Answer
C

P08M004
Which of the following can be used to display the structure of a table in Microsoft Access?
A. Datasheet View
B. Design View
C. Form
D. Report
© Pearson Education Asia Limited 2009 1 NSS ICT Compulsory Question Bank
Answer
B

P08M005
A database table stores the employee information of a company. The structure of the table is
shown as below.
Field name Data type
Name Text
Hong Kong Identity Card number Number
Date of birth Date
Phone number Text
Which field may have a wrong data type?
A. Name
B. Hong Kong Identity Card number
C. Date of birth
D. Phone number
Answer
B

P08M006
A database table contains a key field with the name ‘record_ID’. Which of the following
data type is most probably not appropriate for this field?
A. Text
B. Number
C. AutoNumber
D. Date
Answer
D

P08M007
Reports created by a database are used to _________________________________.
A. store data
B. manipulate data with an attractive and user-friendly interface
C. present data in a professional layout and often contain summarized information
D. perform an action on a table
Answer
C

© Pearson Education Asia Limited 2009 2 NSS ICT Compulsory Question Bank
P08M008
Which of the following file formats can be generated by Microsoft Access?
A. PSD
B. MP3
C. BAT
D. ACCDB
Answer
D

P08M009
Which of the following is not a database object in Microsoft Access?
A. Form
B. Filtering
C. Query
D. Table
Answer
B

P08M010
Fill in the blank to complete an SQL statement:
SELECT age, COUNT(*) FROM table1 ________ age;
A. WHERE
B. ORDER
C. GROUP BY
D. HAVING
Answer
B

P08M011
The following shows the result of a query:
Name District
Amy Eastern
Tim Eastern
Wallace Wan Chai
Zoe Sai Kung
Fill in the blank below to complete a query which may generate the above result.
SELECT name, district FROM table1 ___________________;
A. ORDER BY name

© Pearson Education Asia Limited 2009 3 NSS ICT Compulsory Question Bank
B. ORDER BY district
C. GROUP BY district
D. WHERE district in ("Eastern","Wan Chai")
Answer
A

P08M012
The following database table named ‘mark’ stores examination marks of students.
name student_id chinese_mark english_mark maths_mark
Mary 3A11 56 95 100
Joan 3A12 78 98 99
Chris 3A13 45 80 67
Ken 3A14 79 77 80
Carol 3A15 88 79 53
Louis 3A16 76 94 46
How many records will be returned for the query below?
SELECT * FROM mark WHERE chinese_mark + english_mark +
maths_mark > 260;
A. 0
B. 1
C. 2
D. 3
Answer
B

P08M013
The following shows the data in the database table ‘student’:
name class mark
David 3A 98
Peter 3B 67
James 3B 77
Ann 3A 60
Joice 3A 87
Tony 3B 90
Raymond 3A 86

What will be the output of the following query?


SELECT COUNT(*) FROM student WHERE class = "3A" and marks >

© Pearson Education Asia Limited 2009 4 NSS ICT Compulsory Question Bank
80;
A. 1
B. 2
C. 3
D. 4
Answer
C

P08M014
A database table named ‘student’ contains the information of students’ test marks where each
record has three fields: ‘name’, ‘class’ and ‘test_mark’. Which of the following query counts
the number of students with marks lower than 50 in each class?
A. SELECT class, Max(test_mark) FROM student GROUP BY class;
B. SELECT COUNT(*) FROM student WHERE test_mark < 50;
C. SELECT class, COUNT(*) FROM student WHERE test_mark < 50 and
class = "3A";
D. SELECT class, COUNT(*) FROM student WHERE test_mark < 50
GROUP BY class;
Answer
D

P08M015
The following shows the output of a query from a database table named ‘members’.

name height blood_type


Billy 150 O
Joey 150 O
Zoe 150 O
Which of the following query may generate the above result?
A. SELECT * FROM members WHERE height > 150;
B. SELECT name, height, blood_type FROM members;
C. SELECT name FROM members WHERE height > 140 and height <
180;
D. SELECT name FROM members WHERE height = 140 and blood_type =
"O";
Answer
B

© Pearson Education Asia Limited 2009 5 NSS ICT Compulsory Question Bank
P08M016
In database software, SQL can be used to ________________.
A. create reports
B. design database tables
C. link several tables together
D. create queries
Answer
D

P08M017
Which of the following statements about a database is incorrect?
A. A database includes tables, forms, presentations and reports.
B. A database is used to store and manipulate a large amount of data.
C. Users can locate specific data through the ‘Find’ function of a database.
D. Users can organize the records of a database table in a particular order.
Answer
A

P08M018
Which of the following is a feature of a database?
A. Spell checking
B. Tabular reports
C. Mail merge
D. Find and replace text
Answer
B

P08M019
Which of the following is a method of data processing?
(1) Searching
(2) Sorting
(3) Merging
A. (1) only
B. (3) only
C. (1) and (2) only
D. (1), (2) and (3)
Answer
D

© Pearson Education Asia Limited 2009 6 NSS ICT Compulsory Question Bank
P08M020
Which of the following statements about a key field is correct?
(1) The values in a key field should be unique.
(2) A key field should not be empty.
(3) A key field should contain numbers.
A. (2) only
B. (1) and (2) only
C. (1) and (3) only
D. (1), (2) and (3)
Answer
B

P08M021
Which of the following fields is most suitable for being a key field in a database table?
A. Telephone number
B. Gender
C. Membership card identity number
D. Name
Answer
C

Short Questions

P08S001
(a) Suggest two advantages of the computerized database over the manual filing system.
(2 marks)
(b) State one database application in a school.
(1 mark)
(c) Complete the data hierarchy of a database in descending order with record, field and
table.
database > X > Y > Z
(3 marks)
Answer
(a) It saves the office space by storing data digitally. (1)
Data can be effectively accessed and reused. (1)
(b) Web-based School Administration and Management System (WebSAMS) (1)
(or any reasonable answer)
(c) X: table (1)
© Pearson Education Asia Limited 2009 7 NSS ICT Compulsory Question Bank
Y: record (1)
Z: field (1)

P08S002
(a) State the difference between a form and a report in Microsoft Access.
(2 marks)
(b) (i) Name one tool in Microsoft Access which can be used to create forms.
(1 mark)
(ii) Name one tool in Microsoft Access which can be used to create reports.
(1 mark)
(c) Give two examples of basic layouts of reports.
(2 marks)

Answer
(a) A form is the interface which allows users to manipulate and view data (1) while a report
is mainly used to present data. (1)
(b) (i) Form Wizard (1)
(ii) Report Wizard (1)
(c) Tabular layout (1) and stacked layout (1)

P08S003
(a) (i) State the function of filtering provided by a database.
(1 mark)
(ii) State the function of queries provided by a database.
(1 mark)
(iii) State one difference between querying and filtering.
(1 mark)
(b) State three methods to create a query in Microsoft Access.
(3 marks)
Answer
(a) (i) Filtering is used to extract a subset of the records in the table according to specified
criteria. (1)
(ii) Queries are used to retrieve data from one or more tables that meets specified
criteria. (1)
(iii) Filtering can only be applied to one table each time while querying can be applied to
more than one table. (1)
(b) Query Wizard (1), Design View (1) and SQL View (1)

© Pearson Education Asia Limited 2009 8 NSS ICT Compulsory Question Bank
P08S004
A database table named ‘student’ stores the students’ records of a school.
(a) Complete the data structure of the ‘student’ table as shown below.
Field name Data type
name Text
date_of_birth (i)
class (ii)
student_ID (iii)
(3 marks)
(b) Which field can be the key field?
(1 mark)
(c) Write an SQL statement to display the records of all the students in class ‘2B’.
(2 mark)
Answer
(a) (i) Date (1)
(ii) Text (1)
(iii) Text (1)
(b) student_ID (1)
(c) SELECT * from student WHERE class = "2B"; (2)

P08S005
(a) Suggest the data type for storing each of the following data in Microsoft Access:
(i) A unique number which is generated automatically
(1 mark)
(ii) A long text with length up to 65,530 characters
(1 mark)
(iii) Currencies
(1 mark)
(b) What is the function of input mask?
(1 mark)
(c) (i) State the keyword in SQL statements for sorting the result records.
(1 mark)
(ii) State the keyword in SQL statements for specifying the filtering criteria.
(1 mark)
Answer
(a) (i) AutoNumber (1)
(ii) Memo (1)

© Pearson Education Asia Limited 2009 9 NSS ICT Compulsory Question Bank
(iii) Currency (1)
(b) Input mask helps prevent users from inputting invalid data. (1)
(c) (i) GROUP BY (1)
(ii) WHERE (1)

P08S006
A database table named ‘staff’ contains the information of all the staff in a company. Each
record contains the fields ‘name’, ‘staff_id’, ‘department’, ‘position’, ‘salary’, ‘gender’ and
‘join_date’.
(a) Which field can be the key field?
(1 mark)
(b) Write an SQL statement to display the names of all staff in the ‘IT’ department.
(1 mark)
(c) If ‘staff_id’ is a number with 6 digits. What is the maximum number of staff in this
company?
(1 mark)
(d) State the meaning of the following SQL statements.
(i) SELECT department, COUNT(*) FROM Staff GROUP BY
department;
(1 mark )
(ii) SELECT department, COUNT(*) FROM Staff WHERE gender =
"Male" GROUP BY department;
(2 marks)
Answer
(a) ‘staff_id’ (1)
(b) SELECT name FROM Staff WHERE department = "IT"; (1)
(c) 999999 (1)
(d) (i) It shows the number of staff in each department. (1)
(ii) It shows the number of the male staff in each department. (2)

P08S007
(a) State two methods of editing the structure of a table in Microsoft Access. Which of them
allows users to modify the data type of a field?
(3 marks)
(b) State two table templates in Microsoft Access.
(2 marks)
(c) Jane wants to create an address book for her friends. Suggest one table template for her.
(1 mark)
© Pearson Education Asia Limited 2009 10 NSS ICT Compulsory Question Bank
Answer
(a) Datasheet View (1) and Design View (1)
Design View (1)
(b) Contacts / tasks / issues (any two × 1)
(c) Contacts (1)

P08S008
Fill in the following table which is about database objects in Microsoft Access.
Database object Description
(i) Store data in form of rows and columns.
Form (ii)
Report (iii)
Query (iv)
(v) Simple programs used to automate certain tasks
(vi) Programs that contain data management logics defined by users
(6 marks)
Answer
(i) Table (1)
(ii) Provide an interface for manipulating and displaying data. (1)
(iii) Present data and summarized information in a professional and easy-to-read layout. (1)
(iv) Perform an action on a table. (1)
(v) Marco (1)
(vi) Module (1)

P08S009
Ken works in a hospital and is responsible for recording the data of the patients in a computer.
The following table is created by Ken:

PatientID Name TelNumber HKID DOB Sex

16233 Choi Chi Kong 98658951 A773627(7) 7/8/1939 M

18523 Lo King Wah 23859753 D760255(4) 5/9/1965 M

18699 Or Sau Wan 65894563 K716174(8) 20/6/1976 F

19658 Wong Wing Yin 28695324 E405407(9) 23/4/1968 F

(a) How many records are there in the table?


(1 mark)
(b) How many fields are there in the table? Write down the field names.

© Pearson Education Asia Limited 2009 11 NSS ICT Compulsory Question Bank
(3 marks)
(c) Suggest one key field for the table.
(1 mark)
(d) It is not advisable to use ‘HKID’ as a key field for the table. Give one reason.
(1 mark)
Answer
(a) 4 (1)
(b) 6 (1)

‘PatientID’, ‘Name’, ‘TelNumber’, ‘HKID’, ‘DOB’ and ‘Sex’ (2)

(c) ‘PatientID’ (2)

(d) Security purpose and patients’ privacy (1)

P08S010
(a) Use a simple sentence to explain the term ‘merging’.
(1 mark)
(b) Merge the following tables.
(3 marks)
Name Hobby Weight
Jim Swimming 49
Lilly Eating 60
Peter Skiing 66

Name Hobby Weight


Danny Watching TV 58
Joyce Swimming 49
Judy Playing football 53
Nancy Sleeping 70
Wing Reading 56

(c) Is ‘Hobby’ suitable to be the key field in the table? Explain why briefly.
(2 marks)
Answer
(a) Merging is combination process of two sets of data into one. (1)
(b)
Name Hobby Weight
Danny Watching TV 58
Jim Swimming 49

© Pearson Education Asia Limited 2009 12 NSS ICT Compulsory Question Bank
Joyce Swimming 49
Judy Playing football 53
Lilly Eating 60
Nancy Sleeping 70
Peter Skiing 66
Wing Reading 56
(3)

(c) ‘Hobby’ is not suitable to be the key field, (1) because there might be more than one
people have the same hobby. (1)

P08S011
Most libraries use database management systems to store data.

(a) State one advantage of using a database management system in libraries.

(1 mark)

(b) State one type of application software for creating a database management system.
(1 mark)
Consider the following structures of two database tables:
Table name Field name
BOOK_INFO BOOKNAME
ISBN
AUTHOR
PUBLISHER

Table name Field name


ORDER BOOKNAME
ISBN
QUANTITY
PRICE
SUPPLIER
(c) Suggest one key field of the ‘BOOK_INFO’ table. Explain your answer briefly.
(2 marks)
(d) Which field is used to link the above tables?
(1 mark)
(e) A database management system can generate reports. What elements can be used to make
reports more readable and attractive?
(1 mark)

© Pearson Education Asia Limited 2009 13 NSS ICT Compulsory Question Bank
Answer
(a) A DBMS allows records to be easily sorted, searched, inserted, deleted and updated. (1)
(b) Microsoft Access (1) (or any reasonable answer)
(c) ‘ISBN’ (1)
The ISBN of each book is unique. (1)
(d) ‘ISBN’ (1)

(e) Eye-catching titles, charts and graphics etc. (1)

Long Questions

P08L001
Peter, who is a programmer, has designed a database for a university. It stores the information
of the students including their personal information and course marks. The structure of the
‘Student’ table is shown as below:
Field name Data type Field length
Student_name Text 30
Student_ID Text 8
Address Text 60
Class Text 2
Gender Text 1
Course_name Text 20
Course_ID Text 8
Assessment_mark Number Integer
Exam_mark Number Integer
‘Student’ table
(a) Which field(s) could be the primary key of the ‘Student’ table?
(2 marks)
(b) There are 4,000 students in the university and each student is required to take at least 30
and at most 60 courses. Calculate the maximum storage space (in bytes) of the ‘Student’
table and show the steps. You can suppose each integer takes 4 bytes.
(3 marks)
Another programmer, Jason suggests splitting the original ‘Student’ table into two tables
namely ‘StudentInfo’ and ‘Course’. The structure of the two tables is shown as below:
Field name Data type Field length
Student_name Text 30
Student_ID Text 8

© Pearson Education Asia Limited 2009 14 NSS ICT Compulsory Question Bank
Address Text 60
Class Text 2
Gender Text 1
Course_ID Text 8
‘StudentInfo’ table

Field name Data type Field length


Student_ID Text 8
Course_name Text 20
Course_ID Text 8
Assessment_mark Number Integer
Exam_mark Number Integer
‘Course’ table

(c) (i) Using the information mentioned in part (b), calculate the maximum storage space
(in bytes) of the tables ‘StudentInfo’ and ‘Course’ respectively.
(2 marks)
(ii) Using the answer in part (c) (i), calculate the maximum total storage space (in bytes)
of the tables using Jason’s method.
(1 mark)
(d) Which method requires less storage space, Peter’s or Jason’s? Why is a big difference
between their storage space requirements? Which method is better?
(4 marks)
Answer
(a) Student_ID (1) and Course_ID (1)
(b) There are at most:
4,000 × 60 = 240,000 records (1)
Each record contains at most:
30 + 8 + 60 + 2 + 1 + 20 + 8 + 4 + 4 = 137 bytes (1)
The maximum table storage space:
240,000 × 137 = 32,880,000 bytes (1)
(c) (i) The ‘StudentInfo’ table: (1)
Each record contains at most:
30 + 8 + 60 + 2 + 1 + 8 = 109 bytes
The maximum table storage space:
109 × 4,000 = 436,000 bytes
The ‘Course’ table: (1)
Each record contains at most:

© Pearson Education Asia Limited 2009 15 NSS ICT Compulsory Question Bank
8 + 20 + 8 + 4 + 4 = 44 bytes
The maximum storage space:
44 × (4,000 × 60) = 10,560,000 bytes
(ii) 436,000 + 10,560,000 = 10,996,000 bytes (1)
(d) Jason’s method requires less storage space. (1)
In Peter’s method, a lot of duplicate students’ information is stored. (2)
Jason’s method is better. (1)

P08L002
Ben designs a database table named ‘Transaction’ to store transaction records of a
supermarket. The table structure is shown as follows:

Field name Data type Description


item_name X The name of the item sold in the supermarket, e.g.
Sunkist Orange
item_id Text The code of the item
price Y The price of the item
transaction_time Z The transaction time
(a) Suggest the data types X to Z.
(3 marks)
(b) What problem may be encountered if Ben assigns ‘item_name’ as the key field?
(3 marks)
(c) There are three cashiers in this supermarket. Can the ‘transaction_time’ field be the key
field? Explain your answer briefly.
(2 marks)
(d) Write an SQL statement which returns all the records with ‘item_name’ as ‘Sunkist
Orange’.
(2 marks)
(e) Write an SQL statement which returns the total number of all items sold.
(2 marks)

Answer
(a) X: Text (1)
Y: Number (1)
Z: Date / time (1)
(b) The data in the key field should be unique for each record (1) while different transactions
may involve the same item and share the same item name. (1) Hence, there will probably
be many records with the same ‘item_name’ in the ‘Transaction’ table. (1)

© Pearson Education Asia Limited 2009 16 NSS ICT Compulsory Question Bank
(c) No. (1) Since there are three cashiers, it is possible to have two items with the same name
sold at the same time at different cashiers. (1)
(d) SELECT * FROM Transaction WHERE item_name = "Sunkist
Orange"; (2)
(e) SELECT COUNT(*) FROM Transaction; (2)

P08L003
A database table named ‘Labour_Earning’ stores the answers of the respondents of a Labour
Earnings Survey (LES) of a city. The following shows a section of the table.
questionnaire_ID age gender industry earning
10001 27 F Construction 20000
10002 32 M Transport 15000
10003 54 M Construction 30000
… … … … ...

(a) Write an SQL statement to return the number of respondents who earn more than 15000.
(2 marks)
(b) Write an SQL statement to return the records of those respondents whose industry and
gender are ‘Transport’ and ‘F’ respectively.
(2 marks)
(c) Write an SQL statement to return the average earnings for each industry.
(2 marks)
(d) Write an SQL statement which filters out the records of male respondents, and then
returns the average earnings of each industry from the rest of records.
(2 marks)
(e) Write an SQL statement which returns the average earnings of respondents who are older
than 30 and younger than 40.
(2 marks)
(f) Write an SQL which returns the maximum earnings of each industry, and sort the results
according to the names of the industries.
(2 marks)
Answer
(a) SELECT COUNT(*) FROM Labour_Earning WHERE earning > 15000;
(2)
(b) SELECT * FROM Labour_Earning WHERE industry = "Transport"
and gender = "F"; (2)
(c) SELECT industry, AVG(earning) FROM Labour_Earning GROUP BY

© Pearson Education Asia Limited 2009 17 NSS ICT Compulsory Question Bank
industry; (2)
(d) SELECT industry, AVG(earning) FROM Labour_Earning WHERE
gender = "F" GROUP BY industry; (2)
(e) SELECT AVG(earning) FROM Labour_Earning WHERE age > 30 and
age < 40; (2)
(f) SELECT industry, MAX(earning) FROM Labour_Earning GROUP BY
industry ORDER BY industry; (2)

P08L004
Martin is a founder of an organization who teaches mathematics and also organizes the public
mathematics exam. Each person can take the exam one or more times, but on the same day he
or she cannot take the exam more than once. We call a person who takes the exam as a
candidate. Each person is assigned with a distinct ‘candidate_id’, i.e. a person who takes the
exam more than one time will still have one ‘candidate_id’. In the exam, each candidate will
take 3 papers, and the total mark of the exam is calculated by summing the marks of the three
papers.

Martin has designed two database tables namely ‘Candidate_Info’ and ‘Exam_Results’ to
store the candidate information and the exam results. The ‘Candidate_Info’ table contains the
fields ‘candidate_name’, ‘candidate_id’, ‘date_of_birth’, ‘gender’ and ‘address’. The
‘Exam_Results’ table contains the fields ‘candidate_id’, ‘exam_date’, ‘paper1_mark’,
‘paper2_mark’, ‘paper3_mark’ and ‘total_mark’.

(a) Suggest the key fields for the ‘Candidate_Info’ and ‘Exam_Results’ tables respectively.
(4 marks)
(b) What is the function of the following SQL statement?
SELECT COUNT(*) FROM Exam_Results WHERE total_mark > 90;
(2 marks)
(c) Write an SQL statement to show the total number of female candidates.
(2 marks)
(d) Write an SQL statement to show the average of total marks among all the exams taken for
each candidate respectively. (Hint: You can use the ‘candidate_id’ field to represent the
candidate.)
(2 marks)
(e) Write an SQL statement to show the number of candidates whose total marks are over 90
on each exam date.
(2 marks)

© Pearson Education Asia Limited 2009 18 NSS ICT Compulsory Question Bank
Answer
(a) The key field of ‘Candidate_Info’: ‘candidate_id’ (2)
The key fields of ‘Exam_Results’: ‘candidate_id’ (1) and ‘exam_date’ (1)
(b) Return the number of times that the candidates get a total mark over 90. (2) (Note:
Answers like ‘return the number of candidates whose total mark is over 90’ is not
acceptable.)
(c) SELECT COUNT(*) FROM Candidate_Info WHERE gender = "F"; (2)
(d) SELECT candidate_id, AVG(total_mark) from Exam_Results GROUP
BY candidate_id; (2)
(e) SELECT exam_date, COUNT(*) FROM exam_results WHERE
total_mark > 90 GROUP BY Exam_Date; (2)

P08L005
A database table ‘Books’ contains the information of all the books in a library. Each record
contains the following fields: ‘book_title’, ‘book_id’, ‘author’, ‘category’ and ‘status’. Write
an SQL statement for each of the following query.
(a) Return the records which are sorted by ‘author’.
(1 mark)
(b) Find all the books which are written by ‘Einstein’.
(1 mark)
(c) Find all the books with title ‘Discrete Mathematics’ whose status is ‘available’.
(2 mark)
(d) Count the number of books whose status is ‘available’.
(2 mark)
(e) Count the number of books whose category is ‘Computer’.
(2 mark)
(f) Show the number of books for each type of category.
(2 mark)
(g) Show the number of books for each author.
(2 mark)

Answer
(a) SELECT * FROM Books ORDER BY author; (1)
(b) SELECT * FROM Books WHERE author = "Einstein"; (1)
(c) SELECT * FROM Books WHERE book_title = "Discrete
Mathematics" and status = "available"; (2)
(d) SELECT COUNT(*) FROM Books WHERE status = "available"; (2)
(e) SELECT COUNT(*) FROM Books WHERE category = "Computer"; (2)
© Pearson Education Asia Limited 2009 19 NSS ICT Compulsory Question Bank
(f) SELECT category, COUNT(*) FROM Books GROUP BY category; (2)
(g) SELECT author, COUNT(*) FROM Books GROUP BY author; (2)

P08L006
The following shows a database table ‘Staff’ which stores the information of staff in a
company.
name staff_ID salary position gender
David 110 30000 Manager M
Tim 202 20000 Executive Officer M
Vivian 330 10000 Clerk F
Brian 414 10000 Clerk M
Gloria 335 15000 Secretary F
Ray 346 15000 Senior Clerk M
What will be the output for the following SQL statements?
(a) SELECT staff_ID FROM Staff WHERE name = "Tim";
(1 mark)
(b) SELECT name FROM Staff WHERE position = "Manager";
(1 mark)
(c) SELECT name FROM Staff WHERE salary > 15000;
(2 marks)
(d) SELECT * FROM Staff WHERE gender = "F";
(2 marks)
(e) SELECT COUNT(*) FROM Staff WHERE salary < 12000;
(2 marks)
(f) SELECT position, MAX(salary) FROM Staff WHERE gender = "M"
GROUP BY position;
(2 marks)
(g) SELECT gender, COUNT(*) FROM Staff WHERE salary > 10000
GROUP BY gender;
(2 marks)

Answer
(a) 202 (1)
(b) David (1)
(c)
name
David

© Pearson Education Asia Limited 2009 20 NSS ICT Compulsory Question Bank
Tim
(2)
(d)
name staff_ID salary position gender
Vivian 330 $10000 Clerk F
Gloria 335 $15000 Secretary F
(2)
(e) 2 (2)
(f)
position MAX(salary)
Manager 30000
Executive Officer 20000
Clerk 10000
Senior Clerk 15000
(2)
(g)
gender COUNT(*)
M 3
F 1
(2)

P08L007
The following shows a form. After completing the form and pressing the ‘Submit’ button, the
information in the form will be saved in a table called ‘Personal_Info’ in a database. If a user
enters a non-numeric data in the ‘Name’ field, the system pops up an error message
automatically.

(a) Suggest two methods of data control and describe one application for each method based

© Pearson Education Asia Limited 2009 21 NSS ICT Compulsory Question Bank
on the above scenario.
(6 marks)
(b) How many fields are there in the ‘Personal_Info’ table?
(1 mark)
(c) Briefly explain why using ‘Age’ as a field is not a suitable method and suggest one better
alternative.
(2 marks)
(d) Which field can be used as a key field?
(1 mark)
(e) State two necessary conditions for a field to be a key field.
(2 marks)
Answer
(a) ‧ Data verification (1)

Input the password twice in order to check whether the inputted data matches. (2)

‧ Data validation (1)

Check whether the inputted data is reasonable and valid. If the data inputted in the
‘Age’ field is not a number, the system pops up an error message. (2)

(b) 6 (‘Password’ and ‘Reset password’ occupy only a field.) (1)


(c) Ages change with time and frequent updates are needed. (1)
Use ‘Date of birth’ instead of ‘Age’. (1)
(d) Hong Kong Identity Card number (1)
(e) ‧ The content of each record in the field should be unique in the table. (1)
‧ The field should not be empty. (1)

P08L008
One credit card issuing company is attracting new customers. Interested customers have to fill
personal information in the application forms. The completed forms are collected and sent to
the central office every night. A data entry operator is responsible for entering customers’
information into the database of the company.

(a) Suggest two kinds of errors that may be brought about by


(i) customers;

(2 marks)
(ii) data entry operators.

(2 marks)
(b) Does the above procedure belong to batch processing or real-time processing? Explain
your answer briefly.

© Pearson Education Asia Limited 2009 22 NSS ICT Compulsory Question Bank
(2 marks)
(c) Suppose you were a manager of the company. Suggest one method that can reduce the
chance of data errors.
(2 marks)
(d) The personal information includes the applicant’s e-mail address. Refer to the e-mail
address, give one example of
(i) data validation method;

(2 marks)
(ii) data verification method.

(2 marks)
Answer

(a) (i) ‧ Customers do not provide some key information. (1)

‧ Customers provide wrong information. (1)

(ii) ‧ They may input incorrect data. (1)

‧ They swap data values accidentally. (1)

(b) Batch processing (1)

Collected data is not entered into the computer immediately. (1)

(c) Two operators enter the same application form separately and verify the data entered. (2)
(or any reasonable answer)

(d) (i) There should be no spaces in the e-mail address. ‘@’ symbol should be included
between the username and domain name. (2)
(ii) Send an e-mail to the applicant, and ask the applicant to reply the e-mail for
confirmation. (2)

P08L009
When an applicant applies for a job, an application form has to be filled before the interview.
The company would store the personal information of the successful applicants in a table
named ‘STAFF’. The structure of the table is shown as follows:

Field name Data type Field length Description

NAME Character 15 Name of the staff

DOB Date 8 Date of birth

SEX Character 1 Sex of the staff

STAFFID Character 6 Staff ID

© Pearson Education Asia Limited 2009 23 NSS ICT Compulsory Question Bank
ADDRESS Character 30 Home address of the staff

TELEPHONE Character 8 Contact number of the staff

DEPARTMENT Character 10 Department

GRADE Number 2 Grade (indicator of salary)

SALARY Number 8 Current salary

(a) Suggest one method of verification for verifying the data in the application form.
(1 mark)
(b) Suggest one validation check for checking a name.
(1 mark)
(c) Suggest one error that validation programs cannot detect.
(1 mark)
(d) State one field that we can use range check to validate.
(1 mark)
(e) Explain how we can change the data type of ‘SEX’ from character to number.
(1 mark)
(f) Explain why ‘TELEPHONE’ is not recommended to be set as the key field. Suggest one
key field for the ‘STAFF’ table.
(2 marks)
(g) Given that the salary of a staff is dependent on his / her grade, state one potential problem
of storing ‘SALARY’ in the ‘STAFF’ table.
(1 mark)
(h) Re-design the database structure to solve the problems in part (g). If the new design
includes more than one table, state the field which can link between the tables.
(4 marks)
Answer

(a) Double data entry / Input data twice by two people independently (any one × 1)

(b) Type check (1)

(c) If someone mistyped the name ‘Mandy’ as ‘Candy’, validation programs cannot detect
the error. (1) (or any reasonable answer)

(d) ‘DOB’ (1)

(e) We can use ‘1’ to represent male and ‘0’ to represent female. (1)

(f) ‘TELEPHONE’ may not be unique to each staff if there are family members in the same
company. (1) ‘STAFFID’ can be used as the key field. (1)

© Pearson Education Asia Limited 2009 24 NSS ICT Compulsory Question Bank
(g) The salary of a staff depends on his or her grade, and it may change from time to time.
Therefore, data inconsistency may arise. / Data redundancy may occur since the salary is
dependent on the grade. (any one × 1)

(h) Split the original table into two. One table stores the staff’s personal information, and the
other stores the information related to salary. (1)

Structure of the ‘STAFF’ table: (1)

Field name Data type Field length Description

NAME Character 15 Name of the staff

DOB Date 8 Date of birth

SEX Character 1 Sex of the staff

STAFFID Character 6 Staff ID

ADDRESS Character 30 Home address of the staff

TELEPHONE Character 8 Contact number of the staff

DEPARTMENT Character 10 Department

GRADE Number 2 Grade (indicator of salary)

Structure of the ‘SALARY’ table: (1)

Field name Data type Field length Description

GRADE Number 2 Grade (indicator of salary)

SALARY Number 8 Current salary

‘GRADE’ is the field which links the two tables. (1)

P08L010
The IT Club chairman uses the following table ‘MEMBER’ to store the information of
members. The structure of the table is shown as below:
Field name Data type Description
Name Character Name of the member
Class A Class of the member
Sex B Sex of the member
Phone C Contact number of the member
Post Character Post of the member

© Pearson Education Asia Limited 2009 25 NSS ICT Compulsory Question Bank
NumAct D Number of activities that the member has attended

(a) How many fields are there in the ‘MEMBER’ table?

(2 marks)

(b) Fill in the missing data types A to D.

(4 marks)

(c) What is the problem of choosing the ‘Name’ field as the key field?

(2 marks)

(d) Which field would you add to the ‘MEMBER’ table as the key field? Explain your
answer briefly.

(2 marks)

(e) What is the problem of including the ‘NumAct’ field in the ‘MEMBER’ table? Suggest
one method to solve the problem.

(2 marks)

Answer

(a) 6 (2)

(b) A: Character (1)

B: Character (1)

C: Character (1)
D: Number (1)

(c) There might be more than one student with the same name. (2)

(d) ‘MemberID’ (1)


It is unique for each record. (1)

(e) The number of activities that the member has attended may change from time to time.
(1)

Split the table into two. One table stores the member’s personal information, and the
other table stores the number of activities the member has attended. (1)

P08L011

© Pearson Education Asia Limited 2009 26 NSS ICT Compulsory Question Bank
Class 4A students recently formed a class committee to manage the general welfare of the
class. Two tables, namely ‘CLASSMATES and ‘COMMITTEE’, are kept by the secretary of
the class committee. The structures of the two tables are shown as follows:
Structure of the ‘CLASSMATES’ table:
Field Data type Field length
name
Name Character 25
StudentID Integer 2
Sex Character 1
Age Integer 2
Telephone Integer 8
Address Character 50

Structure of the ‘COMMITTEE’ table:


Field Data type Data length
name
Post Character 20
StudentID Integer 2

(a) Which field is not suitable to be used in the ‘CLASSMATES’ table? How can it be
improved?
(2 marks)
(b) State one field with inappropriate data type. How can it be changed?
(2 marks)
(c) Suggest one key field of ‘CLASSMATES’ and ‘COMMITTEE’ respectively.
(2 marks)
(d) In the ‘COMMITTEE’ table, state one disadvantage of changing the ‘StudentID’ field to
‘Name’.
(2 marks)
(e) If the ‘Telephone’ field in the ‘CLASSMATES’ table is added to the ‘COMMITTEE’
table as the third field, describe how inconsistent data may arise.
(2 marks)
(f) What problem may arise if the ‘StudentID’ field is changed to ‘HKID’, i.e. Hong Kong
Identity Card number?
(2 marks)

Answer
(a) ‘Age’ (1)
Use date of birth instead of age. (1)

© Pearson Education Asia Limited 2009 27 NSS ICT Compulsory Question Bank
(b) ‘Telephone’ (1)
It should be changed to character. (1)
(c) The key field of ‘CLASSMATES’: ‘StudentID’ (1)
The key field of ‘COMMITTEE’: ‘StudentID’ (1)
(d) There might be more than one person with the same name in a class. (2)
(e) If a telephone number is changed, the two tables have to be updated. If one of the tables
is not updated, inconsistent data may arise. (2)
(f) Security and privacy problem (2)

© Pearson Education Asia Limited 2009 28 NSS ICT Compulsory Question Bank

You might also like