tuchawat tuchawat - 10 days ago 5
MySQL Question

MySQL - I have foreign key, but I don't set it as a foreign key in phpmyadmin?

I have foreign key, but I don't set it as a foreign key in phpmyadmin. it just a INTEGER type column.
Question : What is the difference result between setting or not setting it as foreign key in phpmyadmin?

Answer

The FOREIGN KEY constraint enables some automatic checks by the database engine.

If you don't specify it as a foreign key, you won't get an error if you try to insert a value that doesn't exist in the other table. And you can't make use of options like ON DELETE CASCADE, which automatically deletes the row in the child table if the parent row is deleted.

Comments