Foreign key constraints: When to use ON UPDATE and ON DELETE

后端 未结 3 1929
故里飘歌
故里飘歌 2020-12-04 04:22

I\'m designing my database schema using MySQL Workbench, which is pretty cool because you can do diagrams and it converts them :P

Anyways, I\'ve decided to use InnoD

3条回答
  •  离开以前
    2020-12-04 05:06

    Addition to @MarkR answer - one thing to note would be that many PHP frameworks with ORMs would not recognize or use advanced DB setup (foreign keys, cascading delete, unique constraints), and this may result in unexpected behaviour.

    For example if you delete a record using ORM, and your DELETE CASCADE will delete records in related tables, ORM's attempt to delete these related records (often automatic) will result in error.

提交回复
热议问题