如何在数据库表中买方和赞助商之间的关系? [英] How to relationship between Buyer and sponsor in database tables?
本文介绍了如何在数据库表中买方和赞助商之间的关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。
在我们的数据库中,我们有两个存在(表):
1-买家
2-赞助商
每个买家有一个或两个赞助商,每个赞助商可以赞助许多买家。
我们如何设计表格及其之间的关系???
非常感谢。
Hi all.
In the our database , we have two Existence(table) :
1- Buyer
2- sponsor
each Buyer have one or two sponsor and each sponsor can be sponsor many buyer.
How do we design tables and relation between on it ???
thanks a lot.
推荐答案
有买家表
[PK] Buyer_ID
Rest_Of_Buyer_Fields
a赞助商表
[PK] Sponsor_ID
Rest_Of_Sponsor_Fields
和一张加入两个名为Buyer_Sponsor的桌子
[PK] Buyer_ID
[PK] Sponsor_ID
这允许您在买家和赞助商之间建立多对多的关系。如果buyer_sponser表数据看起来像
Buyer_ID,Sponsor_ID
1,1
1,2
3,2
4,9
然后买方1有赞助商1和2.赞助商2有买家1 3.买方4只有赞助商9,赞助商9只有买方4。
Have a Buyer table
[PK] Buyer_ID
Rest_Of_Buyer_Fields
a sponsor table
[PK] Sponsor_ID
Rest_Of_Sponsor_Fields
and a table that joins the two called Buyer_Sponsor
[PK] Buyer_ID
[PK] Sponsor_ID
This allows you to set up a many-to-many relationship between buyers and sponsors. If the buyer_sponser table data looks like
Buyer_ID, Sponsor_ID
1, 1
1, 2
3, 2
4, 9
then buyer 1 has sponsors 1 and 2. Sponsor 2 has buyers 1 and 3. Buyer 4 only has sponsor 9 and sponsor 9 only has buyer 4.
这篇关于如何在数据库表中买方和赞助商之间的关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文