Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0006-logical FR-010, 0006-logical FR-001, 0006-logical FR-002
The logical schema (commons data 0006-logical FR-001, FR-002, FR-010): a relational schema as plain data, in terms of tables, columns, keys, constraints and indexes and of no engine. Every element has an identity of its own, made of its words, and carries from, the identity of the governance element it was made from, so that it is traced back. Names are lists of words (0005-naming): the physical schema writes them in a case style.
Source: commons/data/sql/logical/schema.ts
2 of 27 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.
function carriedOf<T>(element: { readonly governance: readonly Annotation[]; }, kind: AnnotationKind<T>): readonly T[]
The values of the annotations of a kind that an element of the schema carries, typed: a table, a column, a value set or the schema.
| Parameter | What it is |
|---|
element | what carries them |
kind | the kind of annotation |
Returns: the values, in the order governance gave them
Imported by 4 tests of the run (4 passed, 0 failed): the library's results
Checkinterfaceno test imports itinterface Check
A check: a named rule every row must satisfy.
| Member | Type | What it is |
|---|
id | LogicalId | |
from | ElementId | |
name | Words | |
expression | CheckExpression | |
CheckExpressiontypeno test imports ittype CheckExpression =
| { readonly kind: "differs"; readonly columns: readonly [Words, Words] }
| { readonly kind: "oneOf"; readonly column: Words; readonly codes: readonly string[] }
| { readonly kind: "range"; readonly column: Words; readonly min?: number; readonly max?: number }
| { readonly kind: "pattern"; readonly column: Words; readonly pattern: string };
What a check says. A code is by its name: the physical schema writes its stored value (0005-naming FR-006).
CodeRowinterfaceno test imports itinterface CodeRow
A row of a code table: the code by its name, its label and what it means.
| Member | Type | What it is |
|---|
code | string | |
label | string | |
description | string | null | |
Columninterfaceno test imports itinterface Column
A column.
| Member | Type | What it is |
|---|
id | LogicalId | |
from | ElementId | |
name | Words | |
type | LogicalType | |
nullable | boolean | |
default? | LogicalDefault | |
comment | string | What governance said it is: the definition of what it was made from. |
governance | readonly Annotation[] | The annotations of governance that this column carries for the layers below. |
role | ColumnRole | |
ColumnRoletypeno test imports ittype ColumnRole = "attribute" | "reference" | "audit" | "code";
Where a column came from.
columnIdconstno test imports itconst columnId: (table: Words, column: Words) => LogicalId
The identity of a column of a table.
ConstraintKindtypeno test imports ittype ConstraintKind = "pk" | "fk" | "uq" | "ck" | "ix";
The kinds of constraint and index.
constraintIdconstno test imports itconst constraintId: (kind: ConstraintKind, name: Words) => LogicalId
The identity of a constraint or an index.
ForeignKeyinterfaceno test imports itinterface ForeignKey
A foreign key: columns of a table that refer to columns of another.
| Member | Type | What it is |
|---|
id | LogicalId | |
from | ElementId | |
name | Words | |
columns | readonly Words[] | |
references | { readonly table: Words; readonly columns: readonly Words[]; } | |
Indexinterfaceno test imports itinterface Index
An index: how rows are found by columns, in order.
| Member | Type | What it is |
|---|
id | LogicalId | |
from | ElementId | |
name | Words | |
columns | readonly Words[] | |
LogicalDefaulttypeno test imports ittype LogicalDefault =
| { readonly kind: "literal"; readonly value: string | number | boolean }
| { readonly kind: "now" }
| { readonly kind: "code"; readonly name: string };
What a column takes where no value is given: a literal, the moment of the insert, or a code of a list (by its name).
LogicalIdtypeno test imports ittype LogicalId = Brand<string, "LogicalId">;
The identity of an element of a logical schema, made of its words.
interface LogicalSchema
The logical schema of a domain.
| Member | Type | What it is |
|---|
id | LogicalId | |
from | ElementId | |
domain | string | |
comment | string | |
tables | readonly Table[] | |
valueSets | readonly ValueSet[] | The closed code lists, which no table holds. |
governance | readonly Annotation[] | The annotations of the domain, which the schema carries. |
Imported by 13 tests of the run (13 passed, 0 failed): the library's results
LogicalTypetypeno test imports ittype LogicalType =
| { readonly kind: "text"; readonly max?: number }
| { readonly kind: "integer" }
| { readonly … (436 characters)
type LogicalType =
| { readonly kind: "text"; readonly max?: number }
| { readonly kind: "integer" }
| { readonly kind: "decimal"; readonly precision?: number; readonly scale?: number }
| { readonly kind: "boolean" }
| { readonly kind: "date" }
| { readonly kind: "timestamp"; readonly zone: boolean }
| { readonly kind: "json" }
| { readonly kind: "bytes" }
| { readonly kind: "vector"; readonly dimensions: number };
The logical types: none is an engine's.
sameWordsconstno test imports itconst sameWords: (a: Words, b: Words) => boolean
Whether two lists of words are the same.
columnNamedfunctionno test imports itfunction columnNamed(table: Table, name: string): Column | undefined
The column of a table that governance names (partyId, givenName).
| Parameter | What it is |
|---|
table | the table |
name | the name as governance writes it, lower camel case |
Returns: the column, or none
featureIdconstno test imports itconst featureId: (kind: FeatureKind, name: Words) => LogicalId
The identity of what a feature of an extension makes, by its kind and name.
FeatureKindtypeno test imports ittype FeatureKind = "view" | "routine" | "policy" | "partition" | "grant" | "object";
What a feature of an extension makes: the identity of a thing the schema does not have (0009-sql-features).
tableNamedfunctionno test imports itfunction tableNamed(schema: LogicalSchema, name: string): Table | undefined
The table of a schema that governance names (party, partyIdentifier).
| Parameter | What it is |
|---|
schema | the logical schema |
name | the name as governance writes it, lower camel case |
Returns: the table, or none
schemaIdconstno test imports itconst schemaId: (domain: string) => LogicalId
The identity of the schema of a domain.
Tableinterfaceno test imports itinterface Table
A table.
| Member | Type | What it is |
|---|
id | LogicalId | |
from | ElementId | |
name | Words | |
comment | string | |
role | TableRole | |
columns | readonly Column[] | |
primaryKey | readonly Words[] | |
foreignKeys | readonly ForeignKey[] | |
uniques | readonly Unique[] | |
checks | readonly Check[] | |
indexes | readonly Index[] | |
rows? | readonly CodeRow[] | The rows of a code table. |
governance | readonly Annotation[] | The annotations of governance that this table carries for the layers below. |
tableIdconstno test imports itconst tableId: (table: Words) => LogicalId
TableRoletypeno test imports ittype TableRole = "concept" | "code" | "junction" | "values";
Uniqueinterfaceno test imports itinterface Unique
Columns that are unique together.
| Member | Type | What it is |
|---|
id | LogicalId | |
from | ElementId | |
name | Words | |
columns | readonly Words[] | |
ValueSetinterfaceno test imports itinterface ValueSet
A value set: a closed code list, which has no table, kept with its codes and what governance said of it.
| Member | Type | What it is |
|---|
id | LogicalId | |
from | ElementId | |
name | Words | |
comment | string | |
codes | readonly CodeRow[] | |
governance | readonly Annotation[] | |
valueSetIdconstno test imports itconst valueSetId: (name: Words) => LogicalId
The identity of a value set: a closed code list.