Marks a column as the primary key.
id uuid PRIMARY KEY NOT NULLThis page documents the SQL syntax currently supported by TinkerDiagram's ERD source editor. The source sidebar accepts SQL only, and valid SQL `CREATE TABLE` statements are reflected into the ERD canvas.
The ERD source editor is SQL-first again. The supported source contract is a practical CREATE TABLE subset aimed at schema modeling and ERD reflection, not a full SQL dialect implementation.
These are the SQL constructs the ERD source editor is designed to accept and reflect into the canvas.
A minimal ERD source document is a sequence of CREATE TABLE statements.
CREATE TABLE organizations (
id uuid PRIMARY KEY NOT NULL,
name varchar(255) NOT NULL
);
CREATE TABLE users (
id uuid PRIMARY KEY NOT NULL,
organization_id uuid NOT NULL REFERENCES organizations(id),
email varchar(255) UNIQUE NOT NULL
);Each table should be written as a standard CREATE TABLE statement with column definitions inside the body.
CREATE TABLE users (
id uuid PRIMARY KEY NOT NULL,
email varchar(255) NOT NULL
);Columns follow the standard SQL structure of name, type, and one or more supported clauses.
Example: `created_at timestamp NOT NULL`
These clauses are supported directly in the SQL source editor and are reflected into the ERD model.
Marks a column as the primary key.
id uuid PRIMARY KEY NOT NULLAdds a unique constraint to a single column.
email varchar(255) UNIQUE NOT NULLMarks a column as required.
name varchar(255) NOT NULLAllows null values explicitly.
middle_name varchar(255) NULLSets a default value.
status varchar(50) DEFAULT 'draft'Declares a foreign-key relationship.
organization_id uuid NOT NULL REFERENCES organizations(id)Composite keys and some multi-column rules belong at the table level.
CREATE TABLE user_role (
user_id uuid NOT NULL,
role_id uuid NOT NULL,
PRIMARY KEY (user_id, role_id)
);CREATE TABLE members (
workspace_id uuid NOT NULL,
email varchar(255) NOT NULL,
UNIQUE (workspace_id, email)
);CREATE TABLE posts (
id uuid PRIMARY KEY NOT NULL,
author_id uuid NOT NULL,
FOREIGN KEY (author_id) REFERENCES users(id)
);Relationships are inferred from REFERENCES clauses and supported foreign-key constraints.
CREATE TABLE organizations (
id uuid PRIMARY KEY NOT NULL,
name varchar(255) NOT NULL
);
CREATE TABLE users (
id uuid PRIMARY KEY NOT NULL,
organization_id uuid NOT NULL REFERENCES organizations(id),
email varchar(255) UNIQUE NOT NULL
);CREATE TABLE users (
id uuid PRIMARY KEY NOT NULL
);
CREATE TABLE profiles (
id uuid PRIMARY KEY NOT NULL,
user_id uuid UNIQUE NOT NULL REFERENCES users(id)
);CREATE TABLE users (
id uuid PRIMARY KEY NOT NULL
);
CREATE TABLE roles (
id uuid PRIMARY KEY NOT NULL
);
CREATE TABLE user_role (
user_id uuid NOT NULL REFERENCES users(id),
role_id uuid NOT NULL REFERENCES roles(id),
PRIMARY KEY (user_id, role_id)
);These behaviors define how SQL source editing interacts with the ERD canvas and persistence flow.
The source editor intentionally supports a constrained SQL subset rather than arbitrary SQL.