Entidesign language reference
You describe a data model by typing it. Entidesign draws the diagram as you type. This page lists every rule of the language, each with a short example.
The only thing a model ever needs is an entity name. Everything else is optional, and leaving detail out is never an error.
A small model
// A tiny sales model
note: 'Orders and the people who place them'
Customer {
id as customer_id integer [pk]
Email as email varchar(255) [not null, unique]
}
Order
Product
Customer 1--* Order
Order *--* Product
How a model is laid out
The language works one line at a time. A line ends where you press Enter (both Windows \r\n and Unix \n line endings work). Tabs and spaces are treated the same. Blank lines are ignored.
If a line cannot be understood, only that line is affected, and everything else still appears in the diagram. A few problems, such as a quote or a note that is never closed, reach a little further; "Problems the editor reports" below says exactly what still appears.
Comments
// starts a comment that runs to the end of the line. A // inside a quoted string is not a comment.
Customer // the people who buy from us
// Order is not drawn yet
note: 'See https://example.com/data-rules'
Names
Entity names and field names may contain spaces and almost any character, so you can write them the way your business says them.
Order Line
Customer's Order
Größe
Extra spaces are tidied up: Order Line is the same as Order Line. Names are case-sensitive: Order and order are different.
A name cannot contain any of these characters: { } [ ] : . ". It cannot contain the word as on its own (it has a special meaning; only lower-case as is special, so AS is an ordinary word), and it cannot contain a relationship arrow such as 1--*.
To use any of those, put the name in double quotes:
"Order.Line"
"Terms as agreed"
Without the quotes, Terms as agreed is not a name with spaces in it: it means the entity Terms with the physical name agreed.
Entities
An entity is a name on a line of its own.
Customer
You can give an entity a physical name, which is the name used in the database. It follows as and is either one word or a double-quoted string.
Customer as tbl_customer
Customer as "tbl customer"
If you do not give a physical name, one is worked out from the entity name. Everything is made lower case, and each run of characters that are not letters or digits (spaces, apostrophes, dashes and so on) becomes a single underscore. Underscores at the very start or end are dropped, and a name that would start with a digit gets an underscore in front.
Order Line -> order_line
Customer's Order -> customer_s_order
2nd Address -> _2nd_address
To describe an entity in more detail, put { as the last thing on the line, list its fields on the lines below, and close it with a line holding only }.
Customer as tbl_customer {
id as customer_id integer [pk]
Name
}
An entity with nothing in it can be written with empty braces on one line, with or without spaces inside them, and with a physical name if you like. This is what you get when your editor closes the brace for you as you type {.
Customer {}
Customer as tbl_customer { }
Fields cannot go inside the braces of that one-line form. Customer { Name } creates Customer with no fields and reports the brace, because the fields have to be on the lines below.
Two entities cannot have the same name. The second one is ignored, you get an error on its first line, and the lines inside its braces are skipped.
Relationships
A relationship joins two entities with an arrow. Put a space on each side of the arrow.
Customer 1--* Order
The four arrows are:
| Arrow | Meaning |
|---|---|
1--1 |
one to one |
1--* |
one to many |
*--1 |
many to one |
*--* |
many to many |
An entity may be related to itself:
Employee 1--* Employee
You can point at a particular field by writing the entity, a dot, then the field name:
Customer.id 1--* Order.Customer
The field is matched by the name you gave it in the entity, never by its physical name. In the example above, a field written id as customer_id is referred to as id, not customer_id.
If an entity name contains a dot or other reserved character, quote it: "Order.Line".Quantity.
If you name a field that the entity does not have, the relationship is still drawn and you get a warning.
You can add a note to a relationship at the end of the line:
Customer 1--* Order [note: 'A customer may have no orders yet']
Entities created by relationships
You do not have to declare an entity before using it in a relationship. Naming it in a relationship is enough to put it on the diagram, in the order it was first mentioned.
Customer 1--* Order
This draws both Customer and Order. If you declare an entity later, the declaration fills in the one that is already there and keeps its place.
Customer 1--* Order
Order {
id [pk]
}
Fields
Fields go between the braces of an entity, one per line. A field is a name, then optionally as and a physical name, then optionally a data type, then optionally settings in square brackets.
Customer {
Name
Email as email_address
id as customer_id integer [pk]
Total as order_total decimal(10, 2) [not null]
}
A data type can only be given after a physical name. It is everything between the physical name and the settings, so it may contain spaces, parentheses and commas, as in decimal(10, 2).
If you leave the physical name out, it is worked out from the field name in the same way as for entities (Order Total becomes order_total).
A data type cannot contain [, because that is where the settings start. So int[] is read as the type int followed by empty settings, not as a list type. If you need a type with brackets in it, there is no way to write one yet.
Data types and the target database
A model can have a target database: Databricks, Fabric Lakehouse or SQL Server. It is a setting of the saved model, chosen from the top bar, not something written in the text. A model has none until one is chosen.
The language accepts any data type text. With a target chosen, a type that database does not know, or one with the wrong parameters (varchar(9000) on SQL Server, decimal(40) anywhere), is underlined as a warning, in the text and on the diagram's physical level. It is never refused: it is saved, and exported as written. With no target, nothing is checked.
Lists are written the Spark way, array<int>, which needs no [. Postgres-style int[] still cannot be written (backlog R1-13).
Settings
Settings go in square brackets at the end of a field, separated by commas. Setting names are written in lower case: [PK] is not recognised, write [pk].
| Setting | Meaning | Example |
|---|---|---|
pk |
part of the primary key | [pk] |
not null |
a value is required | [not null] |
unique |
no two rows may share a value | [unique] |
note: '...' |
a description of the field | [note: 'Shown on invoices'] |
values: ('a', 'b') |
the only values allowed | [values: ('open', 'closed')] |
default: ... |
the starting value; everything up to the next comma | [default: 0] |
Settings can be combined:
Status as status varchar(20) [not null, values: ('open', 'closed'), default: open]
A setting that is not recognised gives a warning. The other settings on that field still apply.
Notes
A note documents something. Write note: followed by text in single quotes.
At the top of the model, on a line of its own, a note describes the whole model:
note: 'Sales model for the 2027 rebuild'
If the top-level note: appears more than once, the last one is used.
On a line of its own inside an entity's braces, a note describes that entity:
Customer {
note: 'A person or company that buys from us'
id [pk]
}
If an entity has more than one note: line in its braces, the last one is used.
To put a single quote inside a note, write \'. To put a backslash in, write \\.
note: 'The customer\'s billing address'
For a longer note that runs over several lines, open and close it with three single quotes. The opening ''' is the last thing on its line (a // comment may follow it), and the closing ''' must be on a line of its own. The lines are kept as written, except that the indentation they all share is removed. The line break straight after the opening quotes and the one straight before the closing quotes are not part of the note.
note: '''
This model covers sales.
Returns are not included yet.
'''
Inside the three quotes nothing is escaped: a \ or a single quote means exactly what it looks like, and // is part of the note, not a comment. The only things a note cannot contain are a line holding just ''' and a line holding exactly note: ''' (which would start another note). Blank lines inside the note are kept as empty lines, and they do not count when working out the indentation the other lines share.
Notes can also be written as a setting on a field, or on a relationship, as shown above.
A note under a field or a relationship
A note that is too long for a field's settings goes on its own line (or lines) under the field, indented further than the field:
Customer {
Email as email string [unique]
note: '''
Where receipts are sent.
- Checked when the customer signs up
'''
Name
}
The same works for a relationship: a note indented under the relationship's line belongs to it.
Customer 1--* Order
note: 'A customer may have no orders yet'
What decides it is the indentation. A note: line indented further than the field or relationship line above it belongs to that field or relationship; blank lines and comment lines between them do not matter. A note: line that is not indented further keeps its usual meaning: inside an entity's braces it describes the entity, and at the top level it describes the model. Indentation is measured in columns, with a tab moving to the next even column.
If a field has a note in its settings and one under it as well, the one under it is used, with a warning.
Notes are written in markdown: **bold**, *italic*, lists, links, tables and code show formatted in the documentation panel and the data dictionary. Any HTML in a note is shown as text.
What editing on the diagram does to your text
Editing on the diagram changes only the lines it concerns, and every other line comes back exactly as you wrote it. A comment line directly above a field (no blank line between them) travels with that field when the field is moved, and deleting never removes a comment line. A note under a field moves and is deleted with its field.
A note written in the documentation panel goes where you would have typed it: a short one in a field's or relationship's settings, a longer one as a ''' note under it, an entity's first inside its braces, and the model's at the top, below any opening comments. A note that is already there is replaced where it stands.
Problems the editor reports
Each message points at the line and says what is wrong and what to do about it. A problem never blanks the diagram: whatever can be understood still appears, even while you are half-way through typing something.
Problems on a single line
Only the line with the problem is affected, and the rest of the model is drawn as usual.
| Problem | What it means | What still appears |
|---|---|---|
| Line not understood | The line does not follow any rule above. | The line is skipped. |
| Duplicate entity | An entity name was used twice. | The first one is kept. The second one and the lines inside its braces are skipped. |
| Duplicate field | A field name was used twice in one entity. | The first one is kept. |
| Unknown field | A relationship names a field the entity does not have. | The relationship is drawn. This is a warning. |
| Unknown setting | A setting in square brackets is not one of the settings above. | The other settings still apply. This is a warning. |
| Unterminated string | A quote was opened but never closed. | See below. |
A physical name with nothing after as, or text after an entity's physical name, is reported but the entity or field is still kept.
Quotes that are never closed
If a string is still open at the end of its line, the quote swallows the rest of the line. A broken quote never removes an entity or a field from the diagram. What you had typed before it is kept, and the broken part and anything after it on that line is left out:
Customer as "tblandCustomer as "tbl {keep the entityCustomer, with no physical name. If the line ends in{, its body still opens and its fields are kept.F as "bad intkeeps the fieldF, with no physical name or type.A [pk, note: 'oops]keeps the fieldAand itspk. The broken setting and any setting after it are dropped. This also applies to a stray apostrophe in an unquoted value such asdefault: it's: put the value in quotes, or leave the apostrophe out.- A relationship such as
A 1--* B [note: 'oops]is drawn, and only the note is left out.
Two things are skipped, because nothing on the line could be understood without the string. A name that is itself an unclosed double quote ("Customer) skips its line, and so does a note: 'oops line whose whole value is the string. When the skipped line is an entity line that ends in {, the lines inside its braces are skipped as well.
A line inside an entity's braces with a quote that never closes is always read as a field, even if it ends in { or looks like a relationship: the quote swallowed that part of the line.
A malformed note: line (including a multi-line note that is never closed) inside the braces of an entity that was skipped (a duplicate, or one with a bad name) is not reported again. The entity already has a problem on its first line.
A ( that is never closed in values:
values: ('open', 'closed' is reported once, at that setting, and the setting is ignored. The settings after it, such as unique or not null, still apply.
A { that is in the wrong place
{ has to be the last thing on an entity line. In Customer { Name } the entity Customer is created with no fields and the line is reported. The fields have to go on the lines below.
Entities that are never closed
An entity opened with { needs a line holding only } after its fields. While you are still typing, it is often missing, and the editor keeps what you have written:
- At the end of the text, the entity keeps every field read so far. The problem is reported on the entity's first line.
- A line that starts a new entity (it ends in
{, or is written{}) or a relationship ends the body that was open. The first entity keeps its fields and is reported on its first line, and the new line is read as normal. For this, a relationship has an arrow with a space on each side and a name on each side that is valid on its own. A field whose name really looks likeOrder 1--* Itemhas to be written in double quotes to stay a field. - A
}with nothing to close is reported on that line and skipped.
Multi-line notes that are never closed
A note opened with three single quotes is closed by the next line holding only three single quotes. If there is none, the note does not take the rest of the text. It ends just before the first later line that is only }, that ends in { or is written {} (an entity opening), or that is a relationship. Everything on that line and after it is read as normal. If there is no such line, the note runs to the end of the text.
If another note: ''' line comes before any closing ''', the first note was left half-typed. It ends at the earliest of that line and the lines listed above, so typing note: ''' above an entity that has its own multi-line note does not swallow it.
The problem is reported on the line that opened the note, and the note keeps the text it took. Blank lines at the very end are left out.
Summary of the problems
| Problem | What it means |
|---|---|
| Unclosed entity | An entity opened with { has no closing }. Its fields are kept. |
| Unexpected close | A } appears with nothing to close. It is skipped. |
| Unterminated string | A quote, or the ''' that opens a multi-line note, was never closed. |