Data modeling guide

Describe the records your application owns.

Start with one table, verify the generated storage and interfaces, then add relationships, indexes, and access rules.

  • YAML
  • System fields
  • Relationships

First model

Define the fields the product understands.

Tables:
  - TableName: product
    Columns:
      - Name: name
        DataType: varchar(500)
        ColumnType: label
        IsNullable: false
      - Name: price
        DataType: float(7,2)
        ColumnType: float

Start Daptin with the schema available to the server. Inspect the table in dashboard3, its JSON:API resource, and the discovery metadata before adding production records.

What Daptin adds

Every record gets application infrastructure.

Internal and public identity

An integer primary key supports compact database joins while reference_id gives clients a stable UUID reference.

Lifecycle fields

created_at, updated_at, and version support change tracking and server-side stale-write detection.

Ownership and access

user_account_id and the permission field connect records to Daptin's authorization model.

Generated interfaces

The model appears through resource APIs, dashboard3, metadata, OpenAPI, and optional GraphQL.

Integrity

Express database expectations in the schema.

Use IsNullable, IsUnique, and IsIndexed for field-level behavior. Add explicit relationships instead of storing unverified identifiers in ordinary text columns.

Relations:
  - Subject: comment
    Object: post
    Relation: belongs_to

For a file column, use text storage with the appropriate file or image ColumnType and a ForeignKeyData reference to the intended cloud store. Do not invent a database-native image type.

Verification

Check behavior before importing data.

  • Create a valid record and confirm a public reference is returned.
  • Reject missing non-null fields and duplicate unique values.
  • Confirm expected indexes exist in the selected database.
  • Create and traverse each relationship from both relevant resource routes.
  • Attempt to refer to a missing record and verify rejection.
  • Test list, read, update, delete, and relationship permissions as a non-administrator.
  • Rehearse the schema change process with representative existing data.

Use the model through an application API.