Entities

Entities correspond to database tables or similar. Entities contain attributes.

Entity definitions consist of a name followed by { }. For example, users is the name of the below entity and it contains attributes id and displayName.

users {
id string
displayName string
}

It is possible for entities to contain nothing like the below.

users { }

Entity names are required to be unique.

Attributes

Attributes correspond to database table columns or similar.

Attribute definitions occur within an entity definition. They consist of a name, type (optional), and metadata (optional) delimited by the space character. Here is an example:

users {
id string pk
}

Outside of a definition (e.g. in a relationship statement), attributes are referred to following the entity that they belong to, separated by a .. Here is an example:

users.teamId > teams.id

It is possible to define an attribute and create a relationship in the same line by using a relationship statement directly inside the table definition. Here is an example:

users {
teamId < teams.id
}

Relationships

Relationships show the attribute-level relations between entities.

Here is an example:

users.teamId > teams.id

It is possible to show omit the attribute-level and simply show entity-level relations like this:

users > teams

The type of connecting line represents the cardinality between the two entities. Here are the types:

Connector Syntax Description
< One-to-many
> Many-to-one
- One-to-one
<> Many-to-many

If a relationship statement contains a name that has not been previously defined as an entity or attribute, an entity or attribute with that name will be created.