Pros and cons of programmatically enforcing foreign key than in database

Posted by Jeffrey on Stack Overflow See other posts from Stack Overflow or by Jeffrey
Published on 2010-04-01T00:56:06Z Indexed on 2010/04/01 1:03 UTC
Read the original article Hit count: 361

It is causing so much trouble in terms of development just by letting database enforcing foreign key. Especially during unit test I can’t drop table due to foreign key constrains, I need to create table in such an order that foreign key constrain warning won’t get triggered. In reality I don’t see too much point of letting database enforcing the foreign key constrains. If the application has been properly designed there should not be any manual database manipulation other than select queries. I just want to make sure that I am not digging myself into a hole by not having foreign key constrains in database and leaving it solely to the application’s responsibility. Am I missing anything?

P.S. my real unit tests (not those that use mocking) will drop existing tables if the structure of underlying domain object has been modified.

© Stack Overflow or respective owner

Related posts about database

Related posts about foreign-keys