0
  1. How can I delete data form a table with out delete other table data?

  2. Is that possible Null value for foreign key in MySql data base table?

I want to delete one Department without delete other tables data like (shifts, remote_login_id, skills). This my data base ERD. How will I do this?

enter image description here

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user881703
  • 1,111
  • 3
  • 19
  • 38
  • Why a null value for foreign key? Instead remove the dependencies from the table using the foreign key and use it like a unique key or something. I am not getting y null values and how do you expect that. – Milee Apr 19 '12 at 06:45

1 Answers1

0

When you define the foreign key you can choose between SET NULL and CASCADE.

CASCADE deletes all records that holds reference to the deleted row.

SET NULL set's the foreign key column to null wherever it referenced the deleted record. For this to work you need to make sure that that column allows null or it won't work.

http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html

Andreas Wederbrand
  • 38,065
  • 11
  • 68
  • 78