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 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


Properties are key-value pairs enclosed in [ ] brackets that can be appended to entity definitions. Properties are optional.

It is possible to set multiple properties like shown below:

users [icon: user, color: blue] {
teamId < teams.id

Here are the properties that are allowed:

IconAttached iconsIcon names (e.g. aws-ec2). See Icons page for full list.
ColorStroke and fill color, when possibleColor name (e.g. blue) or hex code (e.g. #000000)

Here are the lists of icon names:


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.


Here's a list of all the icons you can use with diagram-as-code.