从开发人员的角度来看,Elgg 框架中的 ElggMetadata 和 ElggAnnotation 有什么区别?
我无法理解其中的区别。
I can not understand the difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我无法理解其中的区别。
I can not understand the difference.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
从数据库的角度来看,它们是完全相同的。它们具有相同的字段(id、user_guid、entity_guid 等),因此为什么不能立即清楚它们的用途是有道理的。
我喜欢这样思考:
元数据是一种动态向实体添加属性的方法。元数据应该描述实体的实际情况——大卫关于汽车颜色的例子很好。其他示例包括书籍的 isbn 编号或活动的地点。
创建实体后添加到实体的任何新信息可能都应该是注释。这就是为什么评级、喜欢等是注释而不是元数据——“评级”不是实体的属性,它只是某人对实体质量的看法。
API 证实了这一区别。元数据的分配就像实体的属性一样。例如:
注释没有等效的简写。
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 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.:
There is no equivalent shorthand for annotations.
ElggMetadata 用于存储有关实际 Elgg 实体的信息。因此,如果您创建了一个 Car 实体并想要说明它的颜色,那么这将是 ElggMetadata 的完美用例。
ElggAnnotion 用于向实体添加附加信息(评论、评论等)。因此,在上面的汽车实体示例中,您可以允许用户对其进行评论或评论。这是 ElggAnnotation 的完美案例。
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.
ElggMetadata 是存储键值对之间的 LINK 的位置,与任何实体关联。但实际的键和值将存储在 ElggMetastrings 中(遵循 EAV 模型)。
例如:
相对而言,ElggAnnotation 存储了一组相当严格的属性,例如评论、任何实体的评级
ElggMetadata is where the LINK between key-value pairs are stored, associated with any entity. But the actual key and values will be stored in ElggMetastrings( following EAV model).
For example:
Comparatively ElggAnnotation stores quite a rigid set of properties like comments, ratings of any entity