I can not understand the difference.
views:
43answers:
3What's the difference ElggMetadata and ElggAnnotation in Elgg framework from a developer viewpoint?
ElggMetadata is used to store information about the actual Elgg entity. So if you created a Car entity and wanted to say what colour it was, that would be a perfect use case for ElggMetadata.
ElggAnnotion is used to add additional information (comment, review, etc.) to an entity. So in the above example of a Car Entity, you could allow users to comment or review it. This is a perfect case for ElggAnnotation.
David's answer is right on. Check these links out if you need more depth.
From a database perspective, they are exactly the same. They have all the same fields (id, user_guid, entity_guid, etc.), so it would make sense why it's not immediately clear what they're for.
I like to think of it this way:
- metadata == objective (property)
- annotations == subjective (opinion)
Metadata are a way to dynamically add properties to an entity. Metadata should describe the entity as it actually is -- David's example about the color of a car was good. Other examples are the isbn number of a book, or the location of an event.
Any new information added to the entity after it's been created should probably be an annotation. This is why ratings, likes, etc. are annotations and not metadata -- a "rating" is not a property of the entity, it's just someone's opinion about the quality of the entity.
The API bears this distinction out. Metadata are assigned as if they were properties of the entity. e.g.:
$event->location = '';
There is no equivalent shorthand for annotations.