{"id":515,"date":"2024-10-08T20:30:10","date_gmt":"2024-10-08T13:30:10","guid":{"rendered":"https:\/\/nbvps.anhtuanlqd.com\/?p=515"},"modified":"2025-01-09T10:02:46","modified_gmt":"2025-01-09T03:02:46","slug":"modify-the-foreign-key-constraint-in-database","status":"publish","type":"post","link":"https:\/\/nbvps.anhtuanlqd.com\/?p=515","title":{"rendered":"Modify the foreign key constraint in database"},"content":{"rendered":"\n<p><strong>Cascade Deletion<\/strong>: You can set up the foreign key constraint to allow cascading deletes. This means that when a user is deleted from the\u00a0<code>users<\/code>\u00a0table, all related rows in the\u00a0<code>grades<\/code>\u00a0table will also be deleted automatically.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER TABLE grades\nDROP FOREIGN KEY grades_ibfk_1;\n\nALTER TABLE grades\nADD CONSTRAINT grades_ibfk_1\nFOREIGN KEY (user_id) REFERENCES users(id)\nON DELETE CASCADE;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Cascade Deletion: You can set up the foreign key constraint to allow cascading deletes. This means that when a user is deleted from the\u00a0users\u00a0table, all related rows in the\u00a0grades\u00a0table will also be deleted automatically.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","footnotes":""},"categories":[50,2,23],"tags":[45,177,178],"class_list":["post-515","post","type-post","status-publish","format-standard","hentry","category-command","category-linux","category-tips-and-trick","tag-database","tag-foreign-key","tag-foreign-key-constraint"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=515"}],"version-history":[{"count":1,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/515\/revisions"}],"predecessor-version":[{"id":516,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=\/wp\/v2\/posts\/515\/revisions\/516"}],"wp:attachment":[{"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nbvps.anhtuanlqd.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}