Table 3: DealTypes (PK DealTypeId)
DealTypeId int
DealFamilyId int
I want to create a relationship between Table1 and Table2.
Table2 must be constrained using a FK on DealId plus Table2:DealFamilyId must = DealFamilyId belonging to the Table1:DealTypeId derived from the lookup Table3.
In the example above, inserts should only be allowed into Table2 where Table1:DealTypeId has a Table3:DealFamilyId = 1.
sephiroth100
Participant
1118 Points
1001 Posts
How to correctly constrain these tables
May 29, 2012 01:11 PM|LINK
Hi,
Need some help on how to acheive this.
Table 1: Deals (PK DealId)
DealId int
DealTypeId int
Table 2: DealEvents (PK DealId)
DealId int
DealFamilyId (computed persisted '1')
Table 3: DealTypes (PK DealTypeId)
DealTypeId int
DealFamilyId int
I want to create a relationship between Table1 and Table2.
Table2 must be constrained using a FK on DealId plus Table2:DealFamilyId must = DealFamilyId belonging to the Table1:DealTypeId derived from the lookup Table3.
In the example above, inserts should only be allowed into Table2 where Table1:DealTypeId has a Table3:DealFamilyId = 1.
Hope this makes sense.
Thanks
Chen Yu - MS...
All-Star
21569 Points
2493 Posts
Microsoft
Re: How to correctly constrain these tables
Jun 01, 2012 03:09 AM|LINK
Hi sephiroth100,
It seems that your tables have below relationship.
Table 1: Deals (PK DealId)
DealId int (FK to Table 2 DealId)
DealTypeId int
Table 2: DealEvents (PK DealId)
DealId int
DealFamilyId (computed persisted '1')
Table 3: DealTypes (PK DealTypeId)
DealTypeId int
DealFamilyId int
Would you please give us some sample data about your tables? It will provide us more information about your tables.
Thanks.
Feedback to us
Develop and promote your apps in Windows Store