The Database Management System (DBMS) · 数据库管理系统 (DBMS)
| English | 中文 | Pinyin · 拼音 |
|---|---|---|
| DBMS/ˌdiː biː em ˈes/ | 数据库管理系统 | shù jù kù guǎn lǐ xì tǒng |
| view/vjuː/ | 视图 | shì tú |
| backup/ˈbækʌp/ | 备份 | bèi fèn |
| data management/ˈdeɪtə ˈmænɪdʒmənt/ | 数据管理 | shù jù guǎn lǐ |
| data dictionary/ˈdeɪtə ˈdɪkʃənəri/ | 数据字典 | shù jù zì diǎn |
| data modelling/ˈdeɪtə ˈmɒdəlɪŋ/ | 数据建模 | shù jù jiàn mó |
| logical schema/ˈlɒdʒɪkl ˈskiːmə/ | 逻辑模式 | luó jí mó shì |
| data integrity/ˈdeɪtə ɪnˈteɡrɪti/ | 数据完整性 | shù jù wán zhěng xìng |
| data security/ˈdeɪtə sɪˈkjʊərɪti/ | 数据安全 | shù jù ān quán |
| transaction/trænˈsækʃn/ | 事务 | shì wù |
| concurrent access/kənˈkʌrənt ˈækses/ | 并发访问 | bìng fā fǎng wèn |
| concurrency control/kənˈkʌrənsi kənˈtrəʊl/ | 并发控制 | bìng fā kòng zhì |
| developer interface/dɪˈveləpə ˈɪntəfeɪs/ | 开发者接口 | kāi fā zhě jiē kǒu |
| query processor/ˈkwɪərɪ ˈprəʊsesə/ | 查询处理器 | chá xún chǔ lǐ qì |
Two people, one seat
- In 1960 American Airlines switched on Sabre, the first computer reservation system. Agents in dozens of cities could sell seats on the same flight at the same moment, and the system's one job that mattered was that no seat was ever sold twice.
- A shared file cannot do that: two programs read "seat 14C free", both write "sold", and two passengers arrive at the gate. Something has to sit between every program and the data and referee.
- That referee is the DBMS 数据库管理系统. Every feature in this lesson is a thing the flat files could not do: describe themselves, keep every user's view consistent, enforce the rules, survive a crash, and let one team build applications while another asks questions.
- This lesson is the features the syllabus names and the two software tools it asks you to describe.
两个人,一个座位
- 1960 年,美国航空启用了 Sabre——第一个计算机订票系统。几十个城市的售票员可以在同一时刻卖同一航班的座位,而这个系统唯一要紧的工作是:没有一个座位被卖两次。
- 共享文件做不到:两个程序都读到"14C 座空",都写下"已售",两个乘客到了登机口。必须有个东西坐在每个程序和数据之间当裁判。
- 那个裁判就是 DBMS(数据库管理系统)。这一课的每一个功能,都是平面文件做不到的事:描述自己、让每个用户看到的都一致、执行规则、扛过崩溃,并让一个团队开发应用的同时另一个团队提问。
- 这一课讲大纲点名的功能,以及它要求你描述的两个软件工具。
What a DBMS is
- A database management system is the software that manages the database centrally. Every program and every user reaches the data only through it.
- It answers each file-based limitation: one copy of each fact, so no redundancy or inconsistency; data independence, so programs are not tied to the storage; central integrity, security, backup and access for many users at once.
- The syllabus names five features and two tools. Learn each one as a thing the DBMS does.
DBMS 是什么
- 数据库管理系统是集中管理数据库的软件。每个程序、每个用户只能通过它接触数据。
- 它回应了基于文件方法的每个局限:每个事实一份副本,所以没有冗余和不一致;数据独立性,所以程序不与存储绑定;集中的完整性、安全、备份,以及多用户同时访问。
- 大纲点名五个功能和两个工具。把每一个都当作 DBMS 做的一件事来学。
Database service lab · 数据库服务实验
Watch how a DBMS turns a query into safe shared data access. · 观看 DBMS 如何将查询转化为安全的共享数据访问。
Match each DBMS service to what it does. · 将每个 DBMS 服务与其功能匹配。
A DBMS bundles these services so programs never touch the raw files directly. · DBMS 捆绑了这些服务,因此程序永远不会直接触碰原始文件。
Data management and the data dictionary
- Data management 数据管理 is the DBMS controlling how the data is stored, organised, retrieved and updated, so that programs never touch the files directly.
- It maintains a data dictionary 数据字典: a description of every table, field, data type, key, relationship and constraint, plus who may access what. It is data about the data.
- Programs query the dictionary instead of hard-coding the structure, so a change to a table does not break them. It is also what the DBMS checks when it validates a new record.
数据管理与数据字典
- 数据管理(data management)是 DBMS 控制数据怎样存储、组织、检索和更新,让程序永远不直接碰文件。
- 它维护一份数据字典(data dictionary):对每张表、字段、数据类型、键、关系和约束的描述,以及谁可以访问什么。它是关于数据的数据。
- 程序查询字典而不是把结构写死在代码里,所以对一张表的改动不会弄坏它们。DBMS 验证一条新记录时查的也是它。
A data dictionary in a DBMS holds: · DBMS 中的数据字典包含:
The data dictionary describes the database structure, so programs query it rather than hard-coding the layout. · 数据字典描述数据库结构,因此程序查询它而不是硬编码布局。
Data modelling and the logical schema
- Data modelling 数据建模 is defining the structure of the data: the entities, their attributes, the keys and the relationships, as in an E-R diagram.
- The result is the logical schema 逻辑模式: the overall logical design of the database, its tables and relationships, described independently of how the bytes are stored on disk.
- Because the logical schema is separate from the physical storage, the storage can be reorganised, indexed or moved and the programs still see the same tables.
The programs see tables; the DBMS sees disks
数据建模与逻辑模式
- 数据建模(data modelling)是定义数据的结构:实体、它们的属性、键和关系,就像 E-R 图那样。
- 结果是逻辑模式(logical schema):数据库的整体逻辑设计——它的表和关系——独立于字节在磁盘上怎样存储来描述。
- 因为逻辑模式与物理存储分离,存储可以重组、建索引或迁移,而程序看到的仍是同样的表。

程序看到表;DBMS 看到磁盘
The logical schema of a database describes: · 数据库的逻辑模式描述:
The logical design is separate from the physical storage, which is what lets the storage change without the programs noticing. · 逻辑设计与物理存储是分开的,这使得在不影响程序的情况下更改存储成为可能。
Data integrity and data security
- Data integrity 数据完整性: the DBMS keeps the data correct and consistent by enforcing the rules centrally: primary keys unique and not null, referential integrity on every foreign key, data types, and validation constraints such as a range or a value from a list.
- Data security 数据安全: the DBMS controls who may see and change what. Access rights are given to individual users or to groups, table by table, as read-only, read and write, or no access; passwords authenticate each user; stored data can be encrypted.
- Security also means backup 备份 procedures: regular copies of the database, with a log of changes since, so the data can be recovered after a failure.
数据完整性与数据安全
- 数据完整性(data integrity):DBMS 通过集中执行规则保持数据正确一致:主键唯一且非空、每个外键上的参照完整性、数据类型,以及范围或列表取值这样的验证约束。
- 数据安全(data security):DBMS 控制谁可以看到和更改什么。访问权限按表授予个人用户或用户组——只读、读写或不可访问;密码验证每个用户;存储的数据可以加密。
- 安全还意味着备份(backup)程序:定期复制数据库,并记录此后的更改日志,以便故障后恢复数据。
Which are data-security features of a DBMS? Select all · 所有 that apply. · 哪些是 DBMS 的数据安全功能?选择所有适用项。
Who may access, and recovery after loss, are security. Normalisation is a design step against redundancy. · 谁可以访问以及在丢失后恢复是安全问题。规范化是防止冗余的设计步骤。
Worked example: how the DBMS keeps the data secure
- Describe how a DBMS provides data security. [4]
- Each user has an account and password, so only authorised people log in. The administrator gives each user or group access rights to each table: a clerk may read the prices but not change them; a customer cannot see the staff table at all. A view can present a user with only the fields they need.
- The DBMS runs backup procedures: a regular copy of the database to a separate medium, with a log of transactions since the copy, so a failure or an attack loses no data.
- Security is about who may access; integrity is about the data being correct. Keep them apart when the question names one.
例题:DBMS 怎样保持数据安全
- 描述 DBMS 怎样提供数据安全。[4]
- 每个用户有账户和密码,所以只有获授权的人能登录。管理员给每个用户或用户组对每张表的访问权限:职员可以读价格但不能改;顾客根本看不到员工表。视图可以只向用户呈现他们需要的字段。
- DBMS 运行备份程序:定期把数据库复制到独立介质,并记录复制之后的事务日志,所以故障或攻击不会丢失数据。
- 安全关于谁可以访问;完整性关于数据正确。题目点名其一时,把它们分开。
Many users at once
- Concurrent access 并发访问: many users work on the database at the same time. Concurrency control 并发控制 uses locks so two users cannot update the same record at once and corrupt it: the second waits until the first has finished.
- A transaction 事务 is a group of operations that either all succeed or all fail, so a crash halfway through a transfer never leaves money missing from both accounts.
- A view 视图 is a virtual table, built from a query, that shows each user only their slice of the data.
多用户同时使用
- 并发访问(concurrent access):许多用户同时使用数据库。并发控制(concurrency control)用锁让两个用户不能同时更新同一条记录而弄坏它:第二个等第一个完成。
- 事务(transaction)是一组要么全部成功、要么全部失败的操作,所以转账中途崩溃永远不会让两个账户都少了钱。
- 视图(view)是由查询构建的虚拟表,只向每个用户显示属于他们的那一片数据。
A database transaction is: · 数据库事务是:
Transactions are all-or-nothing, so the database is never left half-updated. · 事务是全有或全无的,因此数据库永远不会处于半更新状态。
Concurrency control (locking) is needed so that: · 需要并发控制(锁定),以便:
Locks stop two simultaneous updates from clashing and corrupting shared data. · 锁防止两个同时更新发生冲突并损坏共享数据。
A transaction is all-or-nothing: it either fully completes (commit) or fully undoes itself (rollback), so the database is never left half-updated. · 事务是全有或全无的:它要么完全完成(提交),要么完全撤销(回滚),因此数据库永远不会处于半更新状态。
This atomicity is why a bank transfer can never debit one account without crediting the other. · 这种原子性意味着银行转账永远不可能只借记一个账户而不贷记另一个账户。
A virtual table (often a saved query) that shows a user only their relevant slice of the data is called a ______. · 显示用户仅查看其相关数据切片的虚拟表(通常是保存的查询)称为 ______。
A view presents a tailored, often restricted, slice of the data without copying it. · 视图呈现定制且通常受限的数据切片,而不复制数据。
Put the events of two users updating the same record under concurrency control in order. · 按顺序排列在并发控制下两个用户更新同一条记录的事件。
The lock serialises the two updates so neither overwrites the other's change. · 锁序列化这两个更新,以防一方覆盖另一方的更改。
The software tools
- The developer interface 开发者接口 is the set of tools and programming interfaces for building applications on the database: a form builder for data entry, a report generator, a query builder, an SQL editor, a data-dictionary editor, and APIs that let a program in Python or Java send SQL and receive results.
- The query processor 查询处理器 takes a query written in SQL, checks it against the data dictionary, works out the most efficient way to run it, executes it and returns the result set.
- The user who types a query and the programmer who builds the booking form are both using the DBMS; one through the query processor, the other through the developer interface.
软件工具
- 开发者接口(developer interface)是在数据库上构建应用的一组工具和编程接口:用于数据输入的表单构建器、报表生成器、查询构建器、SQL 编辑器、数据字典编辑器,以及让 Python 或 Java 程序发送 SQL 并接收结果的 API。
- 查询处理器(query processor)接收用 SQL 写的查询,对照数据字典检查,算出最高效的执行方式,执行它并返回结果集。
- 输入查询的用户和构建订票表单的程序员都在使用 DBMS;一个通过查询处理器,一个通过开发者接口。
Match each DBMS component to its job. · 将每个 DBMS 组件与其工作匹配。
Running queries, building applications, describing the structure, and the design itself: four different things the exam names separately. · 运行查询、构建应用程序、描述结构和设计本身:这是考试中单独命名的四件不同事情。
Worked example: the two tools in use
- A shop's database is used by the manager, who needs sales totals, and by a programmer writing a stock-control application. Explain how the query processor and the developer interface are used.
- The manager writes or builds a query for the sales totals; the query processor parses it, uses the data dictionary to check the tables and fields exist, chooses the fastest way to run it, executes it and returns the results.
- The programmer uses the developer interface: the form and report builders to make the stock screens, and the API so the application's code can send SQL to the DBMS and receive the records back.
- Two marks each: what the tool is, and what this person does with it.
例题:两个工具的使用
- 一家商店的数据库由需要销售总额的经理和正在编写库存控制应用的程序员使用。解释查询处理器和开发者接口怎样被使用。
- 经理写出或构建一个求销售总额的查询;查询处理器解析它,用数据字典检查表和字段存在,选择最快的执行方式,执行并返回结果。
- 程序员使用开发者接口:用表单和报表构建器做库存界面,用 API 让应用的代码向 DBMS 发送 SQL 并取回记录。
- 每个两分:工具是什么,以及这个人用它做什么。
Marks that slip away
- The DBMS is the software, not the data. "The DBMS holds the customer records" is wrong; it manages them.
- The data dictionary holds data about the data: structures, types, keys, rights. Not the records themselves.
- The logical schema is the design independent of physical storage. Say that phrase.
- Security is who may access; integrity is the data being correct. Backup belongs to security.
容易丢掉的分
- DBMS 是软件,不是数据。"DBMS 保存客户记录"是错的;它管理它们。
- 数据字典保存关于数据的数据:结构、类型、键、权限。不是记录本身。
- 逻辑模式是独立于物理存储的设计。要说出这个短语。
- 安全是谁可以访问;完整性是数据正确。备份属于安全。
You've got it
- a DBMS is the software every program goes through: one copy of each fact, data independence, central rules
- data management with a data dictionary (data about the data) · data modelling producing the logical schema (the design independent of storage) · data integrity (rules enforced) · data security (access rights to users and groups, passwords, encryption, backups)
- concurrency control with locks, transactions that are all-or-nothing, views that show a user their slice
- tools: the developer interface for building applications, the query processor for running SQL
你掌握了
- DBMS 是每个程序都要经过的软件:每个事实一份副本、数据独立性、集中的规则
- 带数据字典(关于数据的数据)的数据管理 · 产出逻辑模式(独立于存储的设计)的数据建模 · 数据完整性(执行规则)· 数据安全(对用户和组的访问权限、密码、加密、备份)
- 用锁的并发控制、全有或全无的事务、只显示用户那一片的视图
- 工具:构建应用的开发者接口,运行 SQL 的查询处理器