entitiesintegerrequiredloss
conceptEntities 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
lossIdidentifierrequiredWhat identifies the loss
Becomes the column loss_id of loss.
Written at commons/data/models/flow/mod.ts:185
stagecode of stagerequiredThe stage they stopped at
Becomes the column stage of loss.
Written at commons/data/models/flow/mod.ts:185
Governance: relationships
manifestoneThe batch To manifest. Written at commons/data/models/flow/mod.ts:185
reasononeWhy 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.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
entities | integer | false | attribute | loss.entities |
loss_id | text | false | attribute | loss.lossId |
manifest_id | text | false | reference | loss.manifest |
reason_id | text | false | reference | loss.reason |
stage | text | false | attribute | loss.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'))
);CREATE TABLE IF NOT EXISTS "loss" (
"loss_id" TEXT NOT NULL PRIMARY KEY,
"stage" TEXT NOT NULL,
"entities" INTEGER NOT NULL,
"manifest_id" TEXT NOT NULL,
"reason_id" TEXT 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'))
);CREATE TABLE IF NOT EXISTS "loss" (
"loss_id" TEXT NOT NULL PRIMARY KEY,
"stage" TEXT NOT NULL,
"entities" INTEGER NOT NULL,
"manifest_id" TEXT NOT NULL,
"reason_id" TEXT 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);