0

I am building a system where there are properties and prospects, I have a table for both, but as I see this as a many to many relationship, I have created a table called prospect_property with two columns prospect_id and property_id, these are both/composite primary key(s).

What I am having problems with is setting the foreign keys and binding it all together. I figure the composite key should be the foreign key on the other two tables (or is it the other way around), but when trying to create that relationship in Management Studio, I have to reference one to one field, but I have one vs. two...

How am I supposed to set the relationship between these tables so that I for a prospect can see all properties and for a property can see all prospects?

SQL SERVER 2012 (Express)

4

1 回答 1

3

1 Property --> 几个prospect_property(两边ProspectId上的链接)
1 Prospect --> 几个prospect_property(两边ProspectId上的链接)

属性:ProspectId 是 PK
Prospect:ProspectId 是 PK前景 _property
:由 PropertyId 和 ProspectId 组成的复合 PK

仅此而已。其余的将通过构建一些将所有这些链接在一起的视图来完成。

于 2012-11-20T09:27:14.647 回答