DatabaseSchema

The database contains a number of primary tables and secondary service modules, its schema table is stored in /engine/schema/mysql.sql.

Each table is prefixed by "prefix_", this is replaced by the Elgg framework during installation.

Contents

Main tables

This is a description of the main tables.

prefix_entities

This is the main Elgg entity table containing Elgg users, sites, objects and groups. When you first install Elgg this is automatically populated with your first site.

It contains the following fields:

  • guid An auto-incrementing counter producing a GUID that uniquely identifies this entity in the system.
  • type The type of entity - object, user, group or site
  • subtype A link to the subtype table.
  • owner_guid The GUID of the owner's entity.
  • site_guid The site the entity belongs to.
  • container_guid The GUID this entity is contained by - either a user or a group.
  • access_id Access controls on this entity.
  • time_created Unix timestamp of when the entity is created.
  • time_updated Unix timestamp of when the entity was updated.
  • enabled If this is 'yes' an entity is accessible, if 'no' the entity has been deleted.

prefix_entity_subtypes

This table contains entity subtype information:

  • id A counter.
  • type The type of entity - object, user, group or site.
  • subtype The subtype name as a string.
  • class Optional class name if this subtype is linked with a class

prefix_metadata

This table contains extra information attached to an entity.

  • id A counter.
  • entity_guid The entity this is attached to.
  • name_id A link to the metastrings table defining the name table.
  • value_id A link to the metastrings table defining the value.
  • value_type The value class, either text or an integer.
  • owner_guid The owner GUID of the owner who set this item of metadata.
  • access_id An Access controls on this item of metadata.
  • time_created Unix timestamp of when the metadata is created.
  • enabled If this is 'yes' an item is accessible, if 'no' the item has been deleted.

prefix_annotations

This table contains annotations, this is distinct from metadata.

  • id A counter.
  • entity_guid The entity this is attached to.
  • name_id A link to the metastrings table defining the type of annotation.
  • value_id A link to the metastrings table defining the value.
  • value_type The value class, either text or an integer.
  • owner_guid The owner GUID of the owner who set this item of metadata.
  • access_id An Access controls on this item of metadata.
  • time_created Unix timestamp of when the metadata is created.
  • enabled If this is 'yes' an item is accessible, if 'no' the item has been deleted.

prefix_relationships

This table defines relationships, these link one relationship with another.

prefix_objects_entity

Extra information specifically relating to objects. These are split in order to reduce load on the metadata table and make an obvious difference between attributes and metadata.

prefix_sites_entity

Extra information specifically relating to sites. These are split in order to reduce load on the metadata table and make an obvious difference between attributes and metadata.

prefix_users_entity

Extra information specifically relating to users. These are split in order to reduce load on the metadata table and make an obvious difference between attributes and metadata.

prefix_groups_entity

Extra information specifically relating to groups. These are split in order to reduce load on the metadata table and make an obvious difference between attributes and metadata.

prefix_metastrings

Metastrings contain the actual string of metadata which is linked to by the metadata and annotations tables.

This is to avoid duplicating strings, saving space and making database lookups more efficient.

Upgrades

Database upgrades are performed by the Elgg framework when running upgrade.php.

Core developers will place schema upgrades in /engine/schema/upgrades/* named after the version.

As a plugin developer, it is unlikely you will need to deploy these upgrades.

Search docs