Database Concepts for OCR A-Level Computer Science | A-Level OCR 计算机:数据库 考点精讲

📚 Database Concepts for OCR A-Level Computer Science | A-Level OCR 计算机:数据库 考点精讲

Databases lie at the heart of almost every modern application — from e‑commerce websites to hospital record systems. In the OCR A‑Level Computer Science specification (H446), the database topic explores how data is modelled, stored, queried, and kept consistent. Understanding relational theory, normalisation, SQL, and transaction management is essential not only for the exam but also for building robust software in the real world.

数据库是现代几乎所有应用的核心,从电商网站到医院病历系统。在 OCR A-Level 计算机科学大纲(H446)中,数据库专题深入探讨了数据如何建模、存储、查询以及保持一致性。理解关系理论、规范化、SQL 以及事务管理,不仅对考试至关重要,对在现实世界中构建健壮的软件也同样关键。

1. Relational Database Fundamentals | 关系数据库基础

A relational database stores data in tables (relations). Each table consists of rows (records/tuples) and columns (attributes/fields). Every column has a defined domain, which is the set of allowable values for that attribute. The structure of the database, including tables and constraints, is called the schema.

关系数据库将数据存储在表(关系)中。每个表由行(记录/元组)和列(属性/字段)组成。每个列都有一个定义的域,即该属性允许取值的集合。数据库的结构,包括表和约束,称为模式。

2. Keys: Primary, Foreign, Candidate, and Composite | 键:主键、外键、候选键与复合键

A primary key uniquely identifies each record in a table; it cannot contain NULL values. A foreign key is an attribute in one table that refers to the primary key of another table, creating a link between them. A candidate key is any minimal set of attributes that can uniquely identify a record — the primary key is chosen from the candidate keys. A composite key (or compound key) consists of two or more attributes that together provide a unique identifier.

主键唯一标识表中的每一条记录,不能包含 NULL 值。外键是一个表中的属性,它引用另一个表的主键,在表之间建立联系。候选键是能够唯一标识记录的任一最小属性集合——主键就是从候选键中选出的。复合键由两个或多个属性共同组成唯一标识。

3. Entity‑Relationship Modelling | 实体关系建模

Entity‑Relationship (ER) diagrams are used to visualise the structure of a database. Entities (rectangles) become tables, attributes (ovals) become columns, and relationships (diamonds) become foreign key links. Relationships have cardinality: one‑to‑one (1:1), one‑to‑many (1:M), or many‑to‑many (M:M). OCR expects you to interpret and draw simple ER diagrams, clearly showing entities, attributes, and the nature of relationships.

实体关系图(ER 图)用于可视化数据库的结构。实体(矩形)变成表,属性(椭圆形)变成列,关系(菱形)变成外键链接。关系具有基数:一对一(1:1)、一对多(1:M)或多对多(M:M)。OCR 要求考生能解读并绘制简单的 ER 图,清楚展示实体、属性以及关系的性质。


4. Normalisation to 1NF | 规范化到第一范式

First Normal Form (1NF) requires that each field contains only atomic (indivisible) values, and that there are no repeating groups. To convert an unnormalised table into 1NF, you must ensure every cell holds a single value, and if multiple values exist for an entity, they are moved into separate rows so that the table has a flat, tabular structure with a primary key that identifies each row uniquely.

第一范式(1NF)要求每个字段只包含原子(不可再分)值,且没有重复组。将未规范化的表转换为 1NF 时,必须确保每个单元格只保存一个值;如果实体存在多值,应将其拆分为独立行,使得表具有平面表格结构,并有主键唯一标识每一行。

5. Second Normal Form (2NF) | 第二范式

A table is in 2NF if it is already in 1NF and every non‑key attribute depends on the whole of the primary key, not just part of it. Partial dependencies only occur when a table has a composite primary key. To move to 2NF, you remove attributes that depend on only part of the composite key into a new table, linking them back via a foreign key.

如果表已经满足 1NF,并且每个非键属性都完全依赖于整个主键而不只是主键的一部分,则该表属于第二范式(2NF)。部分依赖仅出现在表具有复合主键的情况下。要转换为 2NF,需将仅依赖于部分复合键的属性移到一个新表中,并通过外键进行链接。

6. Third Normal Form (3NF) | 第三范式

A table is in 3NF if it is in 2NF and contains no transitive dependencies. A transitive dependency occurs when a non‑key attribute depends on another non‑key attribute rather than directly on the primary key. To achieve 3NF, you separate the transitively dependent attributes into a new table, with the determinant becoming the primary key of that new table and a foreign key in the original.

如果表已经满足 2NF,且不包含传递依赖,则该表属于第三范式(3NF)。传递依赖是指非键属性依赖于另一个非键属性,而不是直接依赖于主键。要实现 3NF,需将传递依赖的属性分离到新表中,让决定因子成为新表的主键,并在原表中作为外键。


7. SQL: Data Definition and Data Manipulation | SQL:数据定义与数据操作

SQL (Structured Query Language) is the standard language for relational databases. Data Definition Language (DDL) commands include CREATE TABLE, ALTER TABLE, and DROP TABLE. Data Manipulation Language (DML) commands include SELECT, INSERT, UPDATE, and DELETE. OCR may ask you to write SQL statements that retrieve specific records, often using WHERE, ORDER BY, and JOIN clauses.

SQL(结构化查询语言)是关系数据库的标准语言。数据定义语言(DDL)命令包括 CREATE TABLEALTER TABLEDROP TABLE。数据操作语言(DML)命令包括 SELECTINSERTUPDATEDELETE。OCR 可能会要求考生编写 SQL 语句,检索特定记录,常会用到 WHEREORDER BYJOIN 子句。

8. SQL Joins and Subqueries | SQL 连接与子查询

To combine data from multiple tables, SQL provides several types of joins. An INNER JOIN returns rows where there is a match in both tables. A LEFT JOIN returns all rows from the left table and matched rows from the right. Subqueries (nested SELECT statements inside WHERE or FROM) allow complex filtering. For the exam, you should be comfortable writing a query that links a foreign key to its referenced primary key.

要从多个表合并数据,SQL 提供了几种连接类型。INNER JOIN 返回两表中匹配的行。LEFT JOIN 返回左表所有行以及右表匹配的行。子查询(嵌套在 WHEREFROM 中的 SELECT 语句)能够实现复杂筛选。考试中应能熟练编写将外键链接到其引用主键的查询。


9. Database Management Systems (DBMS) | 数据库管理系统

A DBMS is software that controls the creation, maintenance, and use of a database. It handles data storage, security, backup, concurrency, and recovery. Examples include MySQL, PostgreSQL, and Microsoft SQL Server. The DBMS enforces integrity constraints (entity, referential, and domain integrity) and provides a query interface. Understanding its role helps explain how multiple users can safely access data simultaneously.

数据库管理系统(DBMS)是控制数据库创建、维护和使用的软件。它处理数据存储、安全、备份、并发和恢复。例如 MySQL、PostgreSQL 和 Microsoft SQL Server。DBMS 强制执行完整性约束(实体完整性、引用完整性和域完整性)并提供查询接口。理解 DBMS 的角色有助于解释多个用户如何能安全地同时访问数据。

10. ACID Transactions | ACID 事务

When multiple operations must be treated as a single logical unit, a DBMS uses transactions. A transaction must satisfy the ACID properties: Atomicity (all or nothing), Consistency (database moves from one valid state to another), Isolation (concurrent transactions do not interfere), and Durability (committed changes survive system failure). For instance, transferring money between bank accounts must debit one and credit the other as a single atomic operation.

当多个操作必须视为一个逻辑单元时,DBMS 会使用事务。事务必须满足 ACID 属性:原子性(全做或全不做)、一致性(数据库从一个合法状态转移到另一个合法状态)、隔离性(并发事务互不干扰)和持久性(已提交的更改在系统故障后依然存在)。例如,银行账户间转账必须在一个原子操作中完成一个账户的借记和另一个账户的贷记。


11. Database Security and Views | 数据库安全与视图

Security measures protect data from unauthorised access. A DBMS provides authentication (username/password), authorisation (privileges like SELECT, INSERT granted to roles), and encryption. Views are virtual tables defined by a stored query; they hide sensitive columns and simplify complex queries. For OCR, you might explain how a view can restrict a user to seeing only their own records.

安全措施保护数据免受未授权访问。DBMS 提供身份验证(用户名/密码)、授权(授予角色的 SELECT、INSERT 等权限)和加密。视图是由存储查询定义的虚拟表,可以隐藏敏感列并简化复杂查询。在 OCR 考试中,可能需要解释视图如何限制用户只能查看其自己的记录。

12. Backup, Recovery, and Redundancy | 备份、恢复与冗余

System failures, human errors, or disasters can destroy data. Backup strategies (full, incremental, differential) create copies that can be restored. Redundancy is deliberately storing duplicate data or using RAID systems to improve reliability. In the context of databases, transaction logs allow point‑in‑time recovery. You should be able to discuss trade‑offs between recovery time, storage cost, and performance.

系统故障、人为错误或灾难可能损毁数据。备份策略(完全备份、增量备份、差异备份)创建可恢复的副本。冗余是指有意识地存储重复数据或使用 RAID 系统以提高可靠性。在数据库上下文中,事务日志允许恢复到某一时间点。应能讨论恢复时间、存储成本与性能之间的权衡。

Published by TutorHao | Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version