Prologue — “The Second Signal”

The Second Signal: Kotomarket’s Black Box

10 min

2184. The Second Signal

The receiver at Vault-9 had been silent for eight months—ever since you took the Kotomarket archive apart down to its last table. Today at 03:11, it picked up a second signal from the same dead sector of the Network.

This time, it isn’t a of the store. It’s a black box containing the company’s entire analytical archive from the final two and a half years of its existence: application events—every launch, click, and search query—daily metrics, logs from the “Console” BI system, and an incident journal signed with a single letter: “L.”

The final entry was written nine days before the company shut down:

The data was screaming. Nobody listened. If someone finds this archive—teach them to listen. — L.

A cadet opens a black box while a hologram traces a single event from a user action to a metric and then to its chart.
One log row records one action. Apply a rule to rows like these to get a metric, then plot the metric as a line on a dashboard.

QUERY opens the first page of the log and purrs unusually softly:

An archivist reads what happened. An investigator finds out why it happened. I’m promoting you. Don’t thank me—I checked whether you were ready. Repeatedly.

Before you open any cases, though, you need to learn the language they’re written in. It starts with one word: event.

An event is a table row

The first table in the black box is called events, and it contains 1.9 billion rows.

An event is a recorded fact: someone did something at a particular moment. In the data, that fact looks ordinary—a row in a table. Here are five rows from the evening of March 14:

user_id | event_name      | event_time | product_id
--------+-----------------+------------+-----------
4412    | product_view    | 19:00:12   | 812
4412    | add_to_cart     | 19:01:47   | 812
4412    | checkout_start  | 19:02:03   | 812
7781    | product_view    | 19:02:15   | 305
2043    | app_open        | 19:02:41   |

The main rule for reading a table like this is:

One row = one recorded action.

Not one user, not one order, not one product—one action recorded at a specific moment in time.

Read the first three rows in order: user 4412 viewed product 812 (“Milo Hammock Bed”) at 19:00:12, added it to the cart 1 minute 35 seconds later, and started checkout another 16 seconds after that. This fragment contains no later events for that user. We don’t see a purchase here either—but five rows aren’t enough to conclude that the user never bought the product later. Without calculating anything, you’ve reconstructed part of someone’s evening from four columns and also found the limit of what those rows let you claim.

Notice what the table doesn’t contain: there’s no “mood” column and no “reason for leaving.” An event records a fact, but it doesn’t explain why it happened. An analyst proposes possible causes as hypotheses and tests them. That’s where analytical work begins.

An event is one line of the log4412product_view19:00:12812|||whouser_idwhentimestampwhat they dideventwith which objectproduct_idevent = who · what · when · with which object
An event is a row that tells us who did what, when, and—if the action involved an object—which object.

The chain behind all analytics

Every number company leadership sees follows a path from a real action to a report. We’ll trace that path step by step using the same five rows.

Step 1. Action. Leo the cat taps the “Add to cart” button with his paw.

Step 2. Event. The app sends the server a message: “user 4412, add_to_cart, 19:01:47, product 812.” The server appends a row to the events table. The action has become a fact in the data. Keep one limitation in mind from the start: analysts can only work with actions the system actually recorded. If an event was never sent or was lost along the way, that action won’t appear in the data.

Step 3. Metric. A metric is a number calculated from facts according to an agreed rule. For example, suppose Kotomarket considers a user active if they had at least one event from our table during the day. Then DAU (daily active users) is the number of unique user_id values for that day. Suppose these are all the rows for the day. The calculation looks like this:

event rows:    4412, 4412, 4412, 7781, 2043   ← five rows
unique IDs:    4412, 7781, 2043               ← three users
DAU = 3

There are five events, but DAU is three because 4412 appears three times and the metric counts users, not actions. One user can perform many actions, so an event table usually contains more rows than unique users.

Step 4. Chart and . One number tells you what happened on one day, but without a comparison you can’t tell whether that result is good or bad. You need a series: DAU for March 13, March 14, March 15… Plot those values as a line and place it on a dashboard—a screen with the key metrics the team monitors.

Three things people call “data”

What it isExample
Eventa fact: who, what, when“4412 added product 812 to the cart at 19:01:47”
Metrica number calculated from facts using a rule“DAU on March 14 = 4,200”
Metric chartmetric values over time“DAU from March 1 to March 31”—a line with 31 points

This distinction matters in practice. A single event can’t “drop by 30%”: it either happened and was recorded, or it didn’t. A metric can drop by 30%, either because user behavior changed or because the measurement went wrong—for example, events were lost, the counting rule changed, or the tracking code broke.

This is where the investigator’s work begins. When the line plunges, you need to find out what changed: the company’s reality or the system measuring it.

Two databases, two kinds of questions

Last time, you worked with the store’s operational database: products, orders, and users. Its main job is to serve the application right now.

It would be convenient to say that “the operational database stores the current state, while the warehouse stores history,” but that isn’t quite accurate: the operational database contains order history too. The distinction depends not only on what data is stored, but also on how that data is used.

Questions for the operational database: “What is the current status of order #812?”, “How many beds are left in stock in Meowfield?”, “What is the delivery address for user 4412?” These are short queries that touch a small number of records. The answer has to come back quickly because a phone screen may be waiting for it. Thousands of these queries can run every second, and each usually touches only a few rows.

Questions for the analytical : “How did the cancellation rate change week by week over the past year?”, “What percentage of users who joined in March were still active in June?”, “How much revenue did the “food” category generate by city over the quarter?” These queries work with large volumes of data across long periods. An answer may take seconds or minutes; there may be only dozens of such queries per day, but each can process millions of rows.

Operational database ()Analytical data warehouse
Type of questionspecific records and current operationsmany objects over a period of time
Who asksprimarily application codeanalysts, reports, and analytical services
Rows per queryusually a small numberpotentially very many
Response timeusually millisecondsseconds or minutes
Cost of an errorfailed application operationincorrect analysis or decision

That’s why analytical workloads are often moved to a separate warehouse: a heavy query over a large volume of historical data shouldn’t interfere with the database handling purchases, payments, and deliveries. Data from operational systems can be copied into the warehouse on a schedule or streamed there continuously—the exact setup depends on how the system is designed.

A data analyst spends most of their time working with the second column. In this course, you’ll get the entire Kotomarket black box—and all of L.’s unsolved cases.

Operational DBone row, right nowusersordersproductsWhat is order #812'sstatus right now?Analytics warehousemillions of rows, historyeventsdaily_metricsdashboardsHow did the cancel ratechange week over weekover the year?different questions → different stores
The operational database handles short application queries, while the analytical data warehouse answers questions that span large volumes of data and long periods of time.
Check yourself
A user opened the app, viewed three products, and bought one. If each action is recorded as a separate event, how many rows will appear in the events table?
Check yourself
Which of these questions should be answered from the analytical data warehouse rather than the application’s operational database?
Key takeaways
  • an event is a row of data: who did what, when, and with what; one row = one action
  • the analytics chain is: action → event → metric → chart on a
  • an event is a single fact, a metric is a number calculated from many facts, and a chart shows metric values, for example over time; a metric can drop, but a single event cannot
  • the operational database answers short application queries about specific records, while the warehouse answers questions about many objects over a period of time

Next, we’ll take the “event → metric” step apart piece by piece.