Constraint On Other Data?

  • I have two related tables.  Table one is basically a lookup and is the one side of a one to many relationship with table two.  The problem is that table two really only applies to a subset of the records in table one and I want to set up the data integrity to prevent rows from being inserted in table two for the rows that don't apply in table one.  I tried to set up a check constraint with a subquery but that doesn't seem to be allowed.  Any other ideas on how to do this?

  • hmmmmmm.

    Restated, ALL rows in table two are related to ONE of a subset of the rows in table one.  Is there a column on table one that identifies whether or not it belongs to the subset of valid rows?

    Wayne

     

  • Yes there is, but I figured out how to use a trigger to enforce the constraint.  In fact there was a perfect example of what I needed in the BOL in the section about triggers.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply