跳到主要内容

数据库

IGCSE 信息与通信技术知识点 18

讲义

English

This topic covers databases: their structure and forms, calculations, sorting and searching, and reports.

18.1 Create a database structure

Database structure

A database table 数据表 holds records 记录 (rows), each made of fields (columns).

data type use display formats
text (alphanumeric) names, codes, phone numbers
numeric: integer, decimal, currency quantities, prices number of decimal places, percentage, currency symbol
date/time dates and times e.g. 25/02/2026, 25-Feb-2026, 14:30
Boolean 布尔型 (logical) only two values yes/no, true/false, a checkbox
  • data can be imported from .csv or .txt files, giving each field the specified name

Keys and relationships

  • a primary key 主键 is a field whose value is unique for each record, e.g. StudentID; it identifies the record
  • a foreign key 外键 is a field in one table that is the primary key of another table; it links the two tables
  • a relationship 关系 joins the tables through these keys, e.g. one student has many loans
flat-file database 平面文件数据库 relational database 关系型数据库
one table two or more linked tables
simple to set up and use more complex to design
data may be repeated (redundancy 冗余), wasting space a good design reduces repetition: shared details stored once
repeated data can become inconsistent when changed in one place only change once, correct everywhere
suits small, simple lists suits large systems, e.g. a school or shop
A Books table and an Authors table: AuthorID is the primary key of Authors and a foreign key in Books

Good data entry forms

A clear title and instructions; fields in a logical order; enough white space and suitable spacing between fields; a clear, readable font; radio buttons 单选按钮 (choose one option), check boxes 复选框 (yes/no or several options), drop-down menus 下拉菜单 (choose from a list) to reduce typing errors; buttons to move between records.

Worked example. A library has Books(BookID, Title, Author) and Loans(LoanID, BookID, MemberID, DateOut). LoanID is the primary key of Loans. BookID is the primary key of Books and a foreign key in Loans, so each loan links to one book.

18.2 Manipulate data

Calculations in a database

  • a calculated field 计算字段 in a query 查询 works out a new value for every record, e.g. Total: [Price]*[Quantity]
  • a calculated control 计算控件 in a report 报表 or form shows a result, e.g. =Sum([Total]) in the report footer 报表页脚
  • functions: Sum, Avg (average), Max, Min, Count; operators 运算符 + − * /

Sorting

  • ascending 升序 (A→Z, 0→9, oldest→newest) or descending 降序 (Z→A, 9→0)
  • with multiple criteria 条件, a second sort orders records that tie on the first, e.g. by Surname ascending, then FirstName ascending

Searching with queries

A query selects only the records that meet the criteria. This sheet uses Microsoft Access syntax, with * and ? as wildcards 通配符; other software may use % and _.

operator meaning example criteria
= <> equal; not equal Colour = "Red"; Colour <> "Red"
> < >= <= greater, less (or equal) Price >= 100
AND both conditions true Price < 50 AND Stock > 0
OR either condition true Colour = "Red" OR Colour = "Blue"
NOT excludes NOT "London"
LIKE with wildcards pattern match: * any number of characters, ? one character LIKE "T*" (starts with T); LIKE "*son" (ends in son)

Worked example. A car database. Find all red or blue cars costing under 20 000 USD, newest first:

(Colour = "Red" OR Colour = "Blue") AND Price < 20000, sorted by Year descending.

The brackets keep the OR together: without them, every red car would be selected whatever its price.

Five cars run through the query: with brackets only the red car at 15 000 and the blue car at 18 000 are selected; without brackets the red car at 28 000 is selected too

18.3 Present data

Database reports

A report presents selected data for printing or display.

part appears typical contents
report header 报表页眉 once, at the start report title, logo, date
page header 页面页眉 top of every page column labels (field names)
detail once per record the data
page footer bottom of every page page number
report footer once, at the end totals, averages, counts
A report with its report header, page header, detail lines, page footer and report footer

Layout and display

  • tabular 表格形式 layout: records in rows, fields in columns, like a table: good for many records
  • columnar 纵栏形式 layout: one record at a time, labels beside the data: good for showing all the details of each record
  • display all the required data and labels in full: widen controls so nothing is cut off
  • right-align numbers and use decimal alignment 小数点对齐, so digits and decimal points line up; text is usually left-aligned
  • format numbers: number of decimal places, currency symbol, percentage

Worked example. A sales report: title "Sales by Region" in the report header; field labels in the page header; each sale in the detail; page numbers in the page footer; the total of all sales, formatted as currency with 2 decimal places, in the report footer.

词汇
English 中文 拼音
table/ˈteɪbl/ 数据表 shù jù biǎo
record/ˈrekɔːd/ 记录 jì lù
primary key/ˈpraɪməri kiː/ 主键 zhǔ jiàn
foreign key/ˈfɒrən kiː/ 外键 wài jiàn
relationship/rɪˈleɪʃənʃɪp/ 关系 guān xì
flat-file database 平面文件数据库 píng miàn wén jiàn shù jù kù
relational database/rɪˈleɪʃənl ˈdeɪtəbeɪs/ 关系型数据库 guān xì xíng shù jù kù
redundancy/rɪˈdʌndənsi/ 冗余 rǒng yú
Boolean/ˈbuːlɪən/ 布尔型 bù ěr xíng
radio button 单选按钮 dān xuǎn àn niǔ
check box 复选框 fù xuǎn kuàng
drop-down menu 下拉菜单 xià lā cài dān
query/ˈkwɪərɪ/ 查询 chá xún
criteria/kraɪˈtɪərɪə/ 条件 tiáo jiàn
calculated field 计算字段 jì suàn zì duàn
calculated control 计算控件 jì suàn kòng jiàn
ascending/əˈsendɪŋ/ 升序 shēng xù
descending/dɪˈsendɪŋ/ 降序 jiàng xù
wildcard/ˈwaɪldkɑːd/ 通配符 tōng pèi fú
operator/ˈɒpəreɪtə/ 运算符 yùn suàn fú
report/rɪˈpɔːt/ 报表 bào biǎo
report header 报表页眉 bào biǎo yè méi
page header 页面页眉 yè miàn yè méi
report footer 报表页脚 bào biǎo yè jiǎo
tabular 表格形式 biǎo gé xíng shì
columnar/ˈkɒləmnɑː/ 纵栏形式 zòng lán xíng shì
decimal alignment 小数点对齐 xiǎo shù diǎn duì qí

该知识点的互动课程

逐步完成,配合即时检查练习。

更多 IGCSE 信息与通信技术 知识点

登录或创建账户

IGCSE, A-Level & AP