First exams 2027 · HL only 2027 年首次开考 · 仅限 HL

A3.4.4 · Alternative databases and data warehouses

A3.4.4 · 其他数据库与数据仓库

Features of distributed databases

分布式数据库的特性

Northlyne Parcel Express runs a depot in every major city it serves. A driver scanning a parcel in Leeds and a customer checking that same parcel's status from a phone in Lagos both need the true, current answer, from machines that have never been in the same room.

Northlyne 包裹速递公司在其服务的每个主要城市都设有一个仓库。一名在利兹扫描包裹的司机,与一名在拉各斯用手机查询同一包裹状态的客户,都需要得到真实、最新的答案,而这两台机器从未处于同一个房间。

HL only 仅限 HL Command term: describe 命令词:describe(描述) Builds on A3.4.1 建立在 A3.4.1 基础上

Explainer

讲解

Every depot Northlyne runs has its own local server handling scans, bookings and deliveries for that city. None of them is the "real" database with everyone else just a copy of it, they are all genuinely part of the same system, spread across separate machines that might sit on entirely different networks, in entirely different countries.

Northlyne 运营的每个仓库都有自己的本地服务器,处理该城市的扫描、预订与配送。它们之中没有哪一个是"真正的"数据库、其他都只是它的副本,它们实际上都是同一个系统真正的一部分,分布在不同的机器上,这些机器可能位于完全不同的网络、完全不同的国家。

Df

A distributed database is made up of two or more separate data stores, sitting on different machines, possibly on different networks entirely, that together present one seamless database to whoever is using it. The pieces are physically apart. The experience of using them is not.

一个分布式数据库由两个或更多个独立的数据存储组成,它们位于不同的机器上,可能分属完全不同的网络,但共同向使用者呈现为一个无缝衔接的数据库。各部分在物理上是分开的,但使用体验并非如此。

This pattern shows up wherever an organization is naturally spread out already: a retail chain keeping stock, orders and catalogue data in sync across warehouses scattered across a country, or a phone network tracking subscriptions and call routing across every region it covers. Northlyne's depot network is the same shape of problem.

这种模式出现在任何本身就自然分散的组织中:零售连锁企业在遍布全国的多个仓库之间同步库存、订单与目录数据,或电话网络在其覆盖的每个区域追踪用户订阅与通话路由。Northlyne 的仓库网络正是同样形态的问题。

!

Why consistency is the hardest part of any of this. The moment data lives in more than one place, those copies can disagree. A parcel marked delivered at the Leeds depot but still showing "in transit" from Lagos is not a cosmetic glitch, it is a decision-making problem, a trust problem, and if left unresolved, a data-integrity problem that gets worse the longer it sits. Keeping every node's view of the truth aligned is what most of the rest of this statement exists to solve.

为什么一致性是这其中最难的部分。一旦数据存在于不止一处,这些副本就可能出现分歧。一个在利兹仓库被标记为已送达、但从拉各斯查询仍显示"运输中"的包裹,这不是表面上的小问题,而是一个决策问题、一个信任问题,若不加以解决,还会演变成一个随时间推移而愈发严重的数据完整性问题。让每个节点对真实情况的认知保持一致,正是本考纲陈述其余大部分内容要解决的问题。

Explainer

讲解

ACID, stretched across every node involved

延伸到每个相关节点的 ACID

A3.3.6 covered ACID for a transaction running on one machine. Spread that same transaction across several machines at once, and each property has to work harder to mean the same thing.

A3.3.6 讲解了单台机器上运行的事务所需具备的 ACID 特性。将同一事务分散到多台机器上同时进行时,每一项特性都必须更努力地才能保持同样的含义。

A

Atomicity

原子性

One node succeeding while another fails is not a partial win, it is a failure for the whole transaction. Every node touched has to agree to commit before any of them actually does, or the entire thing rolls back everywhere at once.

一个节点成功而另一个失败,不是一次部分的成功,而是整个事务的失败。所有涉及的节点必须先一致同意提交,才有任何一个节点真正执行提交,否则整件事就会在所有节点上同时回滚。

C

Consistency

一致性

Once the transaction finishes, every node holding a copy of the affected data has to report the same value if asked. A depot in Leeds and a depot in Lagos cannot be allowed to give two different answers about the same parcel.

事务完成后,任何持有受影响数据副本的节点在被查询时都必须报告相同的值。利兹的仓库与拉各斯的仓库绝不能对同一个包裹给出两个不同的答案。

I

Isolation

隔离性

Two transactions on two different nodes are never allowed to touch the same piece of shared data at the same instant. One has to finish, visibly, before the other is allowed to start working with it.

两个不同节点上的事务绝不允许在同一瞬间触碰同一份共享数据。必须有一个明确完成之后,另一个才能开始处理这份数据。

D

Durability

持久性

A committed change has to survive even if the specific node that first recorded it goes offline five minutes later, because it was already copied out to other nodes before that commit was confirmed.

即使最初记录该更改的那个节点在五分钟后离线,已提交的更改也必须继续存在,因为在提交被确认之前,它已经被复制到了其他节点。

Explainer

讲解

Ten features, one at a time

十项特性,逐一讲解

Click through each one. Several of them are really different angles on the same underlying problem, spreading data out without losing the guarantees a single database would have given for free.

逐一点击查看。其中好几项其实是同一个根本问题的不同角度:如何在数据分散存放的同时,不失去单一数据库本可轻松提供的各项保证。

Worked example

示例讲解

One parcel scan, several features working at once

一次包裹扫描,多项特性同时运作

A driver in Leeds scans parcel NLX-88214 as delivered. Watch how many of the ten features that single scan actually touches before it's done.

一名利兹的司机将包裹 NLX-88214 扫描为已送达。看看这一次扫描在完成之前,实际会触及十项特性中的多少项。

1

Data partitioning means the Leeds node already holds most of what it needs locally, parcels routed through Leeds live primarily on the Leeds node, so the scan doesn't have to reach across the network just to find the record.

数据分区意味着利兹节点本地就已保存了它所需的大部分数据,经由利兹转运的包裹主要存放在利兹节点上,因此这次扫描不需要跨越网络才能找到记录。

2

Concurrency control steps in because the same parcel record is briefly locked while the update is written, in case a second system, say an automated customs check, tries to touch it in the same instant.

并发控制在此时发挥作用,因为在写入更新的短暂过程中,同一条包裹记录会被暂时锁定,以防第二个系统(例如自动海关检查)在同一瞬间试图触碰它。

3

Replication pushes the new "delivered" status out to the other depots and to the customer-facing app's own copy of the data, so the answer is the same no matter where it gets checked from next.

复制将新的"已送达"状态推送到其他仓库,以及面向客户的应用程序自身的数据副本,因此无论接下来从哪里查询,得到的答案都是一致的。

4

Data consistency is what that replication is actually for, once it finishes, Lagos and every other node agree with Leeds, there is no longer a stale "in transit" copy sitting anywhere.

数据一致性正是这次复制真正的目的所在,复制完成后,拉各斯与其他每个节点都与利兹保持一致,不再有任何地方存留过时的"运输中"副本。

5

Fault tolerance covers the case where the Leeds node itself drops offline two minutes later. Because the update was already replicated, the parcel still shows as delivered everywhere else, unaffected by that one machine's outage.

容错性覆盖了利兹节点本身在两分钟后掉线的情况。由于更新已经被复制出去,包裹在其他所有地方仍显示为已送达,不受这台机器故障的影响。

6

Location and distribution transparency are why the driver's handheld scanner and the customer's app never had to know any of this happened. Both just asked "is this parcel delivered?" and got one clean answer, with the depot, the network hop and the replication step entirely hidden from view.

位置透明性与分布透明性正是司机手持扫描器与客户的应用程序完全不需要知道这一切发生过的原因。两者都只是询问"这个包裹送达了吗?",并得到一个干净利落的答案,仓库、网络跳转与复制步骤全部被隐藏在幕后。

Check your understanding

检验你的理解

Northlyne's customer app can look up any parcel without ever needing to know which depot's server actually stores that parcel's record. Which feature is this describing most specifically?

Northlyne 的客户应用程序可以查询任何包裹,而完全不需要知道究竟是哪个仓库的服务器存储了该包裹的记录。这最具体地描述的是哪一项特性?

Common mistake

常见错误

Markers reported this pattern for A3.4.4 考官在 A3.4.4 中报告了这一模式

RecurringDistribution transparency and location transparency get used interchangeably, since both have "transparency" in the name and both are about hiding something from the user. Distribution transparency is the umbrella claim: the whole system behaves like one unified database, full stop. Location transparency is one specific piece of that umbrella: the user never needs to know which physical machine or address actually holds a given piece of data.

反复出现分布透明性与位置透明性常被混用,因为两者名称中都含有"透明"二字,且都关乎向用户隐藏某些内容。分布透明性是总括性的主张:整个系统的表现就像一个统一的数据库,仅此而已。位置透明性是这个总括概念下的一个具体部分:用户永远不需要知道某一条数据究竟存放在哪一台物理机器或哪个地址上。

✕

What a weak answer looks like: "Distribution transparency and location transparency both mean the user doesn't know where the data is." Treats the specific feature as identical to the general one it sits inside.

薄弱答案的样子: "分布透明性与位置透明性都是指用户不知道数据存放在哪里。" 把这个具体特性与它所属的总括概念视为完全相同。

✓

What it should say: "Distribution transparency means the whole distributed system appears as a single, unified database to the user. Location transparency is one part of achieving that, specifically hiding which physical node or server address actually holds the data being requested." Names the general claim, then the specific mechanism, in that order.

应该这样表述: "分布透明性是指整个分布式系统在用户看来就像单一、统一的数据库。位置透明性是实现这一点的部分手段,具体是指隐藏所请求的数据究竟存放在哪一个物理节点或服务器地址上。" 先说明总括性的主张,再说明具体的实现机制,顺序正确。

Linking question

关联问题

A2

To what extent is the effectiveness of the distributed database determined by the network that connects the various tables?

分布式数据库的有效性在多大程度上取决于连接各个表的网络?

Every feature on this page assumes the network between nodes actually works. Replication cannot sync a copy across a link that is down. Concurrency control's locks become a bottleneck if messages between nodes are slow. A network partition can even force a live trade-off between staying available and staying consistent. The database's own design barely matters if the network underneath it can't be trusted, which is exactly what this question is asking about.

本页的每一项特性都假设节点之间的网络确实正常运作。如果链路断开,复制就无法在其间同步副本。如果节点之间的消息传递缓慢,并发控制的锁机制就会成为瓶颈。网络分区甚至可能迫使系统在保持可用性与保持一致性之间做出实时取舍。如果底层网络不可信赖,数据库自身的设计几乎无关紧要,这正是这个问题所要探讨的。

Revision questions

复习题

Past-paper style. Write an answer, then reveal the marking points and mark yourself.

采用历年真题风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 4 marks 第 1 题 · 4 分

[4]Two Northlyne depots scan the same parcel at the same moment. Describe the feature that stops the two updates corrupting each other, and explain how it is achieved.

[4]两个 Northlyne 仓库在同一时刻扫描了同一个包裹。请描述阻止这两次更新相互破坏的特性,并解释它是如何实现的。

Question 2 · 3 marks 第 2 题 · 3 分

[3]Describe the difference between distribution transparency and location transparency.

[3]描述分布透明性与位置透明性之间的区别。

Question 3 · 6 marks 第 3 题 · 6 分

[6]A parcel courier company operates a distributed database across depots in several countries. Describe how atomicity and durability apply to a transaction that updates a parcel's status across multiple nodes.

[6]一家包裹快递公司在多个国家的仓库间运行一个分布式数据库。请描述原子性与持久性如何应用于一个跨多个节点更新包裹状态的事务。

Flashcards

记忆卡片

Active recall for this statement's key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render. Concepts (distributed databases, ACID in a distributed context, and the ten named features) grounded in the IB CS 2027 syllabus's A3.4.4 section; the Northlyne Parcel Express worked example is original, built to reinforce the same features with fresh data rather than reproduce a real course example’s own retailer and telecom examples. Not yet wired to live routes.