# Core ERD

These diagrams show the core Capell database/model relationships. They are split so the relationship lines stay readable while still showing the real table links and polymorphic relationships.

## Publishing And Routing

The publishing ERD covers URL resolution and localized content:

- `sites` own `pages`, `site_domains`, and `page_urls`.
- `site_domains` and `page_urls` are scoped by `languages`.
- `page_urls` target pageable records through `pageable_type` / `pageable_id`.
- `translations` target translatable records through `translatable_type` / `translatable_id`.
- `redirect_health_snapshots` belongs one-to-one with `page_urls`.

![Capell core publishing ERD](../images/capell-core-publishing-erd.svg)

## Composition, Access, Assets, And Operations

The composition ERD covers how pages are rendered and how cross-cutting records attach:

- `pages.layout_id` references `layouts.id`.
- `layouts.elements` stores element keys as a JSON-backed relationship to layout elements.
- Layout elements own element assets.
- `widget_assets`, `asset_relations`, `media`, and `page_role_restrictions` use polymorphic relationships.
- `content_graph_edges` stores derived source/target relationships.
- Operational core tables track installed extensions, upgrade runs, and health alerts without owning content records.

![Capell core composition ERD](../images/capell-core-composition-erd.svg)

## Reading The Lines

Solid lines represent normal database foreign key relationships. Dashed lines represent polymorphic or logical relationships. Dotted lines represent JSON-backed relationships. Orange dashed lines represent derived graph or operational relationships.

Cardinalities are shown near each line end. For example, the `pages -> layouts` relationship is many pages to one layout, while `page_urls -> redirect_health_snapshots` is one URL to zero or one health snapshot.