When your creating a database schema and come up with all the foreign keys. What are the advantages of explicitly defining them as such in the database?
Are there advantages?
If it’s reliant MySQL is the db I will be using.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Foreign key constraints are used for maintaining Referential Integrity which is a database constraint that ensures that references between data are indeed valid and intact (a database should not only store data but should also ensure its quality). In other words, they help to ensure that relationships between tables remain consistent. From Wikipedia:
In order to create a foreign key between two tables with MySQL, both tables need to be InnoDB tables (with the default MyISAM table type, you can “define” a foreign key but they do not actually do anything).