I have just started internship at a small software house and I am working on an ERP. My team lead has forbidden me to create any relationships in the database. As this is my internship I was shocked because till now I have read that relationships are necessary for ensuring data integrity. My team lead told me that we can enforce the data integrity at the front end. After some research I found out that foreign keys do make the db slower but Indexing foreign keys can increase performance.
Questions
- How making foreign keys cost performance?
- Does ensuring data integrity at the front end not cost performance ? If yes then what will be difference between the performance cost by database foreign keys and cost by ensuring data integrity rules at the front end?
- If database foreign keys do make the database slower, and integrity rules at the application layer is a better approach then why do our relational databases allowed to have foreign keys at all?
- After doing some research and reading that relationships do make db slower I tried to think of a scenario where ensuring data integrity at application layer is not possible but I could not think of one, If someone can explain this, it would be great.
If indexing foreign keys increase performance then what would be better out of the two below:
1.) Ensuring data integrity rules at application layer
2.) Indexing Foreign Keys
Thanks for help.