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

A3.4.1 · Alternative databases and data warehouses

A3.4.1 · 其他类型数据库与数据仓库

Database models as approaches to storing data

作为数据存储方式的数据库模型

A relational table with fixed columns is one way to store data, not the only way. The moment the data itself changes shape, needs a location, needs speed, or needs to live somewhere other than a company's own server room, a different model does the job better.

拥有固定列的关系型表格只是存储数据的一种方式,而非唯一方式。一旦数据本身的形状发生变化、需要位置信息、需要速度,或者需要存放在公司自有服务器机房以外的地方,另一种模型就能更好地完成这项工作。

HL only 仅 HL Command term: outline 命令词:outline(概述) Builds on A3.1.1 建立在 A3.1.1 的基础上

Explainer

讲解

A3.1.1 defined a relational database: fixed tables, fixed columns, every row of a table shaped the same way. That structure is excellent for data that genuinely is tabular, but not every real problem produces tabular data. A social network's friendships are a web of connections, not a table. A GPS app's roads are shapes, not rows. A live scoreboard needs an answer in microseconds, not however long a disk read takes.

A3.1.1 定义了关系型数据库:固定的表、固定的列,表中每一行的形状都相同。这种结构非常适合真正呈表格形式的数据,但并非每一个真实问题产生的数据都是表格形式的。社交网络中的好友关系是一张关系网,而不是一张表。地图应用中的道路是形状,而不是行。实时计分板需要在微秒级得到答案,而不是等待磁盘读取所需的时间。

Df

A database model is the underlying blueprint a database follows: what shape a piece of data takes, where it physically lives, and which operations are fast versus slow. Pick the wrong blueprint for the job and every query built on top of it fights the structure instead of working with it.

数据库模型是数据库所遵循的底层蓝图:一条数据呈现什么形状、它实际存放在哪里,以及哪些操作快、哪些慢。为某项工作选错了蓝图,建立在其上的每一条查询都会与结构相抗衡,而不是顺应结构工作。

Four models, one at a time

四种模型,逐一介绍

Structural
结构

NoSQL

NoSQL

Built for large volumes and varied, changing data shapes. Not one structure, four distinct sub-types.

专为大数据量以及多变、不断变化的数据形状而设计。并非单一结构,而是四种截然不同的子类型。

Used for: e-commerce, social platforms, real-time analytics.

用途:电子商务、社交平台、实时分析。

Hosting
托管方式

Cloud

云数据库

Runs on a cloud provider's infrastructure instead of an organization's own hardware. Can be SQL or NoSQL underneath.

运行在云服务提供商的基础设施上,而非组织自有的硬件上。底层可以是 SQL 数据库,也可以是 NoSQL 数据库。

Used for: startups, SaaS, managed services.

用途:初创公司、SaaS、托管服务。

Structural
结构

Spatial

空间数据库

Optimized to store and query points, lines, polygons and other shapes in space.

针对存储和查询空间中的点、线、多边形及其他形状进行了优化。

Used for: GIS, mapping, location-based services.

用途:地理信息系统(GIS)、地图绘制、基于位置的服务。

Storage location
存储位置

In-memory

内存数据库

Keeps its data entirely in RAM instead of on disk, trading storage cost for read and write speed.

将数据完全保存在内存(RAM)中而非磁盘上,以存储成本换取读写速度。

Used for: session storage, live leaderboards, front-line caching.

用途:会话存储、实时排行榜、前线缓存。

Ax

Notice the Structural / Hosting / Storage location tags above. These four models are not four points on the same scale, they answer different questions about a database. NoSQL and spatial are about the SHAPE of the data. In-memory is about WHERE the bytes physically sit. Cloud is about WHO runs the servers. A single real system can combine more than one, a spatial database can run in the cloud, an in-memory database can also be a NoSQL key-value store. The mistake callout further down this page is built entirely around this point.

请注意上方的结构 / 托管方式 / 存储位置标签。这四种模型并不是同一条量表上的四个刻度,它们回答的是关于数据库的不同问题。NoSQL 和空间数据库关乎数据的形状。内存数据库关乎字节实际存放在哪里。云数据库关乎谁来运行服务器。一个真实系统完全可以同时结合多种模型:空间数据库可以运行在云端,内存数据库也可以同时是一个 NoSQL 键值存储。本页下方的常见错误提示正是完全围绕这一点展开的。

Explainer

讲解

NoSQL's four types

NoSQL 的四种类型

What unites the NoSQL family is only what it rejects: the fixed grid of rows and columns. Beyond that the four types below have little in common with each other, so treat them as four separate answers to "what shape should this data take?" Click through each one below.

NoSQL 家族唯一的共同点,是它们共同拒绝的东西:固定的行列网格。除此之外,以下四种类型彼此之间几乎没有共同之处,所以请把它们看作对"这份数据应该呈现什么形状"这个问题的四个独立答案。请依次点击下方各项查看。

Explainer

讲解

Cloud databases: two ways to pay for someone else's servers

云数据库:为他人的服务器付费的两种方式

A cloud database runs on a cloud computing platform rather than on hardware the organization owns. Pricing is based on the resources actually used, provisioned on demand. Organizations choose between two models, and the choice is a genuine trade-off.

云数据库运行在云计算平台上,而非组织自有的硬件上。计价方式基于实际使用的资源,按需配置。组织需要在两种模型之间做出选择,这一选择包含真实的取舍。

Self-managed (IaaS, Infrastructure as a Service)

自行管理(IaaS,基础设施即服务)

Real example: Thornwood runs its own PostgreSQL server on a rented virtual machine, and its own engineer configures and patches it.

真实案例:索恩伍德在一台租用的虚拟机上运行自己的 PostgreSQL 服务器,并由自己的工程师负责配置与打补丁。

Advantage

优势

  • Full control (the organization decides the exact database software, version and configuration, not the vendor)
  • 完全控制权(由组织自行决定具体的数据库软件、版本与配置,而非由供应商决定)

Disadvantage

劣势

  • Full responsibility (deployment, administration and maintenance all fall on the organization's own staff, the provider only manages the underlying infrastructure)
  • 承担全部责任(部署、管理与维护全部落在组织自身员工身上,供应商只负责底层基础设施)

Fully managed (DBaaS, Database as a Service)

完全托管(DBaaS,数据库即服务)

Real example: Thornwood's donor platform runs on a managed database service, so no one on staff patches or backs it up.

真实案例:索恩伍德的捐赠者平台运行在一项托管数据库服务上,因此没有员工需要为其打补丁或做备份。

Advantage

优势

  • Minimal admin burden (the vendor is the one who provisions capacity, keeps backups current, scales the hardware and applies patches and upgrades)
  • 管理负担极低(由供应商负责配置容量、保持备份最新、扩展硬件规模,以及应用补丁和升级)
  • Pay-as-you-go (cost follows actual use, well suited to a startup or small organization that cannot predict its load in advance)
  • 按使用量付费(费用随实际使用量而定,非常适合无法提前预测负载的初创公司或小型组织)

Disadvantage

劣势

  • Limited control (the organization cannot reach the underlying infrastructure, and depends entirely on the vendor's own choices and pricing)
  • 控制权有限(组织无法触及底层基础设施,完全依赖供应商自身的选择与定价)
Sp

Spatial databases exist because "where is this relative to that" is a genuinely different kind of question from anything a normal WHERE clause answers. A regular database can compare two numbers instantly, but has no built-in idea of distance, overlap or containment between two shapes, so a spatial database adds its own data types (a point, a line, a polygon, even a 3D shape) and its own indexes and functions purpose-built for exactly those geometric questions. PostGIS and Oracle Spatial are real examples, and GIS, mapping and location-based services are what actually needs this. The cost is that this expertise does not transfer from ordinary SQL, someone on the team has to know it specifically.

空间数据库之所以存在,是因为"这个相对于那个位置在哪里"这类问题,与普通 WHERE 子句能回答的任何问题都截然不同。普通数据库可以瞬间比较两个数字,但对两个形状之间的距离、重叠或包含关系没有内置的概念,因此空间数据库增加了自己的数据类型(点、线、多边形,甚至三维形状)以及专门为这些几何问题而设计的索引和函数。PostGIS 和 Oracle Spatial 就是真实的例子,而地理信息系统(GIS)、地图绘制与基于位置的服务正是真正需要这项能力的领域。代价在于,这项专业知识无法从普通 SQL 中直接迁移过来,团队中必须有人专门掌握它。

Im

In-memory databases skip the disk entirely and keep every byte in RAM, which sounds like a small implementation detail but changes everything about how fast the database feels: reading and writing RAM is orders of magnitude quicker than reading and writing even a fast disk. Redis and Oracle TimesTen are real examples of this. It suits any job where a disk-backed database's extra milliseconds per operation would actually be felt: holding a shopping session while a customer browses, serving a leaderboard that changes every few seconds, or sitting in front of a slower database as a cache.

内存数据库完全跳过磁盘,将每一个字节都保存在内存(RAM)中。这听起来像是一个微小的实现细节,却彻底改变了数据库的响应速度:读写内存的速度比读写即便是高速磁盘也要快上几个数量级。Redis 和 Oracle TimesTen 就是真实的例子。它适用于任何一种基于磁盘的数据库多出的那几毫秒延迟会被真切感受到的场景:在顾客浏览时保存购物会话、为每隔几秒就变化一次的排行榜提供数据,或是作为缓存层置于速度较慢的数据库前面。

Worked example

Thornwood Wildlife Trust: one organization, six database jobs

Thornwood runs a nature reserve. Six different parts of its platform each store a different kind of data, and each one runs on the model best suited to its own job. Click a card to see which model, and why.

Check your understanding

A company needs to store road networks and building footprints, then run queries like "which buildings are within 200 metres of this road." Which database model is built for exactly this?

Common mistake

Markers reported this pattern for A3.4.1

RecurringCandidates frequently treat "cloud" as if it were a fifth structural type sitting alongside NoSQL, spatial and in-memory, describing it in the same terms as the others ("cloud databases store data as..."). Cloud is not a data structure at all, it describes WHERE a database runs and WHO manages it. A cloud database can be relational, or any of the four NoSQL types, or spatial, or in-memory.

✕

What a weak answer looks like: "The four database models are NoSQL, cloud, spatial and in-memory, each storing data in its own structure." This treats cloud as a structure, when it names a hosting arrangement instead.

✓

What it should say: "NoSQL, spatial and in-memory describe how data is structured or stored. Cloud describes where a database runs and who manages it, and a cloud database can itself be relational, NoSQL, spatial or in-memory underneath." Naming the distinction directly, rather than listing all four as if they were the same kind of thing, is what separates the two answers.

Linking question

A4

What processes are needed to store data in database structures so that they can be used in machine learning?

A machine learning model cannot train on whatever shape data happens to arrive in, it needs consistent, structured records first. The choice of database model on this page is part of that process: a document database's flexible, semi-structured records or a wide-column store's sparse rows still have to be extracted, cleaned and reshaped into a fixed feature set before any model can use them, a step this page's models make easier or harder depending on how close their native structure already is to that target shape.

Revision questions

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

Question 1 · 2 marks

[2]Outline what is meant by a NoSQL database.

Question 2 · 4 marks

[4]Outline two differences between a document database and a wide-column store database.

Question 3 · 5 marks

[5]A ride-booking startup needs to store live vehicle locations for a city map, and also needs fast, low-cost hosting with minimal in-house administration. Outline which database models suit each requirement, and justify your choice.

Flashcards

Active recall for this statement's key terms.