开发者

Terms for related DB records

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?


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.


I would say "the corresponding record".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜