First exams 2027 · SL & HL2027 年首次开考 · SL 与 HL

A3.2.7 · Database design

A3.2.7 · 数据库设计

Evaluating the need for denormalizing databases

评价反规范化数据库的必要性

A live banking system and a weather-analytics dashboard both store data, but the right amount of normalization for one is close to wrong for the other, this statement is about weighing that decision, not just knowing the definitions.

实时银行系统和天气分析仪表盘都存储数据,但对其中一个合适的规范化程度,对另一个几乎是错的,这条陈述讲的是权衡这个决定,而不只是知道定义。

Core for SL & HL Command term: evaluate Builds on A3.2.5 & A3.2.6
SL 与 HL 核心内容 指令词:evaluate 建立在 A3.2.5 与 A3.2.6 之上

Explainer

讲解

A3.2.5 and A3.2.6 both pushed in one direction: normalize, remove redundancy, split tables apart. This statement asks the opposite question on purpose: when is a fully normalized design actually the WRONG choice? "Evaluate" means weighing both sides and reaching a judgement, not just listing pros and cons.

A3.2.5 和 A3.2.6 都朝同一个方向推进:规范化,消除冗余,把表拆开。这条陈述有意提出相反的问题:什么时候完全规范化的设计其实是错误的选择?"Evaluate(评价)"意味着权衡双方并得出判断,而不只是列出优缺点。

Df

Denormalization is doing A3.2.5 and A3.2.6 in reverse, on purpose. The redundancy those statements taught you to remove gets deliberately reintroduced, not because someone made a mistake, but because a specific query pattern will run faster with the duplicate right there than it would having to fetch it fresh from another table every time.

反规范化(denormalization)是有意地把 A3.2.5 和 A3.2.6 倒过来做。那些陈述教你消除的冗余被刻意重新引入,不是因为谁犯了错,而是因为某种特定的查询模式,在重复的数据就在手边时,会比每次都得从另一张表重新取来要快。

The trade-off, both sides

权衡,两个方面

Normalization规范化

Real example: a banking system processing live transfers, every balance must always be exactly correct, right now, for every user checking it.

实际例子:一个处理实时转账的银行系统,每个用户查看时,每个余额都必须随时完全正确。

Advantages

优点

  • Minimizes data redundancy (each fact stored once, less storage, no risk of two copies disagreeing)
  • 把数据冗余降到最低 (每个事实只存一次,占用存储更少,也不会有两个副本互相矛盾的风险)
  • Ensures data integrity (insert, update and delete rules stay consistent and enforceable)
  • 确保数据完整性 (插入、更新和删除的规则保持一致,并且可以强制执行)
  • Supports scalability (new data added without restructuring what already exists)
  • 支持可扩展性 (加入新数据时,不必重构已有的内容)

Disadvantages

缺点

  • More complex schema (many small tables and relationships are harder to understand and maintain)
  • 模式更复杂 (许多小表和关系更难理解和维护)
  • Slower reads (queries need joins across several tables, which costs performance)
  • 读取更慢 (查询需要跨好几张表做连接,这会消耗性能)
Denormalization反规范化

Real example: a weather-analytics dashboard generating historical reports, the data was recorded once and never changes again, it only ever gets read.

实际例子:一个生成历史报表的天气分析仪表盘,数据只记录一次,之后不再改变,只会被读取。

Advantages

优点

  • Improved query performance (a value already sitting in the row you need beats fetching it through a join, every time)
  • 查询性能更好 (一个值已经就在你需要的行里,每次都胜过通过连接去取)
  • Simplified data retrieval (the table's shape ends up matching what the application actually asks for, instead of forcing it to reassemble the answer from several places)
  • 简化数据检索 (表的形状最终与应用程序实际所问的相匹配,而不是迫使它从好几个地方重新拼出答案)
  • Enhanced scalability for reads (more read traffic doesn't mean more relationships to chase, because there are fewer of them to begin with)
  • 增强读取方面的可扩展性 (读取流量增加,并不意味着要追踪更多关系,因为本来要追的就更少)

Disadvantages

缺点

  • Data redundancy (the same fact stored more than once, at real storage cost)
  • 数据冗余 (同一个事实被存了不止一次,带来真实的存储成本)
  • Update risk (if an update misses one of the duplicate copies, the data quietly disagrees with itself)
  • 更新风险 (如果某次更新漏掉了其中一个重复副本,数据就会悄悄地自相矛盾)

Where denormalization specifically pays off

反规范化具体在哪里能带来回报

Read-intensive situations

读取密集的情形

  • Read-intensive applications: when a system spends nearly all its time being queried and almost none being written to, every join it can skip is time saved on every single request.
  • 读取密集型应用:当一个系统几乎所有时间都在被查询、几乎没有写入时,它能跳过的每一次连接,都在每个请求上节省了时间。
  • Reporting and analytics: a report that has to sweep across a large dataset already does a lot of work, dragging several tables together for every row of it just adds more.
  • 报表与分析:一份必须扫描大型数据集的报表本来就做了很多工作,每一行都要把好几张表拼到一起,只会增加更多的工作。
  • Data warehousing: once data has been pulled in from several source systems for analysis, keeping it pre-combined means a cross-source question doesn't have to redo that combining on every query.
  • 数据仓库:数据从多个来源系统拉进来用于分析之后,把它预先合并好,意味着一个跨来源的问题不必在每次查询时重做一遍合并。

Finding the actual balance

找到真正的平衡点

Denormalization trades a straightforward, fast-to-write query structure against the real risk of redundant data drifting out of sync. Reaching a genuine evaluation, not just a guess, means working through this in order:

反规范化是在结构直接、写起来快的查询,与冗余数据失去同步的真实风险之间做的取舍。要得出真正的评价,而不只是猜测,需要按顺序做下面几步:

1

Work out what the system spends most of its time doing: answering read requests, or absorbing a steady stream of updates? Everything else in this process depends on getting this one honestly.

弄清系统大部分时间在做什么:是回答读取请求,还是应对源源不断的更新?这个过程中的其他一切,都取决于你对这一点是否如实判断。

2

Put the speed gain and the inconsistency risk on the same scale: does one genuinely outweigh the other for this specific system? The honest answer is rarely all-or-nothing, denormalizing just the handful of fields that actually get hammered by reads, while leaving the rest properly normalized, is often exactly right.

把速度的提升和不一致的风险放在同一个尺度上:对这个具体的系统来说,其中一个是否真的盖过了另一个?诚实的答案很少是非此即彼,只对真正被读取反复冲击的少数字段做反规范化,而让其余部分保持规范化,往往恰恰是对的。

3

Decide, before going ahead, how the risk from step 2 actually gets managed: what checks catch a value going out of sync, who is watching whether the performance win is holding up over time, and what the actual procedure is for updating every duplicate copy together instead of just one.

在动手之前,决定第 2 步中的风险究竟如何管理:用什么检查来发现某个值失去了同步,由谁来关注性能收益是否能长期保持,以及把所有重复的副本一起更新、而不是只更新一个的实际流程是什么。

Worked example

例题讲解

Same three questions, two systems, two different verdicts

同样的三个问题,两个系统,两种不同的结论

Both databases store real, useful data. Walking through the same balancing questions gives each one a genuinely different answer, that's what "evaluate" actually looks like in practice.

两个数据库存储的都是真实有用的数据。用同样的权衡问题走一遍,每个得到的答案却真正不同,这就是"评价"在实践中的样子。

Weather-analytics dashboard

天气分析仪表盘

Historical weather readings from hundreds of stations, joined against station and region details, to generate charts and reports. Data is recorded once and essentially never edited again.

来自数百个气象站的历史天气读数,与站点和地区的详细信息连接起来,生成图表和报表。数据只记录一次,之后基本不会再被编辑。

Read or update focus?Almost entirely read, reports run constantly, updates are rare.
重读取还是重更新?几乎完全是读取,报表不断运行,更新很少。
Benefit vs redundancy risk?High benefit: flattening station and region details into each reading avoids repeated joins on every single report. Low risk: since readings are never edited, duplicated station/region data can't drift out of sync.
收益与冗余风险相比如何?收益高:把站点和地区的详细信息铺平到每条读数里,避免了每份报表上重复的连接。风险低:因为读数从不被编辑,重复的站点/地区数据不会失去同步。
Mitigation needed?Minimal, since the data is effectively read-only once recorded.
需要什么缓解措施?极少,因为数据一旦记录就基本是只读的。
Denormalize反规范化

The performance win is large and the redundancy risk is genuinely low here, a clear case for a flattened, read-optimized design.

这里性能收益很大,而冗余风险确实很低,是采用铺平的、为读取优化的设计的明确例子。

Live ticket-booking system

实时订票系统

A theatre's seat-booking system, where every seat's availability must update instantly and correctly the moment it's booked or released, for every user viewing the seating map at once.

一家剧院的座位预订系统,其中每个座位的可用状态必须在被预订或释放的那一刻立即、正确地更新,让每一位同时查看座位图的用户都能看到。

Read or update focus?Heavily update-driven, seat status changes constantly and must always be current.
重读取还是重更新?以更新为主,座位状态不断变化,必须始终是最新的。
Benefit vs redundancy risk?Low benefit: seat lookups are already fast on a normalized schema. High risk: duplicating seat-availability data risks two customers being shown the same seat as free, a direct double-booking.
收益与冗余风险相比如何?收益低:在规范化的模式上,座位查询本来就很快。风险高:重复存储座位可用性数据,可能让两位顾客看到同一个座位都是空闲的,直接造成重复预订。
Mitigation needed?Would be substantial if denormalized, real-time synchronization across every redundant copy, on every single booking.
需要什么缓解措施?如果做了反规范化,需要大量的措施:每次预订时,对每个冗余副本进行实时同步。
Stay normalized保持规范化

The redundancy risk (double-booked seats) outweighs a performance gain the system doesn't actually need here.

冗余风险(座位被重复预订)盖过了一个系统其实并不需要的性能收益。

Check your understanding

检查你的理解

Which system is the stronger candidate for denormalization?

哪个系统是反规范化的更强候选?

Common mistake

常见错误

Markers reported this pattern for A3.2.7
阅卷员反馈了 A3.2.7 的这一常见模式

RecurringThe command term "evaluate" means weighing both sides and reaching a justified judgement. Candidates often answer with only one side, either listing denormalization's benefits with no mention of the redundancy risk, or the reverse, when the actual mark scheme rewards a genuine balance, tied to the specific scenario given.

反复出现指令词 "evaluate" 的意思是权衡双方并得出有依据的判断。考生常常只写一面,要么只列出反规范化的好处而不提冗余风险,要么反过来,而实际的评分标准奖励的是与所给具体情境相联系的真正平衡。

✕

What a weak answer looks like: "Denormalizing the reporting database would make queries faster." True, but one-sided, no mention of the redundancy risk being weighed against that benefit, and no judgement reached.

较弱的答案是这样的:"对报表数据库做反规范化会让查询更快。"没错,但只说了一面,没有提到要拿冗余风险与这个好处相权衡,也没有得出判断。

✓

What it should say: "Denormalizing would make the reporting queries faster by removing joins, and since this data is read-only once recorded, the usual redundancy risk barely applies here, so the performance benefit clearly outweighs the cost in this specific case." States both sides AND reaches a justified verdict.

应该这样写:"反规范化通过去掉连接,会让报表查询更快;而且这些数据一旦记录就是只读的,通常的冗余风险在这里几乎不适用,所以在这个具体情况下,性能收益明显盖过成本。"陈述了双方,并且得出了有依据的结论。

Revision questions

复习题

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

仿真题风格。先写出你的答案,再显示评分要点并给自己打分。

Question 1 · 2 marks第 1 题 · 2 分

[2]The weather-analytics dashboard stores each station’s name alongside every reading. Identify two problems this repetition could cause.

[2]天气分析仪表盘把每个气象站的名称和每条读数存放在一起。指出这种重复可能造成的两个问题。

Question 2 · 3 marks第 2 题 · 3 分

[3]Explain why the live banking system is kept fully normalized, referring to two specific characteristics of a normalized design.

[3]解释为什么实时银行系统要保持完全规范化,并联系规范化设计的两个具体特点。

Question 3 · 6 marks第 3 题 · 6 分

[6]A national census database stores historical population records that are published once and never edited afterward, but are queried constantly for public statistics. Evaluate the need for denormalizing this database.

[6]一个全国人口普查数据库保存历史人口记录,这些记录一经发布就不再编辑,但会被公众统计查询不断访问。评价对这个数据库做反规范化的必要性。

Flashcards

闪卡

Active recall for this statement's key terms.

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

Prototype render. Content grounded in the IB CS 2027 syllabus's A3.2.7 section (normalization/denormalization advantages and disadvantages, the three read-intensive scenarios, the balancing process); the weather-dashboard and ticket-booking worked examples are original, built to demonstrate the evaluation itself. Not yet wired to live routes.