← IB Computer Science

A3.4 · Book pp. 195–203

Alternative databases and data warehouses

HL only This whole section is for Higher Level students.

Tables are not the answer to everything. Friends lists, live game scores and years of sales data each call for a different tool.

What you need to know

PointTopic
A3.4.1Types of databases as approaches to storing data
A3.4.2Primary objectives of data warehouses
A3.4.3The role of OLAP and data mining
A3.4.4Features of distributed databases

Next: types of database →

A3.4.1 Types of databases

NoSQL databases

NoSQL databases handle large volumes and many data types, and they store data differently from tables.

TypeStoresUsed forStrengthWeaknessExample
DocumentJSON-like documents of fields and valuesContent management, online shopsFlexible, and handles hierarchies wellRedundancy and inconsistencyMongoDB
Key-valueKey and value pairsCaching, sessions, real-time dataSimple, with very fast reads and writesLimited queryingRedis
Wide-columnRows with dynamic columnsBig data, real-time analyticsScales out, and suits sparse dataComplex to implementCassandra
GraphNodes and edgesSocial media, recommendationsGreat for complex relationshipsSpecialized query languageOrientDB

🔬 Lab: one customer, four shapes

{
  "id": "12345",
  "name": "Mali",
  "address": { "street": "Sukhumvit 12", "city": "Bangkok" },
  "services": ["transport", "tourism"]
}

Other database types

TypeWhat it isStrengthWeakness
CloudRuns on a cloud platform, either self-managed or as a managed serviceScalable and available, paying for what you useDepends on the provider, and can cost more
SpatialStores points, lines, polygons and coordinatesEfficient for maps, GIS and location servicesComplex types needing specialist knowledge
In-memoryKeeps data in RAM rather than on diskExtremely fast, for caching, gaming and live analyticsRAM costs more, and needs a plan for power loss

A self-managed cloud database gives you full control of the database, while the provider runs the infrastructure. A managed service has the vendor handle backups, scaling and patching.

✏️ Book correction

The book gives “low latency” as a drawback of in-memory databases. Low latency means little delay, which is a benefit. The real drawbacks are the cost of RAM and the risk of losing data in a power failure.

Next: data warehouses →

A3.4.2 Data warehouses

A data warehouse stores large amounts of historical data from many sources for analysis, not for day-to-day transactions.

Append-onlyNew versions are added as rows, not overwritten, so change can be studied
Subject-orientedOrganized around themes such as sales or finance
IntegratedCombines many sources through ETL into a single source of truth
Time-variantKeeps history, which allows trend analysis
Non-volatileData is rarely changed or deleted once loaded
Optimized for queriesChooses efficient strategies for fast analysis

🔬 Lab: ETL

Taking care with ETL

  • Extraction must not disrupt the source system.
  • Different formats must be converted into something readable.
  • Extracted data must be relevant to what users need.

Next: OLAP and data mining →

A3.4.3 OLAP and data mining

Business intelligence uses technology to collect, analyse and present information for better decisions.

Online analytical processing (OLAP)

OLAP lets users interactively explore data across dimensions such as time, product and region. Summaries are pre-aggregated, so they come back quickly and can feed charts and dashboards.

🔬 Lab: slice the sales data

Sales in thousands of baht (made-up figures). Each view is the same data, seen from another dimension.

Data mining

Data mining finds hidden patterns in large data sets using statistics and machine learning, for forecasting, customer segmentation and fraud detection.

TechniqueWhat it doesUsed for
ClassificationSorts data into known labels (supervised)Spam detection, credit scoring
ClusteringGroups similar data with no labels (unsupervised)Market segmentation
RegressionPredicts a continuous numberSales forecasts, prices
Association rulesFinds items that occur togetherCross-selling recommendations
Sequential patternsFinds events that occur in a certain orderClickstream analysis
Anomaly detectionFinds rare, unusual dataFraud, equipment failure

Next: distributed databases →

A3.4.4 Distributed databases

A distributed database keeps its data on different sites, yet users see one unified database. Online shops and telecoms companies use them across regions.

ACID across nodes

AtomicityA transaction commits on all nodes or is rolled back on all
ConsistencyAll nodes see the same data afterwards
IsolationTransactions on different nodes cannot interfere
DurabilityCommitted work is stored and replicated across nodes

Features

Concurrency controlManages simultaneous changes with locks or timestamps
Data consistencyAll copies reflect the latest correct state
Data partitioningSplits data across nodes for speed and scale
Data securityEncryption, roles and multifactor authentication
Distribution transparencyUsers work as if it were one database
Location transparencyUsers need not know where data is stored
Fault toleranceKeeps working through failures, using redundancy
Global query processingCoordinates queries across several nodes
ReplicationKeeps copies on several nodes for availability
ScalabilitySpreads a growing load over more nodes

🔬 Lab: the lost update

Two nodes each add to a stock level of 10: one adds 5, the other adds 3. The right answer is 18.

Choose a run.

Next: review →

Quick quiz

1. A social network wants to find friends of friends. Which type fits?
2. Which fits caching web sessions?
3. Which suits a delivery app’s map queries?
4. What does ETL stand for?
5. A data warehouse is mainly for…
6. OLAP lets users…
7. Grouping customers with no preset categories is…
8. Predicting next month’s sales figure uses…
9. Which feature hides where data lives?

Exam-style questions

These are written for this site in the style of Paper 1. Answer on paper first, then open the mark points.

  1. Define the term “data mining”. [1]

    Mark points
    • The process of sorting through large data sets to find patterns and relationships that help solve problems [1].
  2. Explain the role of integrated data in a data warehouse. [2]

    Mark points
    • Data from many systems is combined using ETL [1].
    • This gives one consistent source of truth for analysis [1].
  3. Describe concurrency control in distributed databases and how it can be achieved. [4]

    Mark points
    • It manages simultaneous access to shared data on several nodes [1].
    • It prevents conflicts such as lost updates [1].
    • Locks stop other transactions using data until commit [1].
    • Or timestamps set the order in which transactions run [1].
  4. Compare a document database with a relational database. [4]

    Mark points
    • A relational database uses a fixed schema of tables, while documents are flexible [1].
    • Documents suit unstructured or hierarchical data [1].
    • Relational data has less redundancy, because of normalization [1].
    • Relational databases give strong transactions and joins, while document stores scale out more easily [1].
  5. Compare classification and sequential pattern discovery. [4]

    Mark points
    • Classification assigns data to known categories [1].
    • It is used for spam detection, for example [1].
    • Sequential pattern discovery finds events in a time order [1].
    • It is used for clickstream analysis, for example [1].
  6. Outline the role of OLAP in business intelligence. [3]

    Mark points
    • It lets users analyse data across dimensions interactively [1].
    • Pre-aggregated views allow quick summaries [1].
    • Ad hoc queries answer questions without predefined reports, which supports decisions [1].
  7. Outline two differences between a database view and a data warehouse. [2]

    Mark points
    • A view is a virtual table from a query, while a warehouse physically stores data [1].
    • A view presents existing data from one database, while a warehouse combines historical data from many sources [1].