The Places database

  • Revision slug: The_Places_database
  • Revision title: The Places database
  • Revision id: 100944
  • Created:
  • Creator: Nickolay
  • Is current revision? No
  • Comment fix typos, tweak markup, add a category

Revision Content

This document provides a high-level overview of the overall database design of the Places system. Places is designed to be a complete replacement for the Firefox bookmarks and history systems using Storage.

Core URL table

  • moz_history: This is the main table of URLs and is managed by the history service (see also History service design). This table may be renamed to something better like moz_urls in the future. Any time a Places component wants to reference a URL, whether visited or not, it refers to this table. Each entry has an optional reference to the moz_favicon table to identify the favicon of the page.

History tables

  • moz_historyvisit: One entry in this table is created each time you visit a page. It contains the date, referrer, and other information specific to that visit. It contains a reference to the moz_history table which contains the URL and other global statistics. See History service design for more information.

Bookmarks tables

Warning: The bookmarks service may change significantly before Firefox 3 is released.
  • moz_bookmarks_folders: Contains the list of bookmark folders. Each folder entry contains a numerical folder ID, a title, and some information relating to remote containers.
  • moz_bookmarks_roots: Lists special known folders. Names such as "root", "menu", and "toolbar" are mapped to folder IDs in the moz_bookmarks_folders table.
  • moz_bookmarks: This table contanins the bookmarks hierarchy. It maps a parent folder ID and an integer index to either a page ID (referencing the moz_history table), or a folder ID (referencing the moz_bookmarks_folders table). As a special case, if both the page and the folder are 0, the item is a separator.
  • moz_keywords: This table maps a keyword name to a URL (moz_history ID). It is likely that this functionality will be removed from the bookmarks service.

See Bookmarks service design for more information.

Annotation tables

  • moz_anno_name: Contains the names of all the annotations in the system and a name ID. There should be relatively few unique names.
  • moz_anno: Contains the values of the annotations. It maps a page (reference to moz_history) and an annotation name (reference to moz_anno_name) to the value of the annotation.

Favicon table

  • moz_favicon: This contains a list of unique favicon URIs and data. One or more pages in moz_history refer to each entry. When no pages reference a favicon, the icon entry will be deleted.

Expiration

Expiration is handled in {{template.Source("browser/components/places/src/nsNavHistoryExpire.cpp")}}. This algorithm determines the lifetime of all objects in the places system.

Periodically at runtime, the following happens to expire pages:

  • Expire visits that are older than the history expiration threshold.
  • Delete the history entries that were referenced by the expired visits and not referenced by any non-expired visit or bookmark.
  • Delete favicons for those expiring history entries that are not referenced by any other history entry.
  • Unimplemented: Delete annotations that belong to the expiring pages.

At shutdown time, an extra step is performed in case there are any orphans. There are several ways for orphans to be created, including calling markPageAsTyped and then never visiting the page. Extensions might also set favicons for pages that have never been visited.

  • Delete any history entries that have no visits, are not bookmarked, and are not place: URIs.
  • Delete any favicons that are not referenced by any history entries.

Revision Source

<p>
</p><p>This document provides a high-level overview of the overall database design of the <a href="en/Places">Places</a> system. Places is designed to be a complete replacement for the Firefox bookmarks and history systems using <a href="en/Storage">Storage</a>.
</p>
<h3 name="Core_URL_table"> Core URL table </h3>
<ul><li> <b>moz_history</b>: This is the main table of URLs and is managed by the <a href="en/Places/History_Service">history service</a> (see also <a href="en/Places/History_Service/Design">History service design</a>). This table may be renamed to something better like <code>moz_urls</code> in the future. Any time a Places component wants to reference a URL, whether visited or not, it refers to this table. Each entry has an optional reference to the <code>moz_favicon</code> table to identify the favicon of the page.
</li></ul>
<h3 name="History_tables"> History tables </h3>
<ul><li> <b>moz_historyvisit</b>: One entry in this table is created each time you visit a page. It contains the date, referrer, and other information specific to that visit. It contains a reference to the <code>moz_history</code> table which contains the URL and other global statistics. See <a href="en/Places/History_Service/Design">History service design</a> for more information.
</li></ul>
<h3 name="Bookmarks_tables"> Bookmarks tables </h3>
<dl><dd><div class="note">Warning: The bookmarks service may change significantly before Firefox 3 is released.</div>
</dd></dl>
<ul><li> <b>moz_bookmarks_folders</b>: Contains the list of bookmark folders. Each folder entry contains a numerical folder ID, a title, and some information relating to remote containers.
</li></ul>
<ul><li> <b>moz_bookmarks_roots</b>: Lists special known folders. Names such as "root", "menu", and "toolbar" are mapped to folder IDs in the <code>moz_bookmarks_folders</code> table.
</li></ul>
<ul><li> <b>moz_bookmarks</b>: This table contanins the bookmarks hierarchy. It maps a parent folder ID and an integer index to either a page ID (referencing the <code>moz_history</code> table), or a folder ID (referencing the <code>moz_bookmarks_folders</code> table). As a special case, if both the page and the folder are 0, the item is a separator.
</li></ul>
<ul><li> <b>moz_keywords</b>: This table maps a keyword name to a URL (<code>moz_history</code> ID). It is likely that this functionality will be removed from the bookmarks service.
</li></ul>
<p>See <a href="en/Places/Bookmarks_Service/Design">Bookmarks service design</a> for more information.
</p>
<h3 name="Annotation_tables"> Annotation tables </h3>
<ul><li> <b>moz_anno_name</b>: Contains the names of all the annotations in the system and a name ID. There should be relatively few unique names.
</li></ul>
<ul><li> <b>moz_anno</b>: Contains the values of the annotations. It maps a page (reference to <code>moz_history</code>) and an annotation name (reference to <code>moz_anno_name</code>) to the value of the annotation.
</li></ul>
<h3 name="Favicon_table"> Favicon table </h3>
<ul><li> <b>moz_favicon</b>: This contains a list of unique favicon URIs and data. One or more pages in <code>moz_history</code> refer to each entry. When no pages reference a favicon, the icon entry will be deleted.
</li></ul>
<h3 name="Expiration"> Expiration </h3>
<p>Expiration is handled in {{template.Source("browser/components/places/src/nsNavHistoryExpire.cpp")}}. This algorithm determines the lifetime of all objects in the places system.
</p><p>Periodically at runtime, the following happens to expire pages:
</p>
<ul><li> Expire visits that are older than the history expiration threshold.
</li><li> Delete the history entries that were referenced by the expired visits and not referenced by any non-expired visit or bookmark.
</li><li> Delete favicons for those expiring history entries that are not referenced by any other history entry.
</li><li> <i>Unimplemented:</i> Delete annotations that belong to the expiring pages.
</li></ul>
<p>At shutdown time, an extra step is performed in case there are any orphans. There are several ways for orphans to be created, including calling <code>markPageAsTyped</code> and then never visiting the page. Extensions might also set favicons for pages that have never been visited.
</p>
<ul><li> Delete any history entries that have no visits, are not bookmarked, and are not place: URIs.
</li><li> Delete any favicons that are not referenced by any history entries.
</li></ul>
Revert to this revision