Model your data

Model your data

Choose what each stream holds, how to name it, which bucket it lives in, and who writes it.

Modeling data in Nova means choosing what one stream holds. A stream is cheap, keeps its records in one order, and has its own retention. So the usual answer is one stream per thing whose history you keep in order: one order, device, conversation, or job. Group those streams into buckets that share settings. How Nova fits together introduces each part.

Stream keys in a bucket named apps
tenant-42/orders/8a1f        one order's history
tenant-42/orders/9c02        another order
tenant-42/audit              the tenant's audit log
device/eu-west/sensor-0017   one device's readings
run/2026-08-24/build-3391    one job's steps

One stream per thing you keep in order

PatternOne stream perFor example
Entity historyOrder, account, or documentEvent sourcing, where each entity rebuilds its state from its stream
Tenant logCustomerAudit trails, webhook delivery history
DeviceDevice or sensorTelemetry, firmware events
RunJob, workflow, or agent sessionStep history, build logs
ConversationChat or threadMessages, collaborative edits
Change feedTable or shardChange data capture

Nova does not order records across streams. Put two records in the same stream when their order matters to you, and in different streams when it does not. A stream that one node cannot keep up with, such as all the clicks of a busy site, can be a scalable stream, which keeps order per routing key instead.

Keys

A key is a name of your choice. Nova does not read it, and a slash is an ordinary character in it. Build keys from IDs that never change, such as a tenant ID and an order ID. A status or an owner can change, so keep them out of keys. A key cannot be renamed, and a stream deleted and created again starts empty, from sequence number 0.

Put the most general part first. You can then list a bucket's streams by key prefix:

List one tenant's orders
nova ls apps --prefix tenant-42/orders/
ADDRESS                            CLASS     PRODUCER
nova://apps/tenant-42/orders/8a1f  standard  any
nova://apps/tenant-42/orders/9c02  standard  any

A token can also be limited to a key prefix, so the same convention controls who reads and writes which streams. See API keys and tokens.

Buckets

A bucket gives its new streams their default settings. Group streams in one bucket when they need the same class, timestamping, and retention, or the same permissions. Use separate buckets when they need different ones, such as orders and orders-audit below.

When your application creates keys all the time, such as one stream per session, set the bucket to create a stream on its first append. Writers then append to any address, and the stream appears with the bucket's defaults. Set create-on-read too if a reader may start before the first writer. Buckets has the details.

Choose each bucket's defaults for its streams:

SettingChooseWhen
ClassStandardThroughput and cost matter more than a few hundred milliseconds
ExpressA writer waits on each acknowledgement
Timestampingclient-preferWriters may send event times. This is the default.
client-requireEvery record must carry its event time
arrivalRecords should carry Nova's time only
RetentionAn age or a sizeThe streams are a buffer: sessions, telemetry, logs
NoneThe streams are your source of truth

Writers

Decide who writes each stream:

Who writesUseUse when
Many writersThe default any producer policy. Nova orders their batches as they arrive.Devices, request handlers, or services append to one log
One owner at a timeThe fenced policy, and a new fencing token, such as a generation number, for each new ownerA command handler or workflow engine owns the stream
Writers whose append depends on the streamA match sequence number: read up to the tail, decide, then append only if the tail has not movedAn append is only right if nothing was written since you read

When a new owner fences a fenced stream with its token, the old owner's next append fails. When a conditional append is refused, the error carries the new tail, and you decide again. Writer coordination explains both tools.

Check the tail when you need to know where a stream ends now: before a conditional append, or after an append whose answer you never got.

Example: order history

An order service uses two buckets:

  • orders, with Express as its default class, fenced as its default producer policy, and streams created on first append. Each order has a stream, orders/<order-id>, which Nova creates with those defaults at its first append. The order's command handler appends with match sequence numbers, and projections subscribe from the start.
  • orders-audit, with Standard and arrival timestamping. Each tenant has a stream, orders-audit/<tenant>, with the any policy, which every service that touches the tenant's orders appends to. Retention keeps it for as long as compliance requires.

Listing orders gives the order streams, and listing orders-audit gives the tenants.

See also

On this page