Engine/DataModel
From Elgg Documentation
In Elgg, everything runs on a unified data model, based on atomic units of data called entities. Plugins are strongly discouraged from dealing with database issues themselves, which makes for a more stable system that also has visible benefits for the end user. Content created by different plugins can be mixed together in consistent ways, which are programmed using generic principles - in other words, plugins are faster to develop, and are at the same time much more powerful.
Every entity in the system inherits the ElggEntity class. This controls access permissions, ownership and so on; Elgg allows you to run multiple sites on the same install, so it also stores the site each element belongs to.Users, sites, objects and groups
ElggEntity has four main specializations, which provide extra properties and methods to more easily handle different kinds of data.
- ElggObject - objects like blog posts, uploaded files and bookmarks
- ElggUser - each user in the system
- ElggSite - each site within an Elgg install
- ElggGroup - multi-user collaborative systems, which were called Communities in prior versions of Elgg
The benefit of such an approach is that, apart from modelling data with greater ease, a common set of functions is available to handle objects, regardless of their (sub)type.
Each of these have their own properties that they bring to the table: ElggObjects have a title and description, ElggUsers have a username and password, and so on. However, because they all inherit ElggEntity, they each have a number of core properties and behaviours in common.
- A numeric Globally Unique IDentifier (GUID). Each ElggEntity has a unique GUID; if an ElggSite has a GUID of 7, you can be assured that no other ElggSite, ElggObject, ElggUser or ElggGroup has a GUID of 7.
- Access permissions. (When a plugin requests data, it never gets to touch data that the currently logged-in user doesn't have permission to see.)
- An arbitrary subtype. For example, a blog post is an ElggObject with a subtype of "blog". Subtypes aren't predefined; they can be any unique way to describe a particular kind of entity. "blog", "forum", "foo", "bar", "loafofbread" and "pyjamas" are all valid subtypes.
- An owner.
- The site that the entity belongs to.
Annotations and metadata
You can extend entities with extra information in two ways:
- Metadata This is information you can add to an object to describe it further. For example, tags, an ISBN number, a file location or language information would fall under metadata.
- Annotations Information generally added by third parties which adds to the information provided by the entity. For example, comments and ratings are both annotations.
