Masterbelt

masterbelt/masterbelt

Master Data Keys

Synced from main@9490864MarkdownSource

#Master Data Keys

This document defines primary keys, unique keys, indexes, and lookup contracts for master data.

#Primary Keys

A primary key uniquely identifies a record within a master.

The primary field modifier marks a record field as part of the primary key. It appears in the same position as readonly and writable and is mutually exclusive with them.

Masterbelt
master Items {
  record {
    primary id: int,
    name: string,
  }
}

master Localizations {
  record {
    primary locale: string,
    primary key: string,
    text: string,
  }
}

A master whose record section declares no primary field is a checker error reported as masterbelt.checker.master_primary_missing.

A master whose record section declares two or more primary fields has a composite primary key. The composite key tuple is ordered by source declaration order.

A primary field's type must be a value type for which equality is defined by ../language/types.md. A primary field whose type is not equality-comparable is a checker error.

primary outside a master's record section is a checker error reported as masterbelt.checker.primary_outside_master_record.

#Unique Keys and Indexes

Unique keys, secondary unique indexes, and lookup-by-index contracts are not yet specified.

#Lookup Contracts

Lookup operations against a master by primary key, and the behavior of duplicate-key import failures, are not yet specified.

Specification