QUESTION POSED ON: 11 July 2007 Which is the better option between the following: leaving the data integrity to the DB by creating foreign keys or managing them through the application logic?
I have seen few applications where managing the data integrity through application logic is preferred to the foreign key.
I would like to understand if this should be the case even in Oracle 10g. Thanks.
>
EXPERT RESPONSE
Always, always, always let the database enforce your data integrity. If data integrity is coded in the application, it is very easy for the app to enforce the data integrity in some places but not in others. If the data integrity is coded in the application, how do you guarantee data integrity if you use a different application? If you code the integrity constraints in the database, then these problems do not arise. I have never, in all my years in this businees, seen a case where it is preferrable to move the data integrity rules into the application. And in my opinion, those who do prefer the app over the database for enforcing data integrity do not understand how the database works and why this approach is better.
Search and Browse the Expert Answer Center Search and browse more than 25,000 question and
answer pairs from more than 250 TechTarget industry experts.
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.