---
title: Document database structure
related:
  - https://docs.kentico.com/k8/managing-website-content/working-with-documents-and-pages.md
  - https://docs.kentico.com/k8/developing-websites/defining-website-data-structure/document-types.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

The Kentico database stores documents (nodes in the content tree of websites) in several joined tables:

| Database table                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CMS\_Tree                          | Stores:<br>Data that determines the position of documents in the website content tree<br>Basic document properties that are shared between all [language versions](https://docs.kentico.com/k8/multilingual-websites/editing-the-content-of-multilingual-websites.md) of the same document<br>Contains **only one record for each document**, regardless of the number of language versions. The tables does not store any [versioned data](https://docs.kentico.com/k8/managing-website-content/configuring-the-environment-for-content-editors/configuring-and-using-document-versioning.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| CMS\_Document                      | Stores:<br>Document properties that have unique values for each [language version](https://docs.kentico.com/k8/multilingual-websites/editing-the-content-of-multilingual-websites.md)<br>The content of [editable regions](https://docs.kentico.com/k8/managing-website-content/working-with-documents-and-pages/editing-documents-and-pages.md)<br>The data of [editor widgets](https://docs.kentico.com/k8/managing-website-content/adding-page-content-through-widgets.md)<br>May contain **multiple records per document**, one for each language version. Some of the document columns are [versioned](https://docs.kentico.com/k8/managing-website-content/configuring-the-environment-for-content-editors/configuring-and-using-document-versioning.md).                                                                                                                                                                                                                                                                                                                          |
| Coupled data tables<br>(CONTENT\_) | Stores the fields of individual [document types](https://docs.kentico.com/k8/developing-websites/defining-website-data-structure/document-types.md).<br>For example, the _News_ document type has the **CONTENT\_News** coupled table with the columns defined for news documents, such as _NewsTitle_, _NewsSummary_, _NewsText_.<br>Records in the coupled data tables are bound to documents through the **DocumentForeignKeyValue** column of the **CMS\_Document** table.<br>The document type of tree nodes is determined by the **NodeClassID** column in the **CMS\_Tree** table.<br>Container document types, such as _Folder_, do not have a coupled table.<br>Every [language version](https://docs.kentico.com/k8/multilingual-websites/editing-the-content-of-multilingual-websites.md) of a document has its own record in the corresponding coupled data table.<br>All columns in coupled data tables are [versioned](https://docs.kentico.com/k8/managing-website-content/configuring-the-environment-for-content-editors/configuring-and-using-document-versioning.md). |

![The relationships between document database tables](https://docs.kentico.com/docsassets/k8/document-database-structure/Document_tables.png "The relationships between document database tables")

## Document attachments and versions

| Database table         | Description                                                                                                                                                                                                                                                                                                                                                                                                   |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CMS\_Attachment        | Stores files uploaded to the database as [document attachments](https://docs.kentico.com/k8/managing-website-content/working-with-files/document-attachments.md).                                                                                                                                                                                                                                             |
| CMS\_VersionHistory    | Stores [document versions](https://docs.kentico.com/k8/managing-website-content/configuring-the-environment-for-content-editors/configuring-and-using-document-versioning.md), including older versions and versions that are being edited. When a version is published, the system updates the corresponding records in the **CMS\_Tree** and **CMS\_Document** tables using the data of the version record. |
| CMS\_AttachmentHistory | Stores attachments of document versions. The main purpose of this table is to avoid redundancy for document versions that use the same attachments.<br>When a document version is published, the system updates the records in the **CMS\_Attachment** table using the data of the version record.                                                                                                            |
| CMS\_VersionAttachment | Stores relationships between document versions and their document attachments.                                                                                                                                                                                                                                                                                                                                |

![Database diagram of all document tables](https://docs.kentico.com/docsassets/k8/document-database-structure/Database_documents.png "Database diagram of all document tables")

## Document relationships

| Database table            | Description                                                                                                                       |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| CMS\_Relationship         | Stores records representing relationships between two documents.                                                                  |
| CMS\_RelationshipName     | Stores the relationship names (types) defined in the system.                                                                      |
| CMS\_RelationshipNameSite | Binding table that connects relationship names to websites. Each entry indicates that a relationship can be used on a given site. |

![Database diagram of document relationship tables](https://docs.kentico.com/docsassets/k8/document-database-structure/Database_doc_Relationships.png "Database diagram of document relationship tables")
