Send private message

You must be logged in to send a private message.

Friends

No friends yet.

Group membership

Activity

  • Luca added a new discussion topic Data Model in the group Beginning Developers
    Hi guys! I'm new and I've some doubts about how to extend the ElggEntity class. I mean: should I simply use metadatas to store attributes into the DB or should I create ad hoc DB tables? aren't metadata  "dangerous" from a performance point of...
    • Hi Luca, welcome to Elgg!

      You should be storing attributes as metadata and not be adding ad hoc tables to the database, the Elgg data model is such that just about anything can be stored as metadata, annotations, plugin settings, or relationships depending on what you need it for.

      Of course there will always be a correlation between the amount of metadata and performance, but it's not as bad as you might think.  The metadata for an entity isn't retrieved simply by loading the entity, it's retrieved the first time it's used, and stored in memory for the rest of the operation.  So if you have an entity with 100 pieces of metadata, and you load the entity and display one piece of metadata, the remaining 99 pieces of metadata are not retrieved.

      Additionally, using your own tables to store data essentially takes that data outside of the Elgg framework - thereby making it unavailable for other plugins/extensions.  You lose out on the all of the hooks, events, and permissions associated with metadata that are integral to the flexibility of Elgg.

    • Also, when you decide to optimize, it's possible to flatten DB without modifying the core. For our projects we have a hook-based plugin which handles this quite well for all types of entities. In case you eg. search by 10 or more metadata, you can "cache" them and retrieve with just one join (this one join can be removed as well, although it's a little bit more complicated).

      My experience is that Elgg DB is not very well optimized. It can be optimized relatively easily when you start to have need for optimization though.

  • Luca joined the group Beginning Developers
  • Luca joined the group Plugin Development
  • Luca joined the group Italian Community Group