简体   繁体   中英

MySQL relation without using foreign key references

I have question about making relation between two tables in mysql. I create table with column which is foreign key, but I dont use foreign key references keyword. I connect tables in code(php/asp.net). I dont know if it is good habit? Thanks for your help.

It's generally seen as a good habit to create a foreign key constraint as it will enforce data integrity between the two columns.

Yes, you can have 100% valid data in your database without using any foreign key constraints at all, but implementing them will make it impossible for a flawed update, delete, or insert to violate the foreign constraint between them in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM