Notes

Part 2 of 10

Operational versus analytical systems

Think of a city bike rental app. Three kinds of people work with its data:

  • Backend engineers build the services that let riders unlock bikes and pay, reading and updating data as they go.
  • Business analysts build reports for managers, for example rentals per station per week. This work is often called business intelligence (BI).
  • Data scientists look for patterns and build data-driven features, such as predicting which stations will run out of bikes, scoring payments for fraud, or ranking search results, often with machine learning.

Analysts and data scientists both do analytics. They read data that riders and services created, and they rarely change it, except to fix mistakes. They may, however, build new datasets from it.

This splits the world into two kinds of system:

  • Operational systems are where data is born: the backend services plus the databases, caches, and queues behind them. App code reads and changes data as users act.
  • Analytical systems serve analysts and data scientists. They hold a read-only copy of the operational data, shaped to make analysis fast.

Companies usually keep these two apart, and there are good reasons for that, covered below.

Transaction processing and analytics

The word "transaction" first meant a business deal, like a sale, an order, or a salary payment. The word stuck, and in databases it now means a group of reads and writes that belong together as one unit. In this chapter we use it loosely to mean quick, small reads and writes; the exact meaning comes in a later chapter.

  • A point query looks up a few records by their key, such as "fetch rider 8812".
  • OLTP (online transaction processing) is the pattern of an interactive app: point queries, plus inserts, updates, and deletes driven by what users do. The same pattern shows up in a chat app saving messages, a board game saving moves, or a contacts list.
  • The analytics pattern is different: scan a huge number of rows and return totals, counts, or averages instead of single records. A bike company might ask how many rides started at each station last month, or whether a weekend discount raised rides in the rain.
  • This analytics pattern is called OLAP (online analytical processing), and it is what BI is built on.
OLTPOLAP
ReadsA few records, found by keyTotals over many records
WritesCreate or change single recordsBulk loads (ETL) or event streams
Human userSomeone using the appAn internal analyst making decisions
Machine useCheck whether a user may do an actionLook for patterns that suggest fraud
QueriesFixed, written into the appNew questions, asked on the spot
Shape of loadMany small queriesFew large queries
What data meansThe state right nowThe history of what happened
Typical sizeGigabytes to terabytesTerabytes to petabytes
  • OLTP systems do not let users type their own SQL. A custom query could read or change data the user should not touch, or be so slow that it hurts everyone else. So the app runs only queries built into its code; hand-written queries are kept for maintenance work.
  • Analytical databases do let users write any SQL, either by hand or through dashboard and BI tools that write the query for them.
  • Product analytics (also called real-time analytics) puts analytics work inside a user-facing product, like a "your rides this year" page. These systems take in data as soon as it arrives and aim to answer each query quickly.
  • Classic OLAP instead loads data in batches and aims to get through as many queries as possible.