{
  "name": "data-model",
  "version": "0.4.0",
  "description": "Concept to table in three layers: concepts, entities and attributes, then databases, schemas, tables, columns, indexes, constraints, views and grants. Twelve rules keep the model honest, including that every foreign key points at one primary key of the same type.",
  "license": "Apache-2.0",
  "publisher": "trumly",
  "namespace": "dm",
  "tier": "verified",
  "role": "enrichment",
  "useWhen": "When you need to say what is inside a datastore: the concepts, the entities and attributes, then the databases, schemas, tables, columns and indexes that realise them.",
  "enriches": [
    "datastore"
  ],
  "requires": [
    "core@^1.0.0"
  ],
  "optional": [],
  "includes": [],
  "sha256": "932f8015afcb3a23e0a342ca2e7fd1b8ba9f778c118477dd31d46f2bc93345bb",
  "files": [
    [
      "dm--conceptual",
      "---\nid: dm--conceptual\ntype: plane\ntitle: Conceptual\nfields:\n  order: 1\n  pack: data-model@0.4.0\n  stack: Data model\n---\n\nWhat the business talks about, before any structure.\n"
    ],
    [
      "dm--link-type-data-constrains",
      "---\nid: dm--link-type-data-constrains\ntype: link-type\ntitle: governs\nfields:\n  description: A constraint applies to a table or to the columns it covers.\n  from:\n  - data-constraint\n  inverse: constrained-by\n  name: data-constrains\n  to:\n  - data-table\n  - data-column\n  label: governs\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--link-type-data-contains",
      "---\nid: dm--link-type-data-contains\ntype: link-type\ntitle: contains\nfields:\n  description: 'Something sits inside another: a database in a server, a column in a table.'\n  from:\n  - data-db-server\n  - data-database\n  - data-schema\n  - data-table\n  - data-entity\n  inverse: contained-by\n  label: contains\n  name: data-contains\n  pack: data-model@0.4.0\n  to:\n  - data-database\n  - data-schema\n  - data-table\n  - data-view\n  - data-proc\n  - data-column\n  - data-index\n  - data-constraint\n  - data-attribute\n---\n"
    ],
    [
      "dm--link-type-data-derives-from",
      "---\nid: dm--link-type-data-derives-from\ntype: link-type\ntitle: derives-from\nfields:\n  description: A view is built from tables or columns.\n  from:\n  - data-view\n  inverse: source-of\n  name: data-derives-from\n  to:\n  - data-table\n  - data-column\n  label: derives-from\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--link-type-data-grants",
      "---\nid: dm--link-type-data-grants\ntype: link-type\ntitle: grants\nfields:\n  description: A grant gives access to an object.\n  from:\n  - data-grant\n  inverse: granted-on\n  name: data-grants\n  to:\n  - data-database\n  - data-schema\n  - data-table\n  - data-view\n  - data-proc\n  label: grants\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--link-type-data-has-many",
      "---\nid: dm--link-type-data-has-many\ntype: link-type\ntitle: has-many\nfields:\n  description: One of these relates to many of those.\n  from:\n  - data-entity\n  - data-table\n  inverse: belongs-to\n  label: has-many\n  name: data-has-many\n  pack: data-model@0.4.0\n  to:\n  - data-entity\n  - data-table\n---\n"
    ],
    [
      "dm--link-type-data-has-one",
      "---\nid: dm--link-type-data-has-one\ntype: link-type\ntitle: has-one\nfields:\n  description: One of these relates to exactly one of those.\n  from:\n  - data-entity\n  - data-table\n  inverse: is-one-of\n  label: has-one\n  name: data-has-one\n  pack: data-model@0.4.0\n  to:\n  - data-entity\n  - data-table\n---\n"
    ],
    [
      "dm--link-type-data-holds",
      "---\nid: dm--link-type-data-holds\ntype: link-type\ntitle: holds\nfields:\n  description: A user holds a grant.\n  from:\n  - data-user\n  inverse: held-by\n  name: data-holds\n  to:\n  - data-grant\n  label: holds\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--link-type-data-indexes",
      "---\nid: dm--link-type-data-indexes\ntype: link-type\ntitle: indexes\nfields:\n  description: An index covers a column.\n  from:\n  - data-index\n  inverse: indexed-by\n  name: data-indexes\n  to:\n  - data-column\n  label: indexes\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--link-type-data-realised-by",
      "---\nid: dm--link-type-data-realised-by\ntype: link-type\ntitle: realised-by\nfields:\n  description: 'A higher level thing carried out one level down: concept to entity, entity to table, attribute\n    to column.'\n  from:\n  - data-concept\n  - data-entity\n  - data-attribute\n  inverse: realises\n  label: realised-by\n  name: data-realised-by\n  pack: data-model@0.4.0\n  to:\n  - data-entity\n  - data-attribute\n  - data-table\n  - data-column\n---\n"
    ],
    [
      "dm--link-type-data-references",
      "---\nid: dm--link-type-data-references\ntype: link-type\ntitle: references\nfields:\n  description: 'A foreign key: this column points at another column.'\n  from:\n  - data-column\n  inverse: referenced-by\n  name: data-references\n  to:\n  - data-column\n  label: references\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--link-type-data-relates-to",
      "---\nid: dm--link-type-data-relates-to\ntype: link-type\ntitle: relates-to\nfields:\n  description: A loose relationship between any two things.\n  from: []\n  inverse: related-to\n  label: relates-to\n  name: data-relates-to\n  pack: data-model@0.4.0\n  to: []\n---\n"
    ],
    [
      "dm--logical",
      "---\nid: dm--logical\ntype: plane\ntitle: Logical\nfields:\n  order: 2\n  pack: data-model@0.4.0\n  stack: Data model\n---\n\nEntities and attributes, independent of any database.\n"
    ],
    [
      "dm--pack",
      "---\nid: dm--pack\ntype: pack\ntitle: Data model\nfields:\n  name: data-model\n  namespace: dm\n  version: 0.4.0\n  description: 'Concept to table in three layers: concepts, entities and attributes, then databases, schemas,\n    tables, columns, indexes, constraints, views and grants. Twelve rules keep the model honest, including\n    that every foreign key points at one primary key of the same type.'\n  license: Apache-2.0\n  publisher: trumly\n  role: enrichment\n  enriches:\n  - datastore\n  use-when: 'When you need to say what is inside a datastore: the concepts, the entities and attributes,\n    then the databases, schemas, tables, columns and indexes that realise them.'\n  requires:\n  - core@^1.0.0\n---\n"
    ],
    [
      "dm--physical",
      "---\nid: dm--physical\ntype: plane\ntitle: Physical\nfields:\n  order: 3\n  pack: data-model@0.4.0\n  stack: Data model\n---\n\nTables, columns and the database they live in.\n"
    ],
    [
      "dm--rule-attribute-in-entity",
      "---\nid: dm--rule-attribute-in-entity\ntype: rule\ntitle: Attributes belong to an entity\nfields:\n  name: Attributes belong to an entity\n  applies_to:\n    type: data-attribute\n  check:\n    require_link:\n    - dir: in\n      max: 1\n      min: 1\n      node_type: data-entity\n      type: data-contains\n  pack: data-model@0.4.0\n  severity: warn\n  statement: Attributes belong to one entity\n---\n"
    ],
    [
      "dm--rule-column-in-table",
      "---\nid: dm--rule-column-in-table\ntype: rule\ntitle: Columns belong to a table\nfields:\n  name: Columns belong to a table\n  applies_to:\n    type: data-column\n  check:\n    require_link:\n    - dir: in\n      max: 1\n      min: 1\n      node_type: data-table\n      type: data-contains\n  pack: data-model@0.4.0\n  severity: warn\n  statement: Columns belong to one table\n---\n"
    ],
    [
      "dm--rule-concept-becomes-entity",
      "---\nid: dm--rule-concept-becomes-entity\ntype: rule\ntitle: Concepts become entities\nfields:\n  name: Concepts become entities\n  applies_to:\n    type: data-concept\n  check:\n    require_link:\n    - min: 1\n      node_type: data-entity\n      type: data-realised-by\n  pack: data-model@0.4.0\n  severity: info\n  statement: Every concept becomes an entity\n---\n"
    ],
    [
      "dm--rule-constraint-applies",
      "---\nid: dm--rule-constraint-applies\ntype: rule\ntitle: Constraints apply to something\nfields:\n  name: Constraints apply to something\n  applies_to:\n    type: data-constraint\n  check:\n    require_link:\n    - min: 1\n      type: data-constrains\n  severity: warn\n  statement: Every constraint applies to something\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--rule-database-in-server",
      "---\nid: dm--rule-database-in-server\ntype: rule\ntitle: Databases run in servers\nfields:\n  name: Databases run in servers\n  applies_to:\n    type: data-database\n  check:\n    require_link:\n    - dir: in\n      min: 1\n      node_type: data-db-server\n      type: data-contains\n  pack: data-model@0.4.0\n  severity: warn\n  statement: Databases run in servers\n---\n"
    ],
    [
      "dm--rule-entity-built",
      "---\nid: dm--rule-entity-built\ntype: rule\ntitle: Entities are built as tables\nfields:\n  name: Entities are built as tables\n  applies_to:\n    type: data-entity\n  check:\n    require_link:\n    - min: 1\n      node_type: data-table\n      type: data-realised-by\n  pack: data-model@0.4.0\n  severity: info\n  statement: Every entity is built as a table\n---\n"
    ],
    [
      "dm--rule-fk-references-pk",
      "---\nid: dm--rule-fk-references-pk\ntype: rule\ntitle: Foreign keys reference a key\nfields:\n  name: Foreign keys reference a key\n  applies_to:\n    foreign_key: true\n    type: data-column\n  check:\n    require_link:\n    - max: 1\n      min: 1\n      node_fields:\n        primary_key: true\n      node_type: data-column\n      same_fields:\n      - data_type\n      type: data-references\n  severity: warn\n  statement: Foreign key columns reference one primary key\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--rule-index-covers-column",
      "---\nid: dm--rule-index-covers-column\ntype: rule\ntitle: Indexes cover a column\nfields:\n  name: Indexes cover a column\n  applies_to:\n    type: data-index\n  check:\n    require_link:\n    - min: 1\n      node_type: data-column\n      type: data-indexes\n  severity: warn\n  statement: Every index covers a column\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--rule-schema-in-database",
      "---\nid: dm--rule-schema-in-database\ntype: rule\ntitle: Schemas live in a database\nfields:\n  name: Schemas live in a database\n  applies_to:\n    type: data-schema\n  check:\n    require_link:\n    - dir: in\n      max: 1\n      min: 1\n      node_type: data-database\n      type: data-contains\n  pack: data-model@0.4.0\n  severity: warn\n  statement: Schemas live in a database\n---\n"
    ],
    [
      "dm--rule-table-in-schema",
      "---\nid: dm--rule-table-in-schema\ntype: rule\ntitle: Tables live in a schema\nfields:\n  name: Tables live in a schema\n  applies_to:\n    type: data-table\n  check:\n    require_link:\n    - dir: in\n      max: 1\n      min: 1\n      node_type: data-schema\n      type: data-contains\n  pack: data-model@0.4.0\n  severity: warn\n  statement: Tables live in a schema\n---\n"
    ],
    [
      "dm--rule-table-pk",
      "---\nid: dm--rule-table-pk\ntype: rule\ntitle: Tables have a primary key\nfields:\n  name: Tables have a primary key\n  applies_to:\n    type: data-table\n  check:\n    require_link:\n    - min: 1\n      node_fields:\n        primary_key: true\n      node_type: data-column\n      type: data-contains\n  pack: data-model@0.4.0\n  severity: warn\n  statement: Every table has a primary key\n---\n"
    ],
    [
      "dm--rule-view-from-table",
      "---\nid: dm--rule-view-from-table\ntype: rule\ntitle: Views are built from tables\nfields:\n  name: Views are built from tables\n  applies_to:\n    type: data-view\n  check:\n    require_link:\n    - min: 1\n      node_type: data-table\n      type: data-derives-from\n  severity: info\n  statement: Every view is built from a table\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-attribute",
      "---\nid: dm--type-data-attribute\ntype: type\ntitle: attribute\nfields:\n  description: A logical attribute of an entity.\n  fields:\n  - kind: choice\n    name: data_type\n    required: true\n    values:\n    - text\n    - number\n    - boolean\n    - date\n    - timestamp\n    - identifier\n    - binary\n  - kind: boolean\n    name: mandatory\n  name: data-attribute\n  plane: dm--logical\n  shape: circle 2d\n  label: attribute\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-column",
      "---\nid: dm--type-data-column\ntype: type\ntitle: data-column\nfields:\n  description: A column of a table.\n  fields:\n  - kind: choice\n    name: data_type\n    required: true\n    values:\n    - text\n    - integer\n    - decimal\n    - boolean\n    - date\n    - timestamp\n    - uuid\n    - json\n    - binary\n  - kind: boolean\n    name: nullable\n  - kind: boolean\n    name: primary_key\n  - kind: boolean\n    name: foreign_key\n  label: column\n  name: data-column\n  plane: dm--physical\n  shape: circle 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-concept",
      "---\nid: dm--type-data-concept\ntype: type\ntitle: data-concept\nfields:\n  description: 'A business idea at the conceptual level: a thing the organisation talks about, with no\n    structure yet.'\n  fields: []\n  label: concept\n  name: data-concept\n  plane: dm--conceptual\n  shape: cloud 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-constraint",
      "---\nid: dm--type-data-constraint\ntype: type\ntitle: data-constraint\nfields:\n  description: 'A rule the database enforces on a table or columns: unique, check, not null or default.'\n  fields:\n  - kind: choice\n    name: kind\n    required: true\n    values:\n    - unique\n    - check\n    - not-null\n    - default\n  - kind: text\n    name: expression\n  label: constraint\n  name: data-constraint\n  plane: dm--physical\n  shape: hexagon 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-database",
      "---\nid: dm--type-data-database\ntype: type\ntitle: data-database\nfields:\n  description: A database on a server.\n  fields: []\n  label: database\n  name: data-database\n  plane: dm--physical\n  shape: database up\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-db-server",
      "---\nid: dm--type-data-db-server\ntype: type\ntitle: data-db-server\nfields:\n  description: A database server or instance that hosts databases.\n  fields: []\n  label: db-server\n  name: data-db-server\n  plane: dm--physical\n  shape: octagon 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-entity",
      "---\nid: dm--type-data-entity\ntype: type\ntitle: data-entity\nfields:\n  description: 'A logical entity: a thing with attributes and relationships, independent of any database.'\n  fields: []\n  label: entity\n  name: data-entity\n  plane: dm--logical\n  shape: square 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-grant",
      "---\nid: dm--type-data-grant\ntype: type\ntitle: data-grant\nfields:\n  description: A permission given to a user on an object.\n  fields: []\n  label: grant\n  name: data-grant\n  plane: dm--physical\n  shape: shield 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-index",
      "---\nid: dm--type-data-index\ntype: type\ntitle: data-index\nfields:\n  description: An index on one or more columns of a table.\n  fields:\n  - kind: boolean\n    name: unique\n  label: index\n  name: data-index\n  plane: dm--physical\n  shape: triangle 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-proc",
      "---\nid: dm--type-data-proc\ntype: type\ntitle: data-proc\nfields:\n  description: A stored procedure or function.\n  fields: []\n  label: proc\n  name: data-proc\n  plane: dm--physical\n  shape: chevron 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-schema",
      "---\nid: dm--type-data-schema\ntype: type\ntitle: data-schema\nfields:\n  description: A namespace of tables, views and procedures inside a database.\n  fields: []\n  label: schema\n  name: data-schema\n  plane: dm--physical\n  shape: folder 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-table",
      "---\nid: dm--type-data-table\ntype: type\ntitle: data-table\nfields:\n  description: A physical table.\n  fields: []\n  label: table\n  name: data-table\n  plane: dm--physical\n  shape: square 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-user",
      "---\nid: dm--type-data-user\ntype: type\ntitle: data-user\nfields:\n  description: A database user or role.\n  fields: []\n  label: user\n  name: data-user\n  plane: dm--physical\n  shape: person 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "dm--type-data-view",
      "---\nid: dm--type-data-view\ntype: type\ntitle: data-view\nfields:\n  description: A stored query presented as a table.\n  fields: []\n  label: view\n  name: data-view\n  plane: dm--physical\n  shape: document 2d\n  pack: data-model@0.4.0\n---\n"
    ],
    [
      "examples/bookings-database/attr-booking-slot",
      "---\nid: attr-booking-slot\ntype: data-attribute\ntitle: slot\nplane: dm--logical\nfields:\n  data_type: timestamp\n  mandatory: true\n---\n"
    ],
    [
      "examples/bookings-database/attr-client-name",
      "---\nid: attr-client-name\ntype: data-attribute\ntitle: name\nplane: dm--logical\nfields:\n  data_type: text\n  mandatory: true\n---\n"
    ],
    [
      "examples/bookings-database/col-booking-client",
      "---\nid: col-booking-client\ntype: data-column\ntitle: client_id\nplane: dm--physical\nfields:\n  data_type: uuid\n  foreign_key: true\n  nullable: false\nlinks:\n- type: data-references\n  to: col-client-id\n---\n"
    ],
    [
      "examples/bookings-database/col-booking-id",
      "---\nid: col-booking-id\ntype: data-column\ntitle: id\nplane: dm--physical\nfields:\n  data_type: uuid\n  primary_key: true\n  nullable: false\n---\n"
    ],
    [
      "examples/bookings-database/col-booking-slot",
      "---\nid: col-booking-slot\ntype: data-column\ntitle: slot\nplane: dm--physical\nfields:\n  data_type: timestamp\n  nullable: false\n---\n"
    ],
    [
      "examples/bookings-database/col-client-id",
      "---\nid: col-client-id\ntype: data-column\ntitle: id\nplane: dm--physical\nfields:\n  data_type: uuid\n  primary_key: true\n  nullable: false\n---\n"
    ],
    [
      "examples/bookings-database/col-client-name",
      "---\nid: col-client-name\ntype: data-column\ntitle: name\nplane: dm--physical\nfields:\n  data_type: text\n  nullable: false\n---\n"
    ],
    [
      "examples/bookings-database/concept-booking",
      "---\nid: concept-booking\ntype: data-concept\ntitle: Booking\nplane: dm--conceptual\nlinks:\n- type: data-realised-by\n  to: entity-booking\n- type: data-relates-to\n  to: concept-client\n---\n"
    ],
    [
      "examples/bookings-database/concept-client",
      "---\nid: concept-client\ntype: data-concept\ntitle: Client\nplane: dm--conceptual\nlinks:\n- type: data-realised-by\n  to: entity-client\n---\n"
    ],
    [
      "examples/bookings-database/constraint-slot-unique",
      "---\nid: constraint-slot-unique\ntype: data-constraint\ntitle: One booking per slot\nplane: dm--physical\nfields:\n  kind: unique\nlinks:\n- type: data-constrains\n  to: table-booking\n---\nOne booking per slot per client\n"
    ],
    [
      "examples/bookings-database/database-portal",
      "---\nid: database-portal\ntype: data-database\ntitle: portal\nplane: dm--physical\nlinks:\n- type: data-contains\n  to: schema-public\n---\n"
    ],
    [
      "examples/bookings-database/entity-booking",
      "---\nid: entity-booking\ntype: data-entity\ntitle: Booking\nplane: dm--logical\nlinks:\n- type: data-contains\n  to: attr-booking-slot\n- type: data-realised-by\n  to: table-booking\n---\n"
    ],
    [
      "examples/bookings-database/entity-client",
      "---\nid: entity-client\ntype: data-entity\ntitle: Client\nplane: dm--logical\nlinks:\n- type: data-contains\n  to: attr-client-name\n- type: data-has-many\n  to: entity-booking\n- type: data-realised-by\n  to: table-client\n---\n"
    ],
    [
      "examples/bookings-database/example",
      "---\nid: example\ntype: example\ntitle: From concept to table\nfields:\n  title: From concept to table\n  description: Booking and Client as concepts, then entities and attributes, then the Postgres server,\n    database, schema, tables, columns, a foreign key, an index, a constraint and a view.\n  use: starter\n  requires:\n  - data-model\n---\n"
    ],
    [
      "examples/bookings-database/index-booking-slot",
      "---\nid: index-booking-slot\ntype: data-index\ntitle: booking by slot\nplane: dm--physical\nfields:\n  unique: false\nlinks:\n- type: data-indexes\n  to: col-booking-slot\n---\n"
    ],
    [
      "examples/bookings-database/schema-public",
      "---\nid: schema-public\ntype: data-schema\ntitle: public\nplane: dm--physical\nlinks:\n- type: data-contains\n  to: table-client\n- type: data-contains\n  to: table-booking\n- type: data-contains\n  to: view-upcoming\n---\n"
    ],
    [
      "examples/bookings-database/server-main",
      "---\nid: server-main\ntype: data-db-server\ntitle: Main server\nplane: dm--physical\nlinks:\n- type: data-contains\n  to: database-portal\n---\n"
    ],
    [
      "examples/bookings-database/table-booking",
      "---\nid: table-booking\ntype: data-table\ntitle: booking\nplane: dm--physical\nlinks:\n- type: data-contains\n  to: col-booking-id\n- type: data-contains\n  to: col-booking-client\n- type: data-contains\n  to: col-booking-slot\n---\n"
    ],
    [
      "examples/bookings-database/table-client",
      "---\nid: table-client\ntype: data-table\ntitle: client\nplane: dm--physical\nlinks:\n- type: data-contains\n  to: col-client-id\n- type: data-contains\n  to: col-client-name\n---\n"
    ],
    [
      "examples/bookings-database/view-upcoming",
      "---\nid: view-upcoming\ntype: data-view\ntitle: upcoming bookings\nplane: dm--physical\nlinks:\n- type: data-derives-from\n  to: table-booking\n---\n"
    ]
  ]
}
