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)
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.

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