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.
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.