IF Commons GitHub

loss

concept

Entities of a batch that did not go on, with the stage they stopped at and the reason: what makes a loss explained

Model flow. Written in commons/data/models/flow/mod.ts:185. Identified by lossId.

Governance: attributes

entitiesintegerrequired

How many

Becomes the column entities of loss.

Written at commons/data/models/flow/mod.ts:185

lossIdidentifierrequired

What identifies the loss

Becomes the column loss_id of loss.

Written at commons/data/models/flow/mod.ts:185

stagecode of stagerequired

The stage they stopped at

Becomes the column stage of loss.

Written at commons/data/models/flow/mod.ts:185

Governance: relationships

manifestone

The batch To manifest. Written at commons/data/models/flow/mod.ts:185

reasonone

Why To reason. Written at commons/data/models/flow/mod.ts:185

Logical: the table

Projects to the table loss with the primary key loss_id.

ColumnTypeNullRoleFrom
entitiesintegerfalseattributeloss.entities
loss_idtextfalseattributeloss.lossId
manifest_idtextfalsereferenceloss.manifest
reason_idtextfalsereferenceloss.reason
stagetextfalseattributeloss.stage

Physical: SQL

CREATE TABLE IF NOT EXISTS "loss" (
    "loss_id" VARCHAR NOT NULL PRIMARY KEY,
    "stage" VARCHAR NOT NULL,
    "entities" INTEGER NOT NULL,
    "manifest_id" VARCHAR NOT NULL,
    "reason_id" VARCHAR NOT NULL,
    CONSTRAINT "loss_manifest_id_fk" FOREIGN KEY ("manifest_id") REFERENCES "manifest" ("manifest_id"),
    CONSTRAINT "loss_reason_id_fk" FOREIGN KEY ("reason_id") REFERENCES "reason" ("reason_id"),
    CONSTRAINT "loss_stage_ck" CHECK ("stage" IN ('received', 'captured', 'parsed', 'mapped', 'validated', 'forwarded', 'dest_verdict', 'usable'))
);

Physical: the typed table

Read and written from TypeScript with the types the model gives: import { loss } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/flow.auto.ts: do not edit.

import { from } from "@intellectual-frontiers/data/sql/typed";
import { loss } from "@intellectual-frontiers/data/sql/typed/models";

const rows = await from(loss).select((s) => ({ lossId: s.loss.lossId, stage: s.loss.stage })).run(runner);

Titles, headings, exports, tables, columns and requirements. Esc closes.