英文:
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 manyArticles
- one or many
Articles
are produces by oneAuthor
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论