Skip to content

SQL Tables

The Astro D2 integration can be used to create diagrams representing SQL tables:

src/content/docs/example.md
```d2
Cloud: {
events: {
shape: sql_table
id: int {constraint: primary_key}
}
pages: {
shape: sql_table
id: int {constraint: primary_key}
event: int {constraint: foreign_key}
content: blob
}
pages.event -> events.id
Queue -> events
}
```

The above code block will be rendered as the following diagram:

Diagram