Advice how to manage constraints.

I want to use this as an example of how to manage the constraint objects in general. Rather than the specifics of this db.

The db stores system file paths. Parts of the path (not necessarily directories, sometimes more than one directories together when they have logical meaning) are in separate fields. I do not want to support spaces, even though the os does.

So should I do one combined check constraint 

-- actually many more columns.
check((Column1 NOT LIKE '% %' ) OR (Column2 NOT LIKE '% %' ))

or should we break into several separate constraints for each individual column

The condition is not related, that may somehow require to keep it in one statement. It just so happens that it is the same/or similar on more than one column.

On the other extreme, since the engine keeps them all together, I could bunch all of them into one huge statement, less readable, but all in one place.

I understand that check constraints are table constraints, so this is more of a best practice for management of objects question rather than t-sql syntax.

thnx



Answer this question

Advice how to manage constraints.

  • Advice how to manage constraints.