Skip to content
Back to skills

Ontoplato Model Builder

ASecurity

OntoPlato ontology modeling and data ingestion: connect a data source, build and maintain the ontomap and mappings, load business data into PostgreSQL/MySQL with proposal-gated schema changes, and handle test-data packages and vector resource rules. Use ontoplato-knowledge-governance / ontoplato-knowledge-submit for business knowledge and ontoplato-analyst / ontoplato-query for querying.

  • 13 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added December 3, 2026
databasesgoshellbashsqlnodedockertestinggitapidatabase

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add ontomato-ai/OntoPlato --skill ontoplato-model-builder --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ontoplato Model Builder?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ontoplato Model Builder
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ontomato-ai-ontoplato-model-builder/badge)](https://www.skillsdirectory.com/skills/ontomato-ai-ontoplato-model-builder)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ontoplato-model-builder
description: "OntoPlato ontology modeling and data ingestion: connect a data source, build and maintain the ontomap and mappings, load business data into PostgreSQL/MySQL with proposal-gated schema changes, and handle test-data packages and vector resource rules. Use ontoplato-knowledge-governance / ontoplato-knowledge-submit for business knowledge and ontoplato-analyst / ontoplato-query for querying."
compatibility: Node.js 24+
---

# Model Builder

## Work through one ontology

OntoPlato is an ontology platform: it describes a business domain and uses that shared meaning to connect data, answer questions, and provide business operations.

| Concept | Meaning |
| --- | --- |
| Class and object | A class describes a business object type, such as Employee or Department. An object is one instance, identified by its primary-key value. |
| Attribute | A named property of an object, with a type and business meaning. Display names and descriptions explain a field; they do not replace its technical name. |
| Relationship | A directed business connection, such as Employee **belongs to** Department. Its meaning is distinct from how a database stores or queries it. |
| ontomap | The machine-readable definition of classes, attributes, relationships, descriptions, and data mappings. It describes the data; it is not the object records themselves. |
| Resources and `vector` attributes | A `vector` attribute associates text or file resources with an object for semantic retrieval and display; the object column stores a JSON array of resource references. |
| Capabilities on the ontology | Queries and analyses use these definitions. MetricViews expose reusable queries; Actions expose defined business operations; applications invoke those capabilities. They and business knowledge are managed separately from the ontomap JSON. |

Classes and attributes must map to real structures in the selected data source. Relational sources implement relationships via column JOINs or link tables; graph sources use stored edges. A storage change does not by itself remove a business relationship. Resolve mapping, direction, and multiplicity from evidence; do not infer a valid join merely from similar column names. Some relationships require a link table or another prepared mapping.

Keep every action inside one consistent ontology context: deployment, domain where applicable, object identities, and resource references. Reuse the business intent, access, and scope already established in the session. Resolve technical facts—such as JOIN columns and existing grant sources—through commands, authorized data tools, and bundled references. Ask only for missing business decisions or access that tools cannot supply; do not ask a nontechnical user to guess technical facts. When a required capability is unavailable, explain the missing prerequisite and affected business task while preserving the requested outcome.

## Scope and boundaries

This skill maintains the ontology and business data of a single business data source: connect a supported source, create or adapt its ontomap, write business data into PostgreSQL or MySQL while proposing schema changes for review, and load test-data packages. It does not migrate resource bindings or perform whole-database migrations.

Boundaries with other skills (do not duplicate their procedures here):

- **Business knowledge**: use `ontoplato-knowledge-governance` (governance read/write/review) or `ontoplato-knowledge-submit` (in-session submission).
- **Querying and Q&A verification**: use `ontoplato-analyst` for natural-language data questions and `ontoplato-query` for direct DSL queries or class/attribute probing.
- **Capability authoring**: use `ontoplato-capability-builder` for Action and MetricView function packages.
- **App assembly / permissions / adapter development**: see `ontoplato-app-builder`, `ontoplato-permission`, and `ontoplato-adapter-builder`.

## Connection and prerequisites

- Node.js 24+ (the script uses Node built-ins only) and a deployed OntoPlato instance reachable via its frontend base URL (for example `http://host:3000`).
- Platform access follows the owner's management operations and object rules; importing a test-data package requires change permission on the target test environment.
- All ontology API requests route through the frontend base URL: `<envUrl>/api/data-query/<backend path>`.
- Connection and credential resolution priority:
  1. In-platform execution callback (automatically preferred when the host injects `ONTOMATO_EXECUTION_CALLBACK` and `ONTOMATO_ONTOLOGY_URL`);
  2. External environment variables: `ONTOMATO_URL` (or `ONTOMATO_ONTOLOGY_URL`) plus `ONTOMATO_API_KEY` or `ONTOMATO_TK` (`ONTOMATO_LANGUAGE` overrides `Accept-Language`, which otherwise follows the skill's language directory and falls back to `en`);
  3. `application.yml` in the current working directory or this skill directory (supports `envUrl`, `ontologyUrl`, `apiKey`, `tk`, or `user`/`password`/`domainId` for automatic RSA SSO login; if `user` and tokens are omitted, calls run without authentication).
- This skill works both inside platform-hosted runs and standalone outside the platform. Direct business database writes (`db-sql`, `db-import`) require `databaseType` and `databaseCommand` in `application.yml`.

`application.yml` uses simple `key: value` lines (unquoted values, full-line comments). Keep any file containing administrative credentials private:

```yaml
# Frontend base URL of OntoPlato, without /api/data-query or a browser # route
envUrl: http://host:3000
# Login credentials and optional domainId (leave blank when using ONTOMATO_API_KEY / ONTOMATO_TK)
user:
password:
domainId:
# Business database settings (only for db-sql / db-import): postgresql or mysql
databaseType: postgresql
# JSON argv array of a client that reads SQL from stdin; store passwords in PGPASSWORD or MYSQL_PWD, not here
databaseCommand: ["psql", "-X", "-q", "-v", "ON_ERROR_STOP=1", "-h", "db-host", "-U", "user", "-d", "business"]
```

`databaseCommand` is executed directly without shell interpolation; it may invoke local `psql`/`mysql` or wrap them with `ssh`, `docker exec -i`, or a disposable container when local `psql` is unavailable:

```yaml
databaseCommand: ["docker", "run", "--rm", "-i", "-e", "PGPASSWORD=change-me", "postgres:16-alpine", "psql", "-X", "-q", "-v", "ON_ERROR_STOP=1", "-h", "db-host", "-p", "5432", "-U", "user", "-d", "business"]
```

Always pass `-v ON_ERROR_STOP=1` to `psql` so execution halts on error. This connects to the **business database** mapped by the ontology, not OntoPlato's own metadata database.

## Choosing the approach by task

Confirm the authorized deployment/context and business purpose first. Before changing existing settings, read `list-datasources` and `get-ontomap`. A successful connection test proves reachability only—not that the ontology is accurate or data is migrated.

| Task | How to use available capabilities | Verification criterion |
| --- | --- | --- |
| Create a new ontomap | Run `test-datasource`; inspect real tables/views/indices, columns, types, primary keys, and joins with a read-only database tool; prepare the ontomap, then run `use-datasource` followed by `set-ontomap`. | `get-ontomap` read-back matches; verify objects and relationships via `ontoplato-query` or `ontoplato-analyst`. |
| Maintain an existing ontomap | Start from the current `get-ontomap` output and edit in place; preserve untouched definitions, descriptions, and returned fields; base new or renamed mappings on source facts. | Target diff is applied and other business semantics remain intact. Renaming or adapting a mapping does not delete its relationships. |
| Switch data source | Test and inspect the target first, draft a compatible ontomap, resolve every existing relationship and resource binding, then run `use-datasource` and `set-ontomap`, read back, and verify by query. | Definitions match the real target; cross-object queries and resources work. The two saves are not atomic—if a step fails, inspect live state before retrying or restoring. |
| Load business data | When tables already exist: run `db-import` per CSV table, then `set-ontomap` to align new tables/columns. When tables or columns do not exist yet: generate a migration proposal via `propose-schema` and stop until a human or CI reviews and applies it. | Row counts and primary keys match the source files; imported objects and relationships are queryable via `ontoplato-query` or `ontoplato-analyst`. |
| Attach text/file resources | Load through business-data ingestion or a published Action with vector-write capability; use `import-test-data` in test environments. | Read back the object's `vector` references and verify search and download. |
| Import test data | Upload a zip package with `import-test-data` in a test environment or test domain. | Read back objects and resources; remember it clears every class present in the package—never use on production data. |
| Deploy a book-modeling hand-off package | Convert `ddl.sql` against `ontomap.draft.json` from `ontoplato-book-modeling` into a `propose-schema` proposal for human/CI review and execution; then run `db-import` and `set-ontomap`. Load evidence resources via ingestion or a published Action. | Proposal reviewed and applied outside this skill; model, records, and evidence resources verified against `import-map.md`. |

If required relationships, resources, or permission references lack an executable transition path, keep the current connection and ontomap untouched, finish the target draft, and report the missing access or capability. Resolve those dependencies before switching—never switch first and patch later.

Determine `fromField` and `toField` for relational sources from actual columns and values, verifying direction and cardinality. A missing join key is a data-preparation gap—never drop a business relationship or guess joins from display names. Before a full replacement removes classes, attributes, or relationships, obtain any missing business decision without re-asking for changes already authorized.

When domain selection is required, match the returned domain names to the user's business scope; ask only if ambiguity remains, never default to the first entry. Never place tokens or credentials into user-facing reports or public files.

## Commands

In the commands below, `<this-skill>` is the directory containing this `SKILL.md`. JSON arguments may be passed inline or as `@file`:

```bash
node <this-skill>/scripts/ontomato.mjs list-datasources
node <this-skill>/scripts/ontomato.mjs test-datasource <type> '<json>'
node <this-skill>/scripts/ontomato.mjs use-datasource <type> @payload.json
node <this-skill>/scripts/ontomato.mjs get-ontomap
node <this-skill>/scripts/ontomato.mjs set-ontomap @ontomap.json
node <this-skill>/scripts/ontomato.mjs propose-schema @proposal.json
node <this-skill>/scripts/ontomato.mjs db-sql @data-fix.sql
node <this-skill>/scripts/ontomato.mjs db-import public.paragraph @paragraph.csv [--from <rows>] [--batch <rows>]
node <this-skill>/scripts/ontomato.mjs import-test-data test-data.zip
```

### Command results and write scope

| Command | Observable output | Effect and boundary |
| --- | --- | --- |
| `list-datasources` | `currentType` and installed adapter metadata | Read-only; `requiresJoinFields` indicates whether relationships must declare explicit join columns. |
| `test-datasource` | Connection/catalog/search report by `kind` | Does not select the source, save credentials, migrate data, or validate every read/write operation. |
| `use-datasource` | `datasource set` | Saves and selects this adapter's connection; does not migrate ontomap, knowledge, resources, or permissions; preserves saved configs of other adapter types. Single-source only (see `ontoplato-workflow-admin` for `multiSource`). |
| `get-ontomap` | Full ontomap JSON | Reads definitions only, not object records. |
| `set-ontomap` | `ontomap saved` | Replaces the entire domain ontomap and validates the primary-key contract; does not create/alter business tables or migrate objects, permissions, or resources. Read back after saving. |
| `propose-schema` | Paths to written `.json` and `.sql` files | Produces a schema-migration proposal artifact; does not connect to the database or alter any schema. Hand off to a human or CI for review and execution. |
| `db-sql` | `sql executed` or client error | Runs **data** statements (DML fixes) inside one transaction, rolling back on error. **All DDL (`CREATE`, `ALTER`, `DROP`, `TRUNCATE`, `COMMENT ON`, `GRANT`, `REVOKE`, `RENAME`) is rejected before opening any database connection**—use `propose-schema` instead. |
| `db-import` | Per-batch progress | Reads RFC 4180 CSV (header row = column names) and inserts in transactional batches (default 500 rows); stops on first failing batch while prior batches stay committed; resume with `--from <importedRows>`. |
| `import-test-data` | `test data imported` | Uploads a test-data zip: clears every class listed in the file and its vector resources before writing; test environments or test domains only. |

Non-2xx HTTP responses or JSON payloads with `success: false` fail with a non-zero exit code. A success message never replaces post-write read-back and query verification.

## Writing business data and proposing schema changes

The ontology maps to real tables in the business database. This skill writes **business data** only and **holds no DDL authority**; all table creation and schema alterations must be proposed for human or CI review and execution:

1. **Propose schema changes**: run `node <this-skill>/scripts/ontomato.mjs propose-schema @proposal.json`. The payload requires `title`, `rationale`, and `statements` (array of non-empty SQL strings in the `databaseType` dialect), with optional `requestedBy`, `dialect`, and `ontomapChanges`. The command writes `<id>.json` and `<id>.sql` under `proposals/` (or `proposalDir` from `application.yml`) and prints their paths without connecting to the database. Stop here and hand the artifacts to a reviewer; never bypass DDL refusal with `db-sql` or a raw database client.
2. **Import business data**: once the reviewer applies the proposal and tables exist, run `db-import <table> <file>.csv`. The header row must match the table's column names. An unquoted empty field imports as `NULL`; `""` imports as an empty string. Values are written as string literals and cast by the database per column type. Imports append only (no truncate or upsert); primary-key conflicts fail the batch. Use `db-sql` only for non-DDL data fixes.
3. **Align the ontomap**: for newly added tables or columns, extend the current `get-ontomap` output and save with `set-ontomap`. Every class must have exactly one enabled `varchar` primary-key attribute, backed by a non-null unique column.
4. **Verify**: check row counts and primary keys with a read-only database client, then verify objects and relationships using `ontoplato-query` or `ontoplato-analyst`.

Direct script writes support PostgreSQL and MySQL only. For other databases, still generate proposals and CSVs, have operators apply them with native tools, and return to steps 3 and 4.

## Vector resources and object identity

OntoPlato stores resource files and embeddings; the object's `vector` column holds a JSON array string of resource references:

```json
[{"path": "...", "text": "...", "name": "..."}]
```

- `path`: stored resource path (required; used for retrieval, download, and deduplication).
- `text`: text content embedded for semantic search (required).
- `name`: original filename (optional; normalized by the platform to its trimmed basename and omitted when absent or blank—never store empty string or `null`).

Retrieval is scoped by domain/context, class name, and attribute name, and each resource binds to an object primary key. Prerequisites: the target object must already exist, the attribute must be declared as an enabled `vector` attribute, and the object primary key must be preserved verbatim.

Business-data ingestion or a published Action owns resource attachment, updates, and deletion in formal environments. Before deploying a hand-off package, confirm which ingestion job or published Action loads its evidence files. When using an Action, verify its object key, vector field, and parameters; submit uploads through its application form, or execute JSON-only Actions via `ontoplato-workflow-operator`. Read back the object's `vector` references and check downloads. Test environments can load vector resources through `import-test-data` below. When neither ingestion nor a published Action exists, hand the object keys, field, content, and files to the resource owner.

Before renaming a class, attribute, or primary key, confirm how existing resource references transition; after switching data sources, verify live retrieval and downloads.

## Test data

In a test environment or test domain, `import-test-data <file>.zip` loads objects, relationships, and vector resources in one call (`POST /api/data-query/testEnv/importData`). Zip layout:

```
- data.json          object and relationship rows
- files/             files referenced by vector attributes
```

```json
{
  "objDatas": [
    {
      "className": "/namespace/class1",
      "rows": [
        {
          "id": "c1",
          "attr1": "East",
          "photo": [
            {"path": "files/c1.jpg", "text": "A bright ward room", "name": "c1.jpg"}
          ]
        }
      ]
    }
  ],
  "relDatas": [
    {"relationName": "relation_type", "sourceObjId": "source_pk", "targetObjId": "target_pk"}
  ]
}
```

- `className` must be an existing class; each row includes only enabled attributes of that class and must carry a non-empty primary-key value unique within the file.
- `relationName` must be an existing relationship type, and both endpoint IDs must exist among the corresponding class rows in the same file.
- A `vector` attribute holds an array of `{"path", "text", "name"?}` objects: `path` points to an existing non-empty file under `files/` with a 1–16 character alphanumeric extension; `text` is non-empty and supplies the embedded content (callers provide audio/video transcripts); `name` is optional and preserves the original filename (omit when absent).
- Every class present in the file is **cleared first** (both objects and vector resources) before writing; classes absent from the file are untouched. If writing fails mid-way, prior clears/writes remain—fix the cause and re-import. Test environments only; never use on production data.

## Connecting a data source

1. `node <this-skill>/scripts/ontomato.mjs list-datasources` — `GET /api/data-query/businessConfig/dataAdapters`. Prints `currentType` (active adapter for the domain) and `adapters` (installed adapters with `type`, `label`, `requiresJoinFields`, `fields`, and `examples`); never exposes saved credentials.
2. `node <this-skill>/scripts/ontomato.mjs test-datasource <type> '<json>'` — `POST /api/data-query/businessConfig/testDataAdapter`. Takes the same arguments as `use-datasource` without saving configuration or switching sources. Prints a report keyed by `kind`:
   - Catalog sources (`kind: "catalog"`: JDBC, Neo4j, M3): prints `elapsedMs`, `databaseProduct`, `databaseVersion`, `driverName`, `driverVersion`, `catalog`, `schema`, and `tables` (tables/views with `name` and `type` as `TABLE` or `VIEW`). Table names are what class `name` must resolve to. For JDBC sources that support sandbox probing, the test may create and immediately drop a temporary empty probe table in the target schema to populate `sandboxCapability` (leaving no persistent table behind).
   - Search engines (`kind: "search"`: `elasticsearch`, `opensearch`): prints `elapsedMs`, `databaseProduct`, `databaseVersion`, `clusterName`, and `indices` (visible open indices). Physical indices are derived from class `name` (see rules below).
   - Fails if the connection resolves to no schema (e.g., nonexistent PostgreSQL `currentSchema`) or if a DuckDB file does not exist (testing never creates it). Timeout is 15 seconds.
3. `node <this-skill>/scripts/ontomato.mjs use-datasource <type> '{"url":"jdbc:postgresql://db.example:5432/my_database?currentSchema=public","user":"app","password":"change-me"}'` — `POST /api/data-query/businessConfig/useDataAdapter`. Merges `type` into the JSON payload. Provide the fields listed in `fields` (typically `url`, `user`, `password`).

Available adapter types depend on the deployment; treat `list-datasources` as authoritative.

### Database connection notes

Do not put locale-specific parameters such as `serverTimezone=Asia/Shanghai` in JDBC URLs.

| Type | Notes |
| --- | --- |
| `mysql` | May include `useUnicode=true&characterEncoding=utf8&useSSL=false`, e.g., `jdbc:mysql://db.example:3306/my_database?useUnicode=true&characterEncoding=utf8&useSSL=false`. |
| `postgresql` | Specify schema via `currentSchema`, e.g., `jdbc:postgresql://db.example:5432/my_database?currentSchema=public`. |
| `oracle` | Thin format, e.g., `jdbc:oracle:thin:@db.example:1521:orcl`. |
| `sqlserver` | Select database via `databaseName`, e.g., `jdbc:sqlserver://db.example:1433;databaseName=my_database`. |
| `db2` | E.g., `jdbc:db2://db.example:50000/my_database`. |
| `gaussdb` | Uses `jdbc:opengauss://`, e.g., `jdbc:opengauss://db.example:5432/my_database`. |
| `duckdb` | Backend-accessible file path, e.g., `jdbc:duckdb:/data/warehouse.duckdb`; `url` only. |
| `neo4j` | Bolt URL with `user` and `password`, e.g., `bolt://db.example:7687`; queries the server's default database. |
| `elasticsearch` | HTTP URL with optional Basic auth `user` and `password`, e.g., `http://host:9200`. |
| `opensearch` | HTTP URL with optional Basic auth `user` and `password`, e.g., `https://host:9200`. Point-in-time (PIT) requires OpenSearch 2.4+; declared primary keys must be unique and mapped to a sortable `keyword` field or `.keyword` subfield. |

## ontomap specification

`get-ontomap` calls `GET /api/data-query/admin/getSchema`; `set-ontomap` calls `POST /api/data-query/admin/setSchema` with the complete ontomap object, **replacing** the domain's ontomap wholesale (no merge).

> **Read-back normalization**: `get-ontomap` returns the server-normalized representation—an explicit `"type": "fk"` on a relationship may be omitted on read-back (inferred from `fromField`/`toField`), and class entries include server fields such as `classToCard: null` and `instanceToCard: null`. Verify semantic and structural equivalence rather than byte-for-byte JSON string equality.

| Field | Convention and semantics |
| --- | --- |
| `datasetDesc` | Business description of the entire dataset, injected into programming and question-splitting prompts. Write in the model's response language with business meanings, units, and enumerations. |
| `classList` | List of class names in this domain; keep aligned with `name` entries in `classDefs`. |
| class `name` | SQL table name or Elasticsearch/OpenSearch index name. Matched as an exact string internally; an extra leading `/` is tolerated only when the stored name itself has no `/`. Relational adapters interpolate it verbatim and unquoted into `FROM`/`JOIN` without schema prefix or case folding (put schema in the JDBC URL, e.g., PostgreSQL `currentSchema`). Elasticsearch/OpenSearch derives the physical index by trimming whitespace, lowercasing, replacing every character outside `/` and `a-z0-9_-` with `_`, and prepending `i` if the result starts with `-`, `_`, `+`, or `.`; only existing indices matching that derived name are reachable. |
| class `showName` | Display name used in UI and question-splitting subgraphs; not a SQL table name and not a substitute for class `desc`. |
| class `desc` | Class description shown in prompts; explain meaning, units, and scope in business language. |
| `inStarChart` | **Star Chart is retired**; no runtime path reads this field. `get-ontomap` still stores and echoes it; omitting it or setting `false`/`true` has no functional effect. |
| attr `name` | SQL column name or search document field name. Relational adapters interpolate `alias.column` verbatim and unquoted with the same matching rules as class `name`. |
| attr `showName` | Display name saved and returned with the ontomap; schema prompts and SQL use `name` and `desc`. |
| attr `desc` | Field description read by models; document meaning, units, and enumerations in business language. |
| attr `options` | Declared display options for `varchar`/`text` or numeric attributes: `[{"value": …, "label": …, "tone": …}]`. `value` is required, unique within the attribute, and typed to match the attribute; `label` overrides displayed text; `tone` is one of `default`, `info`, `success`, `warning`, `danger`. Presentation only—stored values outside the list are displayed and saved unchanged. Omit when unused. |
| `type` | One of `varchar`, `text`, `int`, `long`, `double`, `date`, `timestamp`, `vector`, matching the underlying mapping. `vector` stores a JSON array of resource references (`path`, `text`, optional `name`) and is not compared by equality/range. |
| `bizzKey` | When `true`, DSL queries automatically include this column if omitted (the data retriever's SQL generator ignores this flag). Set `true` for key business columns to retain, `false` otherwise. |
| `enable` | Only `true` attributes appear in schema prompts and SQL (`false` hides them). Defaults to enabled; write `true` explicitly. |
| `primaryKey` | **Exactly one** `true` per class, and it must have `enable: true` and `type: "varchar"` or saving fails. Declaring the type does not convert underlying data; if the source key is non-string, prepare a compatible mapping (such as a view or string key column) via authorized data tools first. |
| relationship key | Stable identifier (`letters`, `digits`, `_`) written as `fromClass_verb_toClass` (e.g., `emp_belongs_to_dept`), not a bare class-pair join (`emp_dept`). Models copy it into DSL; actual meaning lives in `desc`. |
| relationship `type` | One of `fk`, `n:n`, or `graph`. When omitted, inferred for legacy compatibility (`linkTable` → `n:n`, `fromField`/`toField` → `fk`, otherwise → `graph`). Declare `type` explicitly on new relationships. |
| `fromClass`, `toClass` | Endpoint class `name` values. Direction runs from `fromClass` to `toClass` and carries semantic meaning. |
| `fromField` | Existing join column on `fromClass`: foreign key for `fk`, or `fromClass` primary key (usually `id`) for `n:n`. Required when `list-datasources` reports `requiresJoinFields: true`. |
| `toField` | Existing join column on `toClass`: join condition is `fromClass.fromField = toClass.toField` for `fk`, or `toClass` primary key (usually `id`) for `n:n`. Graph sources with `requiresJoinFields: false` use native edges. |
| `linkTable` | `n:n` only: physical bridge table name, interpolated verbatim like class `name`. Must already exist in the database; `set-ontomap` never creates tables. |
| `linkTableFromField` | `n:n` only: bridge-table column storing `fromClass` primary keys. |
| `linkTableToField` | `n:n` only: bridge-table column storing `toClass` primary keys; must differ from `linkTableFromField`. |
| relationship `desc` | Relationship description; must be a **predicate** (verb phrase) reading cleanly from `fromClass` to `toClass`—see rules below. |

### Three relationship implementations: `fk`, `n:n`, `graph`

- **`fk`**: one side holds the other's primary key; `fromField` and `toField` are real columns joined via `fromClass.fromField = toClass.toField`.
- **`n:n`**: implemented through a bridge table. `fromField`/`toField` name each side's primary key, `linkTable` names the bridge table, and `linkTableFromField`/`linkTableToField` name the two distinct key columns in the bridge table. The bridge table must be created first via a schema proposal; `set-ontomap` saves semantics only. Relational adapters join through the bridge table and reject many-to-many data declared as `fk`; graph adapters (such as Neo4j) implement `n:n` as native edges without materializing `linkTable`.
- **`graph`**: native edges in a graph source; no `fromField`/`toField` required.

Example `n:n` definition:

```json
{
  "relationshipDefs": {
    "student_has_guardian": {
      "fromClass": "student",
      "toClass": "guardian",
      "type": "n:n",
      "fromField": "id",
      "toField": "id",
      "linkTable": "student_guardian_link",
      "linkTableFromField": "student_id",
      "linkTableToField": "guardian_id",
      "desc": "has guardian"
    }
  }
}
```

Physical bridge table (PostgreSQL example for a `propose-schema` proposal):

```sql
CREATE TABLE student_guardian_link (
  student_id varchar NOT NULL,
  guardian_id varchar NOT NULL,
  PRIMARY KEY (student_id, guardian_id)
);
```

When verifying `n:n`, query in both directions (`student -> guardian` and `guardian -> student`) and confirm the bridge table has no duplicate pairs.

### Name relationships as subject–verb–object predicates

Write every relationship's `desc` as a **predicate** (verb phrase) that holds from `fromClass` to `toClass`, not a noun phrase concatenating both class names:

| Write this (predicate) | Avoid this (noun phrase) |
| --- | --- |
| `belongs to` | `employee and department` |
| `located in` | `company-city relation` |
| `contains` | `order items` |
| `is parent of` | `parent-child` |
| `manages` | `manager` |

- Read "`fromClass` + `desc` + `toClass`" as a natural subject–verb–object clause with the right actor: `emp --belongs to--> dept`, or reversed as `dept --contains--> emp`.
- Keep direction consistent across the model: flows point from actor/cause to target/result (`customer --submits--> order`); membership points from part to whole (`belongs to`). Avoid passive wording ("by…", "from…"); make the active party the subject.
- Converge synonyms: one verb carries one meaning model-wide instead of mixing near-synonyms unless business questions distinguish them.
- Keep `desc` purely to the predicate—do not repeat endpoint class names or append parenthetical scope notes.
- For self-relationships and multiple relationships between the same pair of classes, distinguish direction and role via the predicate (`manages`, `reports to`, `is project manager of`, `is member of`).
- Write short phrases in the model's response language, not full sentences. These rules apply only to relationship keys and `desc`; `datasetDesc`, class `desc`, and attribute `desc` remain business descriptions with nouns, units, and enumerations.

### Minimal ontomap example

```json
{
  "datasetDesc": "Employees and departments",
  "classList": ["dept", "emp"],
  "classDefs": [
    {
      "name": "dept",
      "showName": "Department",
      "desc": "A department within the organization",
      "attrs": [
        {
          "name": "id",
          "showName": "ID",
          "desc": "Department primary key",
          "type": "varchar",
          "bizzKey": true,
          "enable": true,
          "primaryKey": true
        },
        {
          "name": "name",
          "showName": "Name",
          "desc": "Department name",
          "type": "varchar",
          "bizzKey": true,
          "enable": true,
          "primaryKey": false
        }
      ]
    },
    {
      "name": "emp",
      "showName": "Employee",
      "desc": "An active employee",
      "attrs": [
        {
          "name": "id",
          "showName": "ID",
          "desc": "Employee primary key",
          "type": "varchar",
          "bizzKey": true,
          "enable": true,
          "primaryKey": true
        },
        {
          "name": "dept_id",
          "showName": "Department",
          "desc": "Department ID",
          "type": "varchar",
          "bizzKey": false,
          "enable": true,
          "primaryKey": false
        },
        {
          "name": "age",
          "showName": "Age",
          "desc": "Age in years",
          "type": "int",
          "bizzKey": false,
          "enable": true,
          "primaryKey": false
        }
      ]
    }
  ],
  "relationshipDefs": {
    "emp_belongs_to_dept": {
      "fromClass": "emp",
      "toClass": "dept",
      "type": "fk",
      "desc": "belongs to",
      "fromField": "dept_id",
      "toField": "id"
    }
  }
}
```

Files in this skill

  • SKILL.md31.7 KB
  • application.yml563 B
  • scripts/client.mjs31 KB
  • scripts/ontomato.mjs36.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in databases →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.