You are on page 1of 7

8 Databases

Activity 7
9. (a) 8,4
(b) SELECT * FROM members ORDER BY join_date DESC;

10. (a) 5
(c) SELECT * FROM members WHERE last_name IN("Wu",
"Fan") ORDER BY join_date;

11. (a) Display the records for members whose last name is ‘Wu’.
(b) Display the records for members whose identity number is greater than 5 in
the order of their last names.
(c) Display the last name, the first name and height for all members.
(d) Display the records for members whose first name starts with ‘B’.
(e) Display the total numbers of members.

12. (a) SELECT avg(height) FROM members;


(b) SELECT * FROM members WHERE left(phone_no, 3) =
"932";
(c) SELECT * FROM members WHERE join_date BETWEEN
"15/09/2009" AND "15/10/2009";

Extended Activity
2.

© Pearson Education Asia Limited 2009 NSS ICT Compulsory Textbook Answers
© Pearson Education Asia Limited 2009 NSS ICT Compulsory Textbook Answers
Concept Map
1. E
2. C
3. F
4. A
5. B
6. D

Concept Checker
1. T
2. T
3. F
4. F
5. F

Multiple Choice Questions


1. C
2. A
3. B
4. D
5. D
6. C
7. D

Short Questions
1. In the past, a ‘manual filing system’ (a card file or a filing cabinet system) was
used to store data. The problems of using a manual filing system are that only
one person could look at a file at a time, people would have to move to the place
where the data is stored, and it is much more difficult and slower in searching
and sorting files. (1) Now, using a DBMS, we can store, search and sort data
quickly and accurately. (1)
However, the disadvantages of computerized databases are that it requires cost
for training staff, (1) and there are security concerns about databases on
networks. (1)

2. The database system needs to be:


• able to find who bought the most among his customers;
• able to find who owes him money;

© Pearson Education Asia Limited 2009 NSS ICT Compulsory Textbook Answers
• able to specify a location/district and then display all the customers’
information in that location;
• able to print a price list of frozen foods;
• very easy to use; and
• password protected.
(any five × 1)

3. An application of database in supermarket is that a scanner reads the bar code on


a product at the point-of-sale terminal. (1) The bar code will be turned to the
record number of the product in the database of the supermarket. (1) The
database begins searching by using this number. (1)
A data is then returned from the database and it may consist of the name and the
price of the product. These data will be used to calculate the amount to be paid in
the transaction. Finally, the products’ names and prices will be printed on the
receipt for the customer. (1)

4.
Database object Function
Table Storing data
Query Searching, sorting, collecting and manipulating data
Form Producing customized user interfaces for the database system
Report Producing customized reports for printing on paper
Macro Performing simple automated operations
Module Performing more complex automated operations
(Correct function for each object × 1)

5. (a) Staff ID numbers are in the range from 0000 to 9999.


The maximum number of staff ID numbers is 10000. (1)
(b) Date of birth / job title / department (any two × 1)
(c) SELECT name, salary FROM staff WHERE salary <= 5000
ORDER BY salary;
(Correct SELECT × 1, correct FROM and WHERE clauses × 1, correct
ORDER BY × 1)

Long Questions
1. (a) six (1)
data type (1)

© Pearson Education Asia Limited 2009 NSS ICT Compulsory Textbook Answers
description (1)
(b) (i) 50 (1)
(ii) This will perform a field presence check so that users must enter a
name for the field. (1)
(c)
Option Value changed to Purpose
Validation >0 Implement a range check to
Rule ensure the number entered is
greater than 0. (1)
Required Yes Perform a field presence check
to ensure a number is entered.
(1)

(d)
Option Value changed to Purpose
Default Value $1,000 As most students will have paid
$1,000, it helps avoid typing the
value and set this as the default
value. (1)
Validation Between 500 and Perform a range check to ensure
Rule 2,000 that the amount paid is between
500 and 2,000. (1)
Validation Text Incorrect data This is the text which will
entered into the appear when data fails to pass
‘paid’ field the validation rule. (1)

(e) A primary key is a field which is unique for identifying every record from
each other. (1)
(f) Because more than one student may have the same name. (1)

2. (a)
Field name Data type Field length
mem_id numeric 4
first_name text 20
last_name text 20
street text 50
district text 20

© Pearson Education Asia Limited 2009 NSS ICT Compulsory Textbook Answers
zone text 2
tel_no numeric 8
(each correct pair of data type and field length × 1)
(b)
Field name Data type Field length
class_code text 3
subject text 50
teacher text 20
level text 3
class_size numeric 2
(each correct pair of data type and field length × 1)

3. (a) The field ‘age’ should not be used (1) because its value would be changed
year by year. (1) Thus, a lot of updates have to be made on this field for
every record. (1) Instead, the date of birth of the students, data which is not
changed usually, can be used as a field to replace ‘age’. (1)
(b) Some fields may be empty in value (1) which is a waste of disk storage
space. (1) Also, it is a poor design with the following two reasons:
• If a student is studying six courses, this cannot be represented in the
table. (1)
• If a student is only studying one course, then four fields are left empty
and this is a considerable waste of space. (1)
(c) The field ‘courses_taken’ (1) stored more than one value. (1) A field should
be designed to contain only one value. (2)

4. (a) SELECT registration, make, model FROM cars; (1)


(b) SELECT * FROM cars WHERE sunroof = "No"; (1)
(c) SELECT registration, make, price FROM cars WHERE
make = "Ford" AND price < 250000; (1)
(d) SELECT registration, sunroof, mileage FROM cars
WHERE sunroof = "Yes" ORDER BY mileage; (1)
(e) SELECT make, model, colour, engine_size FROM cars
WHERE colour = "Red" or colour = "Blue" ORDER BY
engine_size DESC; (1)
(f) SELECT registration, model, price FROM cars ORDER
BY make, model; (1)

© Pearson Education Asia Limited 2009 NSS ICT Compulsory Textbook Answers
(g) SELECT * FROM cars WHERE price BETWEEN 200000 AND
400000; (1)
(h) SELECT count(*) FROM cars WHERE sunroof = "No"; (1)
(i) SELECT make, MAX(engine_size) FROM cars GROUP BY
make; (1)
(j) SELECT make, AVG(price) FROM cars GROUP BY make; (1)
(k) SELECT MAX(price) FROM cars; (1)
(l) SELECT make, model, price*1.1 AS new_price FROM
cars; (1)

© Pearson Education Asia Limited 2009 NSS ICT Compulsory Textbook Answers

You might also like