The Places database

  • Revision slug: The_Places_database
  • Revision title: The Places database
  • Revision id: 100940
  • Created:
  • Creator: BrettWilson
  • Is current revision? No
  • Comment /* Core URL table */

Revision Content

This document provies a high-level overview of the overall database design of the Places system. Places is designed to be a complete replacement for the Firefox bookmakrs 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 Places:History Service:Design and Places:History Service). 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.

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 Places: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.
  • moz_bookmarks: This table contanins the bookmarks higherarchy. 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.

See Places:Bookmarks Service:Design for more information.

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 nonexpired visit.
  • Delete favicons for those expiring history entries that are not referenced by any other history entry.
  • Unimplemented: Delete annotatations 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 provies a high-level overview of the overall database design of the Places system. Places is designed to be a complete replacement for the Firefox bookmakrs 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 history service (see <a href="en/Places/History_Service/Design">Places:History Service:Design</a> and <a href="en/Places/History_Service">Places:History Service</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.
</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">Places: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.
</li></ul>
<ul><li> <b>moz_bookmarks</b>: This table contanins the bookmarks higherarchy. 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>
<p>See <a href="en/Places/Bookmarks_Service/Design">Places:Bookmarks Service:Design</a> for more information.
</p>
<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 nonexpired visit.
</li><li> Delete favicons for those expiring history entries that are not referenced by any other history entry.
</li><li> <i>Unimplemented:</i> Delete annotatations 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 markPageAsTyped 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