HKTA Tang Hin Memorial Secondary School
S3 Chapter 5
ICT AND STEM
2024-2025
Database - Introduction to Database System
Chapter 5: Database - Introduction to Database System (Teacher Version)
1 What is a Database?
1.1 Database defined
A database is an organized collection of structured information, or data, typically stored electronically in a
computer system, enabling efficient storage and retrieval of data. A database is usually controlled by a
database management system (DBMS). Together, the data and the DBMS, along with the applications that
are associated with them, are referred to as a database system.
1.2 Real-Life Database Examples
1. Social Media Platforms
2. eCommerce Websites
3. Email Services
4. Airline Reservation Systems
5. Hotel Booking Systems
6. Healthcare Information Systems
1.3 Database management system
It is commonly used software that helps us organize and handle large amounts of data. Some of them
provide Graphical User Interface (GUI), with buttons and menus.
2 THMSS – S3 Stem and ICT
Chapter 5: Database - Introduction to Database System (Teacher Version)
2 Database Hierarchy
Inside a database, data is stored in Tables, which consist of many Records and each record consists number
of Fields.
3 THMSS – S3 Stem and ICT
Chapter 5: Database - Introduction to Database System (Teacher Version)
e.g. Refer to the following database table and answer the questions.
ENROLMENT
STUDENTID NAME COURSEID
S001 Ann C101
S001 Ann C305
S002 Banny C101
S003 Candy C205
S003 Candy C301
(a) How many fields are there in the above table?
(b) What is the name of the student with “STUDENTID” number “S001”? Which course(s) has / have
the student enrolled for?
2.1 Differences between a database and a spreadsheet
Databases and spreadsheets (such as Microsoft Excel) are both convenient ways to store information. The
primary differences between the two are:
Database Spreadsheet
Contain multiple tables Contain multiple worksheets
Each row is a record and each column is a field There is no restriction on what rows and
of every record columns represent
Values are stored in fields Values are stored in cells
Each field has a field name Each cell has a cell address
The value of a field cannot exist without a The value of a cell can exist
record independently
Each field can store only one type of data Each cell can store any types of data
4 THMSS – S3 Stem and ICT
Chapter 5: Database - Introduction to Database System (Teacher Version)
2.2 Data type
Each field in a database must have a data type. Take Microsoft Access as an
example.
Data Type Data type in Access Example of field size Example of values in Access
Character / Short Text / Long Text a 0913 1C09
String
Real Number Integer / Decimal 569.1 -40.3 0.009
number
Date/Time Date/Time Short Date / 2025/01/03
Medium Date/
Short Time /
Long Time
Boolean Yes/No Yes (True) No (False)
5 THMSS – S3 Stem and ICT
Chapter 5: Database - Introduction to Database System (Teacher Version)
e.g. A teacher wants to create a table named EVENT to store the data of school events.
Here is the table structure of EVENT. Give an example of each data stored in the corresponding field.
Field Name Description Example
EID A unique identity number for each event. It ranges
from 0 to 999,999.
ENAME Event name. The maximum length is 255.
EDATE The date of the event.
FEE The participation fee for the event.
FINISHED Whether the event has finished. (1 means finished, 0
means pending)
2.3 Primary key and composite key
e.g. Suppose you are the manager of a DVD rental store in the early 2000s, renting various types of DVDs
to your store’s members. You plan to create three physical log sheets to store data about the DVDs,
members and renting record respectively.
a. What data should your log sheet of the DVDs include?
b. What data should your log sheet of the members include?
In order to be sure that each record can be found easily and to prevent more than one copy of the same
record being kept, each record includes a Primary Key field. Each Primary Key field in the table is unique.
The primary key can be a field that is unique, for example the ISBN in the book table, or a new field added
to each record , for example, a unique hospital number could be added to each hospital patients record.
6 THMSS – S3 Stem and ICT
Chapter 5: Database - Introduction to Database System (Teacher Version)
e.g. Refer to the following table:
SUBMI
SID SNAME HKID DOB CLASS CNO SCORE ATIME
T
034945 Ann Au Z0992.. 2015-06-19 1A 3 80.5 9:03 Yes
034941 Finn Fung Z0994.. 2015-05-18 1A 4 50 9:02 Yes
034930 Dahlia S0022.. 2015-01-24 1A 1 92 8:45 Yes
Hirche
034932 Olaf Or K8723.. 2015-08-01 1A 2 64 8:46 Yes
034938 Chad Chan H8731.. 2015-05-20 1A 5 95 9:01 No
034935 Gwen Ku L8763.. 2015-02-22 1B 2 89.5 9:05 Yes
034933 Kim Kwok P4321.. 2015-12-09 1B 3 84.5 8:50 Yes
034944 Eva Lee H0032.. 2015-04-17 1B 4 57.5 9:30 Yes
034934 Ben Bu Z6221.. 2015-10-08 1B 5 44.5 9:18 No
034939 Nina Ng B0484.. 2015-11-03 1B 1 74 8:52 No
034943 Leo Lo C4321.. 2015-04-04 1C 5 77.5 8:40 Yes
034937 Hank Ho U8272.. 2015-03-21 1C 3 83 8:42 No
034931 Jo Chong M2232. 2015-06-27 1C 2 75.5 8:54 Yes
.
034940 Dan Tang H4211.. 2015-07-23 1C 1 63.5 8:53 Yes
034942 Ivy Yip F8495.. 2015-09-25 1C 4 0 8:57 No
034936 May Mo F4221.. 2015-07-14 1C 6 76 9:07 Yes
a. SID in the above table is defined as characters instead of numbers. Why?
b. Which of the following field is the best to uniquely identify the record?
c. Can SNAME be a primary key? Why?
d. Can HKID be a primary key? Why?
There are 3 key properties of a primary key:
• A table should have one and only one primary key
• The value of a primary key cannot be empty for any records
• The value of a primary key must be unique for every record in the table
7 THMSS – S3 Stem and ICT
Chapter 5: Database - Introduction to Database System (Teacher Version)
Sometimes, a primary key can be formed by using two or more existing fields for example the doctors
appointments could have a primary key made from the date and the time of each appointment, called
composite key.
e.g. Refer to the following table:
SPORTSDAY
EID SID RESULT
LJ10M 03496 Champion
SHPUT 03496 Champion
B400R 03496 Champion
B400R 03494 Champion
B400R 03493 Champion
SHPUT 03492 1ST
SHPUT 03491 2ND
a. Which of the following field(s) is/are the best to uniquely identify the record?
2.4 Constraint
There are various constraints we can apply to fields for data validation.
# Name Description
1 Required If “Yes”, the field cannot be left empty
2 Indexed If “Yes”, the field cannot have duplicated values.
3 Default Value A value is automatically assigned to the field for any new
record.
4 Allow Zero Length Text fields only. If “No”, the field must contain at least
one character.
8 THMSS – S3 Stem and ICT