📚 GCSE Computer Science: Databases Revision Guide | GCSE 计算机:数据库 考点精讲
Databases are a fundamental part of modern computing, allowing huge amounts of data to be stored, searched and managed efficiently. For GCSE Computer Science you need to understand how databases are structured, how they differ from spreadsheets, and how to write simple SQL queries to retrieve and modify data.
数据库是现代计算的基础,能够高效地存储、搜索和管理海量数据。在 GCSE 计算机科学中,你需要了解数据库的结构、数据库与电子表格的区别,以及如何编写简单的 SQL 查询来检索和修改数据。
1. What is a Database? | 什么是数据库?
A database is an organised collection of structured data stored electronically in a computer system. It is designed to allow many users to store, retrieve, and update data at the same time without conflict. The software that manages the database is called a Database Management System (DBMS).
数据库是一个有组织的结构化数据集合,以电子方式存储在计算机系统中。它允许多个用户同时存储、检索和更新数据而不会发生冲突。管理数据库的软件称为数据库管理系统 (DBMS)。
2. Databases vs. Spreadsheets | 数据库与电子表格
Although both spreadsheets and databases store data in tables, they serve different purposes. Spreadsheets are best for small datasets and individual analysis, while databases are designed for large, shared data environments with strict controls over data integrity and security.
虽然电子表格和数据库都以表格形式存储数据,但它们用途不同。电子表格最适合小数据集和个人分析,而数据库则专为大型共享数据环境设计,对数据完整性和安全性有严格控制。
| Feature | Database | Spreadsheet |
|---|---|---|
| Data volume | Very large (millions of records) | Limited by memory |
| Concurrent users | Many at once | Usually one user |
| Data redundancy | Minimised by design | Often occurs |
| Integrity rules | Enforced by the DBMS | Manual checks only |
3. Key Terminology: Tables, Records, Fields | 关键术语:表、记录、字段
A database is made up of one or more tables. Each table holds data about a specific entity, for example a table named ‘Students’.
数据库由一个或多个表组成。每个表保存关于特定实体的数据,例如一个名为 ‘Students’ 的表。
A record (also called a row) is a single complete entry in a table, such as all the information about one student.
一条记录(也称为行)是表中的一条完整条目,例如一个学生的所有信息。
A field (also called a column) is a single category of data in a table, such as ‘LastName’ or ‘DateOfBirth’. Each field has a defined data type.
一个字段(也称为列)是表中的一类数据,例如 ‘LastName’ 或 ‘DateOfBirth’。每个字段都有定义的数据类型。
4. Data Types and Field Properties | 数据类型与字段属性
Common data types you need to know include: Text (alphanumeric characters), Number (integer or real), Date/Time, and Boolean (Yes/No). The data type determines what operations can be performed on the field and how much storage it uses.
你需要知道的常见数据类型包括:文本(字母数字字符)、数字(整数或实数)、日期/时间以及布尔型(是/否)。数据类型决定了可以对该字段执行哪些操作以及它占用多少存储空间。
Field properties such as field size, format, input mask, and validation rules help control the data entered. For example, a field size of 20 limits a text field to 20 characters.
字段属性如字段大小、格式、输入掩码和验证规则有助于控制输入的数据。例如,字段大小设为 20 会将文本字段限制为 20 个字符。
5. Primary Keys and Foreign Keys | 主键与外键
A primary key is a field (or combination of fields) that uniquely identifies each record in a table. No two records can have the same primary key value, and it cannot be left blank. A StudentID is a typical primary key.
主键是一个字段(或字段组合),它唯一标识表中的每条记录。没有两条记录可以拥有相同的主键值,且主键不能留空。学号 (StudentID) 就是典型的主键。
A foreign key is a field in one table that refers to the primary key of another table. It creates a link between the two tables, enabling relationships and ensuring referential integrity.
外键是一个表中的字段,它引用另一个表的主键。它在两个表之间建立链接,从而实现关系并确保参照完整性。
6. Relational Databases and Relationships | 关系型数据库与关系
In a relational database, data is split into separate linked tables to avoid duplication. Relationships are formed using primary and foreign keys. Common relationship types include one-to-one, one-to-many, and many-to-many.
在关系型数据库中,数据被拆分到多个相互链接的表中以避免重复。关系是通过主键和外键建立的。常见的关系类型包括一对一、一对多和多对多。
A one-to-many relationship means one record in Table A can be associated with many records in Table B. For example, one teacher can teach many students. Many-to-many relationships require a junction (link) table to connect the two tables.
一对多关系意味着表 A 中的一条记录可以与表 B 中的多条记录关联。例如,一名教师可以教多名学生。多对多关系需要一个连接(链接)表来连接两个表。
7. Reducing Data Redundancy and Normalisation | 减少数据冗余与规范化
Data redundancy means storing the same piece of data in more than one place, which wastes space and can lead to inconsistencies. Normalisation is the process of organising data to reduce redundancy by splitting tables and defining relationships.
数据冗余指的是在多个位置存储相同的数据项,这会浪费空间并可能导致不一致。规范化是通过拆分表和定义关系来减少冗余、组织数据的过程。
Even at GCSE level you should be able to suggest splitting a flat file into two related tables. For instance, instead of repeating customer addresses in every order record, store customer details in a separate Customers table linked by a CustomerID foreign key.
即使在 GCSE 阶段,你也应该能够提出将平面文件拆分成两个相关表的建议。例如,与其在每个订单记录中重复客户地址,不如将客户详细信息存储在一个单独的 Customers 表中,通过 CustomerID 外键进行链接。
8. Introduction to SQL – SELECT Queries | SQL入门 – SELECT 查询
SQL (Structured Query Language) is used to communicate with relational databases. The most common command is SELECT, which retrieves data from one or more tables.
SQL(结构化查询语言)用于与关系型数据库通信。最常用的命令是 SELECT,它从一张或多张表中检索数据。
The basic syntax to get all columns and all rows from a table Students is:
从 Students 表中获取所有列和所有行的基本语法是:
SELECT * FROM Students;
To select only certain fields, list them after SELECT separated by commas, for example:
要仅选择特定字段,请在 SELECT 后列出它们并用逗号分隔,例如:
SELECT FirstName, LastName FROM Students;
9. Filtering with WHERE and Sorting with ORDER BY | 使用 WHERE 过滤与 ORDER BY 排序
The WHERE clause is used to filter records based on a condition. Only those records that meet the condition are returned. You can use operators such as =, <, >, <>, AND, OR, BETWEEN, and LIKE with wildcards % (matches any sequence of characters) and _ (matches a single character).
WHERE 子句用于根据条件过滤记录。只有满足条件的记录才会被返回。你可以使用诸如 =、<、>、<>、AND、OR、BETWEEN 以及带有通配符 %(匹配任意字符序列)和 _(匹配单个字符)的 LIKE 等运算符。
Example: Find all students over age 16.
示例:查找所有年龄超过 16 岁的学生。
SELECT * FROM Students WHERE Age > 16;
The ORDER BY clause sorts the results in ascending (ASC) or descending (DESC) order. To sort by LastName alphabetically:
ORDER BY 子句按升序 (ASC) 或降序 (DESC) 对结果进行排序。按姓氏字母顺序排序:
SELECT * FROM Students ORDER BY LastName ASC;
10. Inserting, Updating and Deleting Data | 插入、更新和删除数据
To add a new record, use the INSERT INTO statement. You must specify the table name, the fields you are filling, and the values.
要添加新记录,请使用 INSERT INTO 语句。你必须指定表名、要填充的字段以及对应的值。
INSERT INTO Students (StudentID, FirstName, LastName, Age)
VALUES (101, ‘John’, ‘Smith’, 17);
The UPDATE statement changes existing data. Always include a WHERE clause to specify which record(s) to modify; otherwise you will update every record in the table.
UPDATE 语句用于更改现有数据。务必包含 WHERE 子句以指定要修改的记录;否则你将更新表中的每条记录。
UPDATE Students SET Age = 18 WHERE StudentID = 101;
The DELETE statement removes records. Again, use WHERE to target specific records. DELETE FROM Students WHERE StudentID = 101; would delete John’s record.
DELETE 语句用于删除记录。同样,使用 WHERE 来定位特定记录。DELETE FROM Students WHERE StudentID = 101; 将删除 John 的记录。
11. Data Validation and Verification | 数据验证与确认
Validation is a process carried out by the computer to check if data is sensible, reasonable, and allowable. Common validation checks include presence check (must not be blank), range check (value within a set range), type check (correct data type), format check (matches a pattern like dd/mm/yyyy), and length check (e.g. phone number must be 11 digits).
验证是计算机执行的过程,用于检查数据是否合理、合规且被允许。常见的验证检查包括存在性检查(不能为空)、范围检查(值在设定范围内)、类型检查(数据类型正确)、格式检查(匹配指定模式,如 dd/mm/yyyy)以及长度检查(例如电话号码必须为 11 位数字)。
Verification is the process of making sure that the data entered matches the original source. It is usually done by a human, for example double-entry verification where data is typed twice and compared, or proof-reading.
确认是确保输入的数据与原始来源一致的过程。这通常由人工完成,例如双重输入确认(数据键入两次并进行比较)或校对。
12. Advantages of Databases | 数据库的优点
Relational databases offer many benefits over flat-file systems: reduced data redundancy, improved data integrity through validation and constraints, better privacy and security with user access levels, efficient searching and reporting using SQL, and the ability to handle concurrent users without data corruption.
关系型数据库相较于平面文件系统有许多优势:减少数据冗余、通过验证和约束提高数据完整性、利用用户访问级别实现更好的隐私和安全性、使用 SQL 进行高效搜索和报告,以及能够处理并发用户而不会损坏数据。
Data independence is another key advantage: changes to the data structure do not require changes to the entire application, making databases flexible and scalable.
数据独立性是另一个关键优势:数据结构的更改不需要更改整个应用程序,这使得数据库具有灵活性和可扩展性。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply