数据库关系写作规则

huangapple go评论66阅读模式
英文:

Rules for writing database relationship

问题

我有两个表,第一个表是文章表,第二个表是作者表。一个作者可以写多篇文章,我想要编写关系注释 @ManyToOne,哪个是正确的,是 @ManyToOne Article-Author 还是 @ManyToOne Author-Article

英文:

I have two table, the first table is article table, and the second is author table. One author can write many articles,
I want to write the relation annotation @ManyToOne, which one correct @ManyTone Article-Author or @ManyToOne Author-Article ?

答案1

得分: 1

你只需简单地表达你拥有以下的关系:

  • 一个 Author 拥有多个 Articles
  • 一个或多个 Articles 被一个 Author 拥有

在你的实体中,你将拥有以下的注解:

  • 对于 Author 使用 @OneToMany
  • 对于 Article 使用 @ManyToOne
英文:

To simply say you have the following relationship :

  • an Author produces many Articles
  • one or many Articles are produces by one Author

In your entities you will have the following annotations :

  • for Author @OneToMany
  • for Article @ManyToOne

答案2

得分: 0

你说:

> 一个作者可以写多篇文章

这将翻译为ManyToOne 文章-作者,换句话说:多篇文章对应一个作者。

英文:

You said:

> One author can write many articles

This would translate as ManyToOne Article-Author, in other words: many articles to one author.

huangapple
  • 本文由 发表于 2020年10月10日 09:58:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/64289244.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定