Composite Foreign key with a calculated column
I have 2 tables - 1 is a superset of the other. The child has a calculated column on the second half of the composite shared key.
- dbo.Entity is the parent table with a Primary Key on (EntityId, EntityTypeId). EntityTypeId is an FK to ref.EntityType
- entity.Person represents the subset, has a Primary Key on EntityId, a persisted calculated column EntityTypeId = 10 (Corresponds to ref.EntityType record for 'Person'), and a Foreign Key Constraint (EntityId, EntityTypeId) to dbo.Entity.
0 · Share on Twitter