# Entity Relationship Diagrams

## What is an ﻿entity relationship diagram

- Used to model relationships among entities such as database tables
- Each entity contains an entity name and attributes (e.g. a table containing table name and fields)
- Each attribute can have an attribute name, type, and metadata (e.g. `id string pk`)
- Full syntax documentation found [﻿here](https://docs.tryeraser.com/docs/syntax-1)

## How to insert a new entity relationship diagram (﻿see how)

1. Click on the "+" button or `/` shortcut on the canvas
2. Select "Diagram as Code" from the menu
3. Select "Entity Relationship" from the menu

## How to edit an entity relationship diagram (﻿see how)
_Eraser's entity relationship diagrams are created and edited in code form, a concept we call Diagram-as-Code_

1. **Double-click** on the diagram to open the code editor
2. Each line of code represents a message or a statement
   - Try adding a new table with:
   
   ```
   subfolders {
     id string
     parentFolderId string
   }
   ```
   
   - Try adding a new relationship with: oo oo

```
   subfolders.parentFolderId > folder.id
   ```

3. Click on the "Syntax Help" button or "[﻿Documentation](https://docs.tryeraser.com/docs/syntax-1)" to learn more

Drawing canvas

Entity Relationship Diagram
