从开发人员的角度来看,Elgg 框架中的 ElggMetadata 和 ElggAnnotation 有什么区别?

发布于 2024-08-27 17:03:20 字数 18 浏览 6 评论 0原文

我无法理解其中的区别。

I can not understand the difference.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

此生挚爱伱 2024-09-03 17:03:20

从数据库的角度来看,它们是完全相同的。它们具有相同的字段(id、user_guid、entity_guid 等),因此为什么不能立即清楚它们的用途是有道理的。

我喜欢这样思考:

  • 元数据==客观(属性)
  • 注释==主观(意见)

元数据是一种动态向实体添加属性的方法。元数据应该描述实体的实际情况——大卫关于汽车颜色的例子很好。其他示例包括书籍的 isbn 编号或活动的地点。

创建实体后添加到实体的任何新信息可能都应该是注释。这就是为什么评级、喜欢等是注释而不是元数据——“评级”不是实体的属性,它只是某人对实体质量的看法。

API 证实了这一区别。元数据的分配就像实体的属性一样。例如:

$event->location = '';

注释没有等效的简写。

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.

诗笺 2024-09-03 17:03:20

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.

靑春怀旧 2024-09-03 17:03:20

ElggMetadata 是存储键值对之间的 LINK 的位置,与任何实体关联。但实际的键和值将存储在 ElggMetastrings 中(遵循 EAV 模型)。

例如:

$user->gender=male; 

相对而言,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:

$user->gender=male; 

Comparatively ElggAnnotation stores quite a rigid set of properties like comments, ratings of any entity

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文