📚 Database Essentials for IB AQA Computer Science | IB AQA 计算机:数据库 考点精讲
Databases sit at the heart of most modern applications, from online banking to social media. In the IB AQA Computer Science syllabus, understanding database concepts is not just about memorising definitions — it involves grasping how data is structured, queried and maintained with precision. This article walks through the key areas you need to master, including relational models, SQL and normalisation.
数据库是绝大多数现代应用的核心,从网上银行到社交媒体无一例外。在 IB AQA 计算机科学大纲中,理解数据库概念不只是背诵定义,更需要掌握数据是如何被精准地构建、查询和维护的。本文将梳理你必须掌握的关键领域,包括关系模型、SQL 语言以及规范化。
1. What is a Database? | 数据库定义
A database is an organised collection of data that is stored and accessed electronically. It allows multiple users to efficiently retrieve, insert, update and delete information while minimising redundancy. Unlike a simple spreadsheet, a database enforces structure and integrity through a Database Management System (DBMS).
数据库是一个有组织的数据集合,以电子方式存储和访问。它允许多个用户高效地检索、插入、更新和删除信息,同时最大限度地减少冗余。与简单的电子表格不同,数据库通过数据库管理系统(DBMS)强制执行结构和完整性约束。
2. Relational Database Concepts | 关系数据库概念
The relational model organises data into tables (relations) consisting of rows and columns. Each table represents an entity, and every row is a unique instance of that entity. The strength of the relational model lies in linking tables through common attributes, avoiding duplication.
关系模型将数据组织成由行和列构成的表(关系)。每个表代表一个实体,每一行是该实体的一个唯一实例。关系模型的优势在于通过公共属性连接表,从而避免数据重复。
3. Tables, Records, and Fields | 表、记录与字段
A table is a collection of related data held in a structured format. Each row is called a record (or tuple), and each column is a field (or attribute). For example, a ‘Student’ table might have fields such as StudentID, Name, and DateOfBirth. Every field has a defined data type, like INTEGER, VARCHAR, or DATE.
表是以结构化格式保存的相关数据的集合。每一行称为一条记录(或元组),每一列称为一个字段(或属性)。例如,“Student”表可能包含 StudentID、Name 和 DateOfBirth 等字段。每个字段都有定义的数据类型,如整数、变长字符串或日期。
4. Primary and Foreign Keys | 主键与外键
A primary key is a field (or combination of fields) that uniquely identifies each record in a table. It must contain unique values and cannot be NULL. A foreign key is a field in one table that refers to the primary key in another table, creating a link between the two. This enforces referential integrity — you cannot have a foreign key value that does not exist as a primary key in the referenced table.
主键是唯一标识表中每条记录的一个字段(或字段组合)。它必须包含唯一值,且不能为空。外键是一个表中的字段,它引用另一个表中的主键,从而在两个表之间建立联系。这强制实施参照完整性——你不能有一个在被引用表中不作为主键存在的外键值。
5. Relationships Between Tables | 表间关系
Tables can be related in three main ways: one-to-one, one-to-many, and many-to-many. A one-to-many relationship is the most common — for instance, one department has many employees. Many-to-many relationships (e.g., students and courses) require a junction (link) table to break them down into two one-to-many relationships.
表可以通过三种主要方式关联:一对一、一对多和多对多。一对多关系最为常见——例如,一个部门有多名员工。多对多关系(如学生与课程)需要一个联结表将它们拆分成两个一对多关系。
6. Introduction to SQL | SQL语言简介
SQL (Structured Query Language) is the standard language for interacting with relational databases. It is declarative — you specify what data you want, not how to retrieve it. The language is split into categories: DDL (Data Definition Language) for defining structures, and DML (Data Manipulation Language) for working with data.
SQL(结构化查询语言)是与关系数据库交互的标准语言。它是一种声明式语言——你指定想要什么数据,而不必指定如何获取。该语言分为几类:用于定义结构的 DDL(数据定义语言)和用于处理数据的 DML(数据操纵语言)。
7. Querying with SELECT | 使用SELECT查询
The SELECT statement retrieves data from one or more tables. Basic syntax: SELECT field1, field2 FROM table WHERE condition; You can use wildcards like * to select all columns, and combine conditions with AND, OR. ORDER BY sorts results, and JOIN clauses merge related tables together.
SELECT 语句从一个或多个表中检索数据。基本语法:SELECT 字段1, 字段2 FROM 表 WHERE 条件; 你可以使用 * 这样的通配符选择所有列,并用 AND、OR 组合条件。ORDER BY 对结果排序,JOIN 子句将相关表合并在一起。
8. Modifying Data: INSERT, UPDATE, DELETE | 修改数据:插入、更新、删除
To add a new record, use INSERT INTO table (columns) VALUES (values);. UPDATE table SET column = value WHERE condition; changes existing records — always include a WHERE clause to avoid updating every row. DELETE FROM table WHERE condition; removes records; omitting WHERE deletes all rows while keeping the table structure.
要添加一条新记录,使用 INSERT INTO 表 (列) VALUES (值);。UPDATE 表 SET 列 = 值 WHERE 条件; 会修改现有记录——一定要加上 WHERE 子句,以免更新所有行。DELETE FROM 表 WHERE 条件; 删除记录;省略 WHERE 会删掉所有行,但保留表结构。
9. Database Normalisation (1NF, 2NF, 3NF) | 数据库规范化(1NF, 2NF, 3NF)
Normalisation is a process to reduce data redundancy and improve integrity. First Normal Form (1NF) requires atomic values and no repeating groups. Second Normal Form (2NF) builds on 1NF by removing partial dependencies — all non-key attributes must depend on the whole primary key. Third Normal Form (3NF) eliminates transitive dependencies, where a non-key attribute depends on another non-key attribute. For most exam purposes, reaching 3NF is considered sufficient.
规范化是减少数据冗余、提高完整性的过程。第一范式(1NF)要求原子值且没有重复的分组。第二范式(2NF)在 1NF 的基础上去除部分依赖——所有非键属性必须依赖于整个主键。第三范式(3NF)消除传递依赖,即一个非键属性依赖于另一个非键属性。在大多数考试情境下,达到 3NF 即视为足够。
10. DBMS and Data Integrity | 数据库管理系统与数据完整性
A DBMS provides tools for creating, querying, and administering databases. It upholds data integrity through constraints: entity integrity (primary key uniqueness and non‑null), referential integrity (foreign key validity), and domain integrity (allowed values and data types). Additionally, it handles concurrency, access control, and backup/recovery. Common examples include MySQL, SQLite, and PostgreSQL.
DBMS 提供创建、查询和管理数据库的工具。它通过约束维护数据完整性:实体完整性(主键唯一且非空)、参照完整性(外键有效性)以及域完整性(允许的值和数据类型)。此外,它还处理并发控制、访问权限控制以及备份与恢复。常见的例子包括 MySQL、SQLite 和 PostgreSQL。
11. SQL JOINs Illustrated | SQL表连接详解
JOINs combine rows from two or more tables based on a related column. INNER JOIN returns only rows where the join condition is met in both tables. LEFT JOIN returns all rows from the left table plus matched rows from the right; unmatched right columns become NULL. Understanding JOINs is vital for building meaningful queries across normalised tables.
JOIN 根据相关列合并两个或多个表的行。INNER JOIN 只返回两个表中都满足连接条件的行。LEFT JOIN 返回左表的所有行,加上右表中匹配的行;右表不匹配的列将显示为 NULL。掌握 JOIN 对于在规范化的表之间构建有意义的查询至关重要。
12. Key Exam Tips and Common Mistakes | 考试要点与常见错误
When writing SQL in exams, check your semicolons and ensure WHERE clauses are precise. In normalisation questions, clearly state which normal form is violated and why. Practice drawing entity‑relationship diagrams and translating them into table schemas. Always link theory back to real‑world scenarios, as AQA style questions often ask for application rather than pure recall.
考试中书写 SQL 时,检查分号并确保 WHERE 子句准确无误。对于规范化问题,要清楚说明违反的是哪个范式以及原因。练习绘制实体关系图并将其转化为表模式。始终将理论联系到实际场景中,因为 AQA 风格的题目常要求应用知识,而非单纯回忆。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导