Schema plan

From petrowsky/agentic-fm · View interactive version

Schema plan is an AI agent skill from the GitHub repository petrowsky/agentic-fm. Design the data model for a new FileMaker solution from a natural language description — produce a Mermaid ERD showing base tables and relationships, then extend it to a FileMaker-specific model with table occurrences and a relationship specification. Use when the developer says "design schema", "pl

How to use this skill

Skill file

Schema Plan

Design a complete data model for a new FileMaker solution. Takes a natural language application description (and optionally existing SQL DDL, spreadsheet structure, or legacy schema) and produces two artifacts:

  1. Mermaid ERD — base tables, their fields, and relationships
  2. FM-specific model — extends the ERD with table occurrences (TOs) and a relationship specification

Output files:


FileMaker data model concepts

The agent must understand these distinctions when designing a schema. See also agent/docs/knowledge/disambiguation.md for the full table-vs-TO disambiguation.

Base tables vs table occurrences

Relationships

TOs and the API boundary


FM-specific field conventions

Every base table gets these system fields automatically when created (whether manually or via OData):

| Field | Type | Auto-enter | Purpose |

|-------|------|------------|---------|

| PrimaryKey | Text | Get ( UUID ) on creation | Unique record identifier |

| CreationTimestamp | Timestamp | Creation timestamp | When the record was created |

| CreatedBy | Text | Creation account name | Who created the record |

| ModificationTimestamp | Timestamp | Modification timestamp | When the record was last modified |

| ModifiedBy | Text | Modification account name | Who last modified the record |

These do not need to be listed in the ERD unless the developer requests full field detail. They are assumed present in every table.

Foreign key naming: ForeignKey{RelatedTableName} (e.g., ForeignKeyClient, ForeignKeyInvoice). Always Text type to match the UUID primary key.

FM field types: Text, Number, Date, Time, Timestamp, Container. There is no Boolean type — use Number (1/0) or Text ("Yes"/"No") depending on convention.


Workflow

Step 1 — Understand the requirements

Read the developer's application description carefully. If they provided existing schema (SQL DDL, spreadsheet headers, legacy structure), parse it for entities and relationships.

Identify:

If the description is ambiguous or incomplete, ask clarifying questions before proceeding. Common questions:

Step 2 — Design the base tables

For each identified entity, define:

Handle many-to-many relationships by introducing a join table (e.g., ProductCategories to connect Products and Categories).

Step 3 — Present the Mermaid ERD

Generate a Mermaid erDiagram showing all base tables, their fields, and relationships.

Mermaid syntax reference
erDiagram
    Clients ||--o{ Invoices : "has"
    Invoices ||--o{ LineItems : "contains"
    LineItems }o--|| Products : "references"

    Clients {
        text PrimaryKey PK
        text Name
        text Email
        text Phone
    }
    Invoices {
        text PrimaryKey PK
        text ForeignKeyClient FK
        date InvoiceDate
        text Status
        number Total
    }
    LineItems {
        text PrimaryKey PK
        text ForeignKeyInvoice FK
        text ForeignKeyProduct FK
        number Quantity
        number UnitPrice
        number LineTotal
    }
    Products {
        text PrimaryKey PK
        text Name
        number Price
        text Description
    }

Cardinality notation:

| Pattern | Mermaid | Meaning |

|---------|---------|---------|

| One-to-many | \|\|--o{ | One parent, many children |

| Many-to-one | }o--\|\| | Many children, one parent |

| One-to-one | \|\|--\|\| | One-to-one |

| Many-to-many | }o--o{ | Many-to-many (use join table instead) |

Field conventions in the ERD:

Step 4 — Review ERD with the developer

Present the ERD and ask the developer to confirm:

Review the ERD above. Does this capture the right entities and relationships? Reply with any changes (e.g., "add a Notes table", "Staff should connect to Invoices", "remove the Categories table") or confirm with "looks good" to proceed to the FM-specific model.

Iterate until the developer approves the ERD.

Step 5 — Extend to FM-specific model

Once the ERD is confirmed, produce the FM-specific model that extends it with:

5a — Table occurrences

List all TOs that will be needed. Start with the auto-created primary TOs (one per base table, same name), then identify additional TOs required for:

Format:

## Table Occurrences

### Auto-created (one per base table)
These are created automatically when the base table is created.

| TO Name | Base Table |
|---------|------------|
| Clients | Clients |
| Invoices | Invoices |
| LineItems | LineItems |
| Products | Products |

### Additional TOs (manual creation required)
These must be created manually in the relationship graph.

| TO Name | Base Table | Purpose |
|---------|------------|---------|
| Invoices_by_Client | Invoices | Show client's invoices in a portal on the Clients layout |
| LineItems_by_Invoice | LineItems | Show line items in a portal on the Invoices layout |
5b — Relationship specification

Produce a click-through checklist the developer can follow to create each relationship manually in the relationship graph. This is the primary deliverable of the FM-specific model.

Format each relationship as:

## Relationships

### 1. Clients -> Invoices (one-to-many)
- **Left TO**: Clients
- **Right TO**: Invoices
- **Join**: Clients::PrimaryKey = Invoices::ForeignKeyClient
- **Cascade delete**: Off
- **Allow creation**: Off

### 2. Invoices -> LineItems (one-to-many)
- **Left TO**: Invoices
- **Right TO**: LineItems
- **Join**: Invoices::PrimaryKey = LineItems::ForeignKeyInvoice
- **Cascade delete**: On (delete line items when invoice is deleted)
- **Allow creation**: On (allow creating line items from invoice portal)

### 3. LineItems -> Products (many-to-one lookup)
- **Left TO**: LineItems
- **Right TO**: Products
- **Join**: LineItems::ForeignKeyProduct = Products::PrimaryKey
- **Cascade delete**: Off
- **Allow creation**: Off

For each relationship, provide guidance on cascade delete and allow creation:

5c — Layout suggestions

Briefly suggest which layouts the solution will likely need, and which TO each should be based on:

## Suggested Layouts

| Layout Name | Based on TO | Purpose |
|-------------|-------------|---------|
| Client List | Clients | List view of all clients |
| Client Detail | Clients | Detail view with invoices portal |
| Invoice Detail | Invoices | Detail view with line items portal |
| Product List | Products | List/selection of products |

Step 6 — Write the output files

Create the plans/schema/ directory if it does not exist.

File 1: plans/schema/{solution-name}-erd.md

# {Solution Name} — Entity Relationship Diagram

Designed: {date}

## Tables

{brief description of each table's purpose}

## ERD

{mermaid diagram}

File 2: plans/schema/{solution-name}-fm-model.md

# {Solution Name} — FileMaker Data Model

Designed: {date}
Based on: {solution-name}-erd.md

## System Fields (all tables)

Every table includes these auto-created fields:
- PrimaryKey (Text, auto-enter UUID)
- CreationTimestamp (Timestamp, auto-enter)
- CreatedBy (Text, auto-enter)
- ModificationTimestamp (Timestamp, auto-enter)
- ModifiedBy (Text, auto-enter)

## Field Definitions

{complete field list per table, excluding system fields}

## Table Occurrences

{auto-created and additional TOs}

## Relationships

{click-through relationship specification}

## Suggested Layouts

{layout suggestions}

## Next Steps

1. Create the base tables (via OData with `schema-build` or manually in FM Pro)
2. Create additional table occurrences in the relationship graph
3. Create relationships per the specification above
4. Create layouts based on the suggested TO assignments

Step 7 — Report to the developer

Confirm both files were written and summarize:


Key considerations

Examples

Example 1 — Simple invoicing app

Developer: "I need an invoicing app. Clients have invoices, invoices have line items, line items reference products."

  1. Identify 4 entities: Clients, Invoices, LineItems, Products
  2. Design fields for each (Name, Email for Clients; InvoiceDate, Status, Total for Invoices; etc.)
  3. Generate ERD with 3 one-to-many relationships
  4. Developer confirms
  5. FM model adds TOs for portals (Invoices_by_Client, LineItems_by_Invoice)
  6. Relationship spec with cascade delete on Invoices->LineItems, allow creation on the portal relationships
  7. Write both files to plans/schema/invoicing-erd.md and plans/schema/invoicing-fm-model.md

Example 2 — From existing SQL DDL

Developer: "Here's my PostgreSQL schema, translate it to FileMaker" + provides CREATE TABLE statements

  1. Parse SQL DDL for tables, columns, types, constraints, and foreign keys
  2. Map SQL types to FM types (VARCHAR/TEXT -> Text, INTEGER/DECIMAL -> Number, DATE -> Date, etc.)
  3. Replace SQL auto-increment PKs with UUID-based PrimaryKey
  4. Replace SQL integer FKs with Text ForeignKey fields
  5. Handle SQL ENUM types as value lists (note in the model)
  6. Handle SQL JOIN tables as FM join tables
  7. Present ERD for confirmation, then produce FM model

Example 3 — From spreadsheet structure

Developer: "I have these spreadsheets: Contacts.xlsx (Name, Company, Email, Phone), Orders.xlsx (OrderDate, ContactName, Product, Qty, Price)"

  1. Identify that "ContactName" in Orders is a denormalized reference to Contacts — normalize with a ForeignKeyContact field
  2. Suggest separating Products into its own table if the same product appears in multiple orders
  3. Present the normalized ERD for confirmation
  4. Produce FM model with proper foreign key relationships
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.