This chapter describes the structure of the content stored in the Kentico CMS repository and how they can be accessed.
Database structure of the documents
Document data is stored in several joined tables that are used for the tree structure, multilingual support and custom document fields. The document record consists of the following tables:
• | CMS_Tree – a table with basic document data shared between different language versions of same document. This table determines the tree structure of the website document content. Table contains one record for all culture versions of the document. The table does not contain any versioned data. |
• | CMS_Document – a table with document data of specified language version of the document. Table contains several records for every document, each one representing one language version of the document. Some of the document columns are versioned columns. |
• | Coupled table – a table that contains document-type specific fields defined by the developer. For example the News document type has a Content_News coupled table that contains NewsTitle, NewsSummary, NewsText and other fields specific for news. Coupled table primary key is referenced by the value of DocumentForeignKeyValue column and the table is determined by type of the document. Container document types, such as folder, do not have any coupled table. All columns from coupled tables are versioned. Each culture version of the coupled document contains one record in the coupled table. |
The following figure shows how the tables are connected:
See Kentico CMS Database Reference or the database structure for details on the table columns.
TreeNode Class
The CMS.TreeEngine.TreeNode class encapsulates the tables described above. You can work with the document values using the TreeNode class properties (if available) or using the SetValue and GetValue methods with column name from either CMS_Tree, CMS_Document or coupled table. There are following methods to make the changes to the database:
• | Insert – Inserts complete document record to the database, creates new record in CMS_Tree, CMS_Document and coupled table. Use this method for first culture version of the document. |
• | InsertAsNewCultureVersion – Inserts a new language version of the document. Creates new record in CMS_Document and coupled table bound to the existing CMS_Tree record. Use for the new language versions of the same document if some language version of the document already exists. |
• | Update – Updates the document record (all three tables) in the database |
• | Delete – deletes the document record from the database. It deletes the CMS_Document and coupled table record. If the document is the last culture version of the document, it deletes also the CMS_Tree record. |
The next chapters contain code examples of working with documents.
See also: Managing attachments, Versioning internals, Workflow internals
Page url: http://devnet.kentico.com/docs/devguide/index.html?content_management_internals.htm