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