# Entity-Relationship Diagram

![Entity-Relationship Diagram](https://content.gitbook.com/content/aNbtXAm2MUsbrMlAEZb1/blobs/yg2eVDxGknrO9CNfGmLP/Main.png)

## Create Entity-Relationship Diagram

To create a Entity-Relationship Diagram:

1. Select first an element where a new Entity-Relationship Diagram to be contained as a child.
2. Select **Model | Add Diagram | ER Diagram** in Menu Bar or select **Add Diagram | ER Diagram** in Context Menu.

## Data Model

To create a Data Model (model element only) by Menu:

1. Select an Element where a new Data Model to be contained.
2. Select **Model | Add | Data Model** in Menu Bar or **Add | Data Model** in Context Menu.

## Entity

To create an Entity:

1. Select **Entity** in **Toolbox**.
2. Drag on the diagram as the size of Entity.

To create a Entity (model element only) by Menu:

1. Select a Data Model where a new Entity to be contained.
2. Select **Model | Add | Entity** in Menu Bar or **Add | Entity** in Context Menu.

You can use **QuickEdit** for Entity by double-click or press `Enter` on a selected Entity.

* **Name** : Enter name.
* **Add Note** : Add a linked note.
* **Add Column** (`Ctrl+Enter`) : Add a column.
* **Add One to One** : Add an one-to-one relationship with an entity.
* **Add One to Many** : Add an one-to-many relationship with an entity.
* **Add Many to Many** : Add an many-to-many relationship with an entity.

To suppress Columns, see [Suppress Columns](https://docs.staruml.io/user-guide/formatting-diagram#suppress-columns).

## Column

To add a Column:

1. Select an Entity.
2. Select **Model | Add | Column** in Menu Bar or **Add | Column** in Context Menu.

You can use **QuickEdit** for Column by double-click or press `Enter` on a selected Column.

* **Column Expression** : Edit column expression.

  *Syntax of Column Expression*

  ```
  column ::= name [ ':' type ] [ '(' length ')' ]
  name ::= (identifier)
  type ::= (identifier)
  length ::= (string)
  ```
* **Primary Key** : Check whether the column is primary key or not.
* **Add** (`Ctrl+Enter`) : Add one more column in the below.
* **Delete** (`Ctrl+Delete`) : Delete the column
* **Move Up** (`Ctrl+Up`) : Move the column up.
* **Move Down** (`Ctrl+Down`) : Move the column down.

## Relationship

To create a Relationship:

1. Select **One-to-One Relationship**, **One-to-Many Relationship** or **Many-to-Many Relationship** in **Toolbox**.
2. Drag from an entity and drop on another entity.

You can use **QuickEdit** for Relationship by double-click or press `Enter` on a selected Relationship.

* **Name** : Enter name.
* **Identifying** : Check whether the relationship is identifying or not.
* **Add Note** : Add a linked note.

You can also use **QuickEdit** for Relationship End by double-click at the end side of a Relationship.

* **Name** : Enter name.
* **Cardinality** : Select cardinality of the selected relationship end.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.staruml.io/working-with-additional-diagrams/entity-relationship-diagram.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
