相关数据库记录的术语

发布于 2024-10-18 07:27:33 字数 409 浏览 4 评论 0原文

这是一个数据库模式:

users(id, name);
items(id, user, name), user 是外键
Tags(item, name), item 是一个外键

基于该模式:

  • 关系)
  • 每个 item 都有一个用户(一对一 item 可能有多个标签(一对多关系)

假设您是items 中的一条记录。

根据您的关系,您会使用什么术语来指代用户的记录?你会称其为“一对一的亲戚”还是其他什么?

同样,您会使用什么术语来指代一堆标签?你会称他们为“一对多亲戚”还是其他什么?

Here's a DB schema:

users(id, name);
items(id, user, name), user is a foreign key
tags(item, name), item is a foreign key

Based on that schema:

  • each item has one user (one to one relationship)
  • each item may have multiple tags (one to many relationship)

Pretend you are a record from items.

What term would you use to refer to a record from users, based on your relationship? Would you call it a "one to one relative" or something else?

Similarly, what term would you use to refer to a bunch of tags? Would you call them "one to many relatives" or something else?

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

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

发布评论

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

评论(2

岁月染过的梦 2024-10-25 07:27:33

如果类特定于项目,您可以将项目的用户称为“所有者”,而标签简称为“标签”。

如果该类是通用记录处理程序(例如 活动记录数据映射器),适用的英文单词并不多。 “相对”和“相对”是两个,尽管它们可能不会给方法名称添加太多含义。项目和用户之间存在函数关系,其中项目是参数/输入,用户是值/输出,但这些术语的描述很差。我怀疑大多数通用术语都会遇到描述能力低的同样问题。

受术语codomain(函数的)的启发,您可以尝试使用前缀“co- ”。

在面向对象的世界中,项目和标签之间的关系是一个聚合,这表明您可以将标签称为方法名称中的“聚合”。

If the class is specific to items, you could call the user for an item an "owner", and the tags simply the "tags".

If the class is a generic record handler (e.g. an active record or data mapper), there aren't many English words that would apply. "Relative" and "relatives" are two, though they may not add much meaning to method names. There's a functional relationship between items and users, where the item is the argument/input and the user is the value/output, but these terms are poor descriptions. I suspect most any generic terms will suffer the same problem of having low descriptive power.

Taking inspiration from the term codomain (of a function), you could try using the prefix "co-".

In the OO world, the relationship between items and tags is an aggregation, which suggests that you could refer to the tags as an "aggregate" in method names.

天暗了我发光 2024-10-25 07:27:33

我会说“相应的记录”。

I would say "the corresponding record".

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