Skip to content

Schema

Schema defines the structure of interaction data. Before storing data, define how edges are structured, what properties they have, and how they can be queried.

See Core Concepts for background.

Service (v3: Database)
├── Label (v3: Table)
│ ├── Schema (src, tgt, fields)
│ └── Indices (v3: Indexes)
└── Alias
  • Service groups related Labels and Aliases
  • Label defines the schema for edges
  • Alias provides an alternative name for a Label

A namespace that contains labels and aliases.

PropertyDescription
nameService identifier (e.g., myservice)
descDescription (v3: comment)
activeWhether active

Example: an e-commerce service might contain labels for likes, recent_views, and purchases.

Defines the schema for edges—src, tgt, fields, and indices.

PropertyDescription
nameFormat: service.label
descDescription (v3: comment)
typeLabel type (INDEXED, HASH, MULTI_EDGE, IMMUTABLE_INDEXED)
schemaEdge structure (src, tgt, fields)
dirTypeDirection type (v3: direction)
storageStorage URI (e.g., datastore://<namespace>/<table>)
indicesIndices for querying (v3: indexes)
activeWhether active
  • src (v3: source): source type (STRING, LONG) — who
  • tgt (v3: target): target type (STRING, LONG) — what
  • fields (v3: properties): each with name, type, nullable

Example: Recent Views

src: user_id (LONG)
tgt: product_id (LONG)
fields:
- created_at (LONG)
dirType: BOTH

Example: Reactions

src: user_id (LONG)
tgt: product_id (LONG)
fields:
- created_at (LONG)
- reaction_type (STRING)
dirType: BOTH

Indices enable efficient querying. Each index has a name and a list of fields with sort order.

indices:
- name: by_created_at
fields: [created_at DESC]
- name: by_type_and_time
fields: [reaction_type ASC, created_at DESC]

Indices are pre-computed at write time. See Query.

Immutable Edge Tables (type: IMMUTABLE_INDEXED, v3: IMMUTABLE_EDGE)

Section titled “Immutable Edge Tables (type: IMMUTABLE_INDEXED, v3: IMMUTABLE_EDGE)”

An append-only variant of the indexed label. A regular edge tracks mutable state (a like can be un-liked); an immutable edge records facts that never change, such as an event log or a message queue. Only index rows are persisted: there is no state row, no count records, and no caches. The index rows are the record.

PropertyConstraint
indicesAt most one index
dirTypeSingle direction (OUT or IN) — BOTH is rejected
mutationsINSERT only — UPDATE and DELETE are rejected

These constraints ensure every persisted row is reachable by a single index scan, so deleting the scanned rows is a complete delete. That is what makes eviction (scan-delete) safe.

Behavioral differences from a regular indexed label:

OperationBehavior
Point getRejected; read with an index scan
Count / totalNot supported; no count records are written
CDCNot emitted; the log itself is the change history
EvictionScan-delete removes a scanned index range

Example: Event Log

src: partition (LONG)
tgt: event_id (STRING)
fields:
- seq (LONG)
- payload (STRING)
dirType: OUT
indices:
- name: seq_asc
fields: [seq ASC]

Immutable edge tables back the queue/v1 API.

An alternative name for a label.

PropertyDescription
nameFormat: service.alias
descDescription (v3: comment)
targetThe label it points to
activeWhether active

Useful for gradual migrations or domain-specific naming.

TypeFormatExample
ServiceSimple identifiermyservice
Labelservice.labelmyservice.likes
Aliasservice.aliasmyservice.friends

v2 and v3 map almost 1:1.

v2 (Current)v3 (Future)
servicedatabase
labeltable
srcsource
tgttarget
tsversion
fieldsproperties
dirTypedirection
indicesindexes
desccomment