The Sitecore config contains the following comments about these two attributes:
<!--
content: Database containing items to be edited.
database: Database containing items to be used for rendering the site.
-->
The content attribute defines the database which contains the items that will be edited from within the CMS interface. The default website
entry in the <sites>
section of config does not have this attribute set. Only the shell
and modules_shell
entry have the content attribute set to master.
The database attribute defines the database to use for rendering the site. The default website
entry in the <sites>
section of config has this set to web.
Note that different site
entries may have different values set for the database
attribute, for example on the shell
site database=core
.
For a standard installation, the settings should be as follows for custom site
entries:
- Content Management -
database = web
, content
not set
- Content Delivery-
database = web
, content
not set
If you have multiple publish targets that different sites could set this to one of the other "web" type databases if different sites need to use different DBs.
Also, if you take a look at /App_Config/Include/LiveMode.config.example
then you will see an example that patches the database
attribute to use master. This allow you to view the items without requiring publish from master to web.
Why does the content
need to be specified
The reason for the content database attribute and requiring this to be set on the shell
site is when you are editing items from the Content Editor the site context is shell
. The shell
site requires the core
database for all it's settings and configuration
You may often see code which references context database like so:
Database db = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
This is commonly used in code when executing in the content editing interface needs to access items in the master database (or whatever is set as content
).
There is some more details in this article about Content and Databases.