Online entity relationship diagram tool (Chen notation and Crow’s Foot)

What symbols, attributes, or entities are used in an ERD?

An entity-relationship diagram (ERD) is a tool used to help a developer to design databases at the conceptual level. An ERD uses three main elements to represent the building blocks of a database: entity, attribute, and relationship. Here they are in Gleek.

Entities

Entities are the real-world elements in your system. If something can be individually identified, then you can use it as an entity in your database. An entity is usually represented by a named rectangle.

Relationships

Relationships describe how entities are associated with each other. A relationship is usually represented by a named diamond in Chen notation, or just a labelled line in Crow’s Foot notation.

Attributes

Attributes are the properties or characteristics of entities. In Chen notation, one of the two most commonly used ways to draw an ERD, attributes are represented as an oval.

There are a number of different types of attributes, including simple attributes that cannot be broken down any further, composite attributes that can contain several simple attributes, and even derived attributes, which are worked out from other attributes.

In some cases, you’ll need the relationships in your database to show cardinality. This refers to the different numerical relationship between entities. Attributes and cardinality are where Chen and Crow’s Foot notation, the two most popular ways of drawing an ERD, diverge.

What is the difference between Chen and Crow’s Foot notation?

Chen and Crow’s Foot notation use different approaches to represent relationships. Some people prefer one over the other, but they ultimately show the same information.

Chen notation uses a diamond and connecting lines with symbols to describe relationship and cardinality, while Crow’s Foot just uses lines with symbols on the end. Cardinality is essential for showing the numerical relationship between entities.

Chen notation has the following possible cardinality:

  • One-to-one (1:1) – both entities are associated with only one attribute of another entity
  • One-to-many (1:N) – one entity can be associated with multiple values of another entity
  • Many-to-one (N:1) – many entities are associated with only one attribute of another entity
  • Many-to-many (M:N) – multiple entities can be associated with multiple attributes of another entity

Crow’s Foot has these relationships. While the logic is the same, the visual representation is quite different:

  • One
  • Many
  • Zero or many
  • One or many
  • One and only one
  • Zero or one

Chen notation in Gleek

Chen notation is easy to create in Gleek. You just create a diamond shape with connecting lines to other entities and add a text label. These screenshots from Gleek show you the syntax and resulting diagrams for the possible relationships in Chen notation. Remember that attributes can also be shown as an oval in Chen notation.

Crow’s Foot notation in Gleek

Gleek also now supports Crow’s Foot notation, but the syntax for using it can seem a little more complex at first, so let’s use Gleek’s unique syntax to walk you through creating relationships and cardinalities with Crow’s Foot notation. Note that attributes are not usually represented by an oval in Crow’s Foot notation, but are listed under the entity.

1. Start off by creating two entities. We’ll call them "Entity" and "Entity2". Note that you can use the TAB key to add attributes. Attributes must consist of two values separated by a space.

2. Now let’s add a one-to-one relationship. Just use {1}--{1} for a simple line, {1}-.-{1} for a dotted line, {1}-text-{1} to describe the relationship, and {1}-. text-{1} for a dotted line with a description.

3. Here are some one-to-one relationship examples between multiple entities.

{1}--{1} a one and only one notation on both sides

{1}--{01} a one and only one notation on one side of a relationship and a zero or one on the other

4. Many-to-many relationship examples:

{0..n}--{0..n} a zero to many on both sides of a relationship

{1..n}--{1..n} a one to many on both sides of a relationship

{1..n}--{0..n} a one to many on one side and a zero to many on the other

5. Many-to-one relationship examples:

{0..n}--{1} a zero to many notation on one side of a relationship and a one and only one on the other

{1..n}--{1} a one to many notation on one side of a relationship and a one and only one on the other

{0..n}--{01} a zero to many notation on one side of a relationship and a zero or one notation on the other

{1..n}--{01} a one to many notation on one side of a relationship and a zero or one notation on the other

How to create an ERD in Gleek

You have the freedom to create your ERD in Gleek using either Chen or Crow’s Foot notation, so choose whichever seems best for your project and dive in!

Let’s use a very simple example of the relationship between a customer and an order. We’ll go with Crow’s Foot notation for this and leave out attributes to keep it straightforward.

1. The customer places an order. The relationship is one and only one for customer and zero or many on the order side. This is the syntax in Gleek and how the diagram will start off:

2. The customer is now liable for invoice: one and only customer is liable for zero or many invoice(s).

3. The invoice covers the order: one and only one invoice covers one or many order(s).

4. The customer has an address: one or many customer(s) has/have one or many address(es). This is shown as an optional relationship with a dashed line.

5. The customer’s address receives the order: one and only one address receives zero or many orders.

6. The order includes an item: one and only one order includes one or many items.

7. Finally, each product can be ordered as one or many items, in other words, zero or many items are ordered for one and only one product. And each product can be in one and only category, while each category can include one or many products.