create_table
Create a new table in a Deriva domain schema, defining columns with types and constraints, and optionally adding foreign keys to reference other tables.
Instructions
Create a new table in the domain schema.
This tool creates a standard table (not an asset table). For tables that store files with automatic URL/checksum tracking, use create_asset_table instead.
Process Overview:
Define columns with names, types, and constraints
Optionally define foreign keys to reference other tables
The table is created in the domain schema
The navigation bar is automatically updated
Args: table_name: Name for the new table (e.g., "Subject", "Experiment", "Protocol"). columns: Column definitions, each dict with: - name (str, required): Column name - type (str): One of "text", "int2", "int4", "int8", "float4", "float8", "boolean", "date", "timestamp", "timestamptz", "json", "jsonb", "markdown" (default: "text") - nullok (bool): Allow null values (default: True) - comment (str): Column description foreign_keys: Foreign key definitions, each dict with: - column (str, required): Column name in this table (must also be in columns list) - referenced_table (str, required): Name of the table to reference - referenced_column (str): Column in referenced table (default: "RID") - on_delete (str): Action on delete - "NO ACTION", "CASCADE", "SET NULL" (default: "NO ACTION") comment: Description of the table's purpose. schema: Schema to create the table in. If not provided, uses the default domain schema. Useful when a catalog has multiple domain schemas.
Returns: JSON with status, table_name, schema, columns.
Examples: Simple table: create_table("Subject", [ {"name": "Name", "type": "text", "nullok": false}, {"name": "Age", "type": "int4"}, {"name": "Notes", "type": "markdown"} ])
Table with foreign key:
create_table("Sample", [
{"name": "Name", "type": "text", "nullok": false},
{"name": "Subject", "type": "text", "nullok": false},
{"name": "Collection_Date", "type": "date"}
], foreign_keys=[
{"column": "Subject", "referenced_table": "Subject", "on_delete": "CASCADE"}
])
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema | No | ||
| columns | No | ||
| comment | No | ||
| table_name | Yes | ||
| foreign_keys | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |