Home › Theme A › A3 › A3.4 › A3.4.1

A3.4.1 Other kinds of database: NoSQL, cloud, spatial and more

HL onlyCommand term: Outline

1. Four other ways to store data

Relational tables are not the only approach. Press Next to see the same kind of data stored in NoSQL databases, then cloud, spatial and in-memory databases.

2. Spatial database lab: what is near me?

Click the map to set your location, then change the search radius. A spatial database answers this with a spatial index and distance functions.

Search radius

3. In-memory database lab: speed and volatility

Run 1,000 lookups on the same data stored in RAM, on an SSD and on a hard disk. Then cut the power.

In-memory (RAM): about 0.1 µs per lookup
Disk-based on SSD: about 100 µs per lookup
Disk-based on hard disk: about 10 ms per lookup
Press Run. (Times are typical orders of magnitude; the bar lengths use a log scale.)

4. Flip-card deck

Click to flip. Say the answer before you flip.

5. Choose the database

Which approach fits each real-world system best? Streaks of 3+ score double.

Round 0/10Score 0Streak 0Best 0
Press start!

6. 45-second speed round: which model?

A feature appears. Which database model is it describing?

Time 45sScore 0Streak 0Best 0
Press start!

Learning objectives

By the end of this page you should be able to:

  1. Outline why approaches other than relational databases are used.
  2. Outline NoSQL databases and the main NoSQL types.
  3. Outline cloud, spatial and in-memory databases.
  4. Identify real-world uses of each model, such as e-commerce, GIS, real-time analytics, social media and SaaS.
  5. Select a suitable database model for a given scenario.

Why other approaches?

Relational databases are excellent for structured data, strict rules and ACID transactions. But some systems hold huge amounts of varied data, must scale across many servers, store locations, or need answers in microseconds. Other database models are designed for these jobs (see the limitations in A3.1.1).

The four models

ModelHow data is storedStrengthsLimitationsReal-world uses
NoSQL (“not only SQL”)Not in fixed tables. Four main types: document (JSON-like documents, e.g. MongoDB), key-value (a key and its value, e.g. Redis), wide-column (rows with flexible columns, e.g. Cassandra), graph (nodes and relationships, e.g. Neo4j).Flexible / no fixed schema; handles unstructured and semi-structured data; scales out horizontally across many servers; fast for simple lookups at huge scale.Often weaker consistency (eventual consistency rather than full ACID); joins and complex queries are harder; data may be duplicated; less standardised query languages.Social media platforms, e-commerce product catalogues, recommendations (graph), user profiles, big data.
CloudThe database runs on a provider's servers and is used over the internet. Often a managed service (database as a service, DBaaS), e.g. Amazon RDS, Azure SQL, Google Cloud Firestore. Can be relational or NoSQL.No hardware to buy; scales up or down on demand; pay as you go; the provider handles backups, updates, security patches and replication; accessible from anywhere.Needs a reliable internet connection; ongoing costs; less control; data privacy and location (which country) concerns; vendor lock-in.SaaS applications, managed services, startups, apps used in many countries, school management systems.
SpatialStores geometry: points, lines and polygons with coordinates, plus spatial indexes (e.g. an R-tree). Often an extension of a relational database, e.g. PostGIS.Answers location questions fast: distance, nearest neighbour, “within 2 km”, “inside this area”, intersections.Specialised and more complex; large geometric data needs a lot of storage and processing.Geographic information systems (GIS), maps, ride-hailing and delivery apps, urban planning, environmental monitoring.
In-memoryKeeps the data in main memory (RAM) rather than on disk, e.g. Redis, SAP HANA, Memcached.Extremely fast reads and writes (RAM is much faster than disk); ideal for real-time processing.RAM is volatile: data is lost on power failure unless saved with snapshots or logs; RAM is expensive, so size is limited.Real-time analytics, caching, session storage, gaming leaderboards, trading systems.

The four NoSQL types in one line each

  • Document: each record is a self-contained document; different documents can have different fields.
  • Key-value: the simplest: look up a value by its unique key, very fast.
  • Wide-column: rows grouped into column families; each row can have different columns; good for huge write volumes.
  • Graph: nodes (people, products) and edges (FRIENDS_WITH, BOUGHT); good for following relationships.

These models are not exclusive: a cloud provider may host a NoSQL in-memory database, and a spatial database is usually relational. Choose the approach that fits the data and how it is used.

Use the 中文 button at the top to show or hide the Chinese terms.

Term中文Meaning

Choose an answer. You get instant feedback.

Score: 0 /

Write your answer first, then reveal the markscheme. These are exam-style practice questions written for this site.

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

A database that does not store data in fixed relational tables [1]; it uses another model such as documents, key-value pairs, wide columns or graphs, with a flexible schema [1].

2. State two advantages of using a cloud database for a small company. [2]

Any two, [1] each: no need to buy or maintain hardware; pay only for what is used; scales easily as the company grows; backups / updates / security handled by the provider (managed service); accessible from anywhere with internet.

3. Outline one disadvantage of an in-memory database. [2]

RAM is volatile [1], so data can be lost if the power fails unless it is saved with snapshots / logs to disk [1]. OR RAM is expensive [1], so the amount of data that can be held is limited / costly [1].

4. A food delivery app must find the five nearest drivers to each customer. Explain why a spatial database is suitable. [3]

It stores locations as geometric data / points with coordinates [1]; it provides spatial functions such as distance and nearest-neighbour queries [1]; spatial indexes (e.g. R-tree) make these searches fast even with many drivers moving in real time [1].

5. A social media platform stores posts that may contain text, images, polls or videos, for hundreds of millions of users. Explain why a NoSQL document database may be chosen instead of a relational database. [4]

Posts have different structures, and a document database has a flexible schema, so each post can have different fields without changing a table design [1]. A post and its comments can be stored together in one document, so it can be read in one operation without joins [1]. NoSQL databases scale horizontally across many servers to handle huge numbers of users [1]. They can give high availability / fast reads at large scale, accepting eventual consistency, which is acceptable for posts and likes [1].

6. Outline how each of the following could be used by an online shop: a NoSQL database, a cloud database, an in-memory database. [6]

Award up to [2] for each. NoSQL: product catalogue where products have different attributes / storing customer reviews or recommendations [1] because of the flexible schema / scalability [1]. Cloud: hosting the shop's database with a provider [1] so it can scale during busy periods (e.g. sales) and backups are managed [1]. In-memory: caching popular products / shopping carts / sessions [1] for very fast responses / real-time analytics of current sales [1].