{
  "dataSource": "/OpenForum/AddOn/PaperScape/DBModelView/example-database-model.dbmv.json",
  "model": {
    "tables": [
      {
        "id": "users",
        "name": "users",
        "description": "Registered platform members with authentication credentials and profile metadata.",
        "columns": [
          { "name": "id", "type": "uuid", "primaryKey": true, "nullable": false, "default": "uuid_generate_v4()" },
          { "name": "email", "type": "text", "nullable": false, "unique": true },
          { "name": "display_name", "type": "text", "nullable": false },
          { "name": "created_at", "type": "timestamptz", "nullable": false, "default": "now()" },
          { "name": "status", "type": "user_status", "nullable": false, "default": "'active'::user_status" }
        ],
        "indexes": [
          { "name": "users_email_idx", "unique": true, "columns": ["email"] },
          { "name": "users_status_created_at_idx", "columns": ["status", "created_at"], "method": "btree" }
        ]
      },
      {
        "id": "products",
        "name": "products",
        "description": "Catalog entries that can appear on customer orders.",
        "columns": [
          { "name": "id", "type": "uuid", "primaryKey": true, "nullable": false, "default": "uuid_generate_v4()" },
          { "name": "sku", "type": "text", "nullable": false, "unique": true },
          { "name": "name", "type": "text", "nullable": false },
          { "name": "price_cents", "type": "integer", "nullable": false },
          { "name": "active", "type": "boolean", "nullable": false, "default": "true" }
        ],
        "indexes": [
          { "name": "products_active_idx", "columns": ["active"], "method": "btree" }
        ]
      },
      {
        "id": "orders",
        "name": "orders",
        "description": "Order headers capturing who placed the order and its fulfilment status.",
        "columns": [
          { "name": "id", "type": "uuid", "primaryKey": true, "nullable": false, "default": "uuid_generate_v4()" },
          { "name": "user_id", "type": "uuid", "nullable": false, "foreignKey": { "targetTable": "users", "targetColumn": "id" } },
          { "name": "ordered_at", "type": "timestamptz", "nullable": false, "default": "now()" },
          { "name": "status", "type": "order_status", "nullable": false, "default": "'pending'::order_status" },
          { "name": "total_cents", "type": "integer", "nullable": false }
        ],
        "indexes": [
          { "name": "orders_user_id_idx", "columns": ["user_id"], "method": "btree" },
          { "name": "orders_status_idx", "columns": ["status"], "method": "btree" }
        ]
      },
      {
        "id": "order_items",
        "name": "order_items",
        "description": "Line items associated with an order, connecting products and quantities.",
        "columns": [
          { "name": "id", "type": "uuid", "primaryKey": true, "nullable": false, "default": "uuid_generate_v4()" },
          { "name": "order_id", "type": "uuid", "nullable": false, "foreignKey": { "targetTable": "orders", "targetColumn": "id" } },
          { "name": "product_id", "type": "uuid", "nullable": false, "foreignKey": { "targetTable": "products", "targetColumn": "id" } },
          { "name": "quantity", "type": "integer", "nullable": false, "default": 1 },
          { "name": "unit_price_cents", "type": "integer", "nullable": false }
        ],
        "indexes": [
          { "name": "order_items_order_id_idx", "columns": ["order_id"], "method": "btree" },
          { "name": "order_items_product_id_idx", "columns": ["product_id"], "method": "btree" }
        ]
      }
    ],
    "relationships": [
      { "type": "foreignKey", "sourceTable": "orders", "targetTable": "users" },
      { "type": "foreignKey", "sourceTable": "order_items", "targetTable": "orders" },
      { "type": "foreignKey", "sourceTable": "order_items", "targetTable": "products" }
    ]
  },
  "view": {
    "tables": [
      { "type": "DBModelTableView", "tableId": "users", "x": 80, "y": 80, "color": "teal" },
      { "type": "DBModelTableView", "tableId": "orders", "x": 480, "y": 80, "color": "blue" },
      { "type": "DBModelTableView", "tableId": "products", "x": 80, "y": 360, "color": "emerald" },
      { "type": "DBModelTableView", "tableId": "order_items", "x": 480, "y": 360, "color": "violet" }
    ]
  }
}
