November 9, 2009

How to enforce a foreign key constraint against multiple tables

@JohnMacIntyre and I recently started working on a project together and we're currently running through the database design. One of the issues we've come across is how to use foreign key constraints that aren't tied to a specific table - i.e. the foreign key could be valid providing that it exists in one of a number of tables. After discounting a few approaches that weren't going to work for us, we were left with dreaded triggers. John's post on his approach to the design can be found on his blog at WhileICompile along with a bunch of pretty pictures to make it easy to read and understand.

No comments:

Post a Comment