Foreign keys and updates
There are other ways of ensuring referential integrity.
SET NULL
delete from P where p_id = 3;
P
p_id |
x |
1 | 123 |
2 | 456 |
3 | 789 |
4 | 111 |
|
|
F
f_id |
p_id |
y |
1001 | 1 | 999 |
1002 | 1 | 888 |
2001 | 2 | 777 |
3001 | 3 | 666 |
3002 | 3 | 555 |
3003 | 3 | 444 |
|
|
→ |
P
|
|
F
f_id |
p_id |
y |
1001 | 1 | 999 |
1002 | 1 | 888 |
2001 | 2 | 777 |
3001 | NULL | 666 |
3002 | NULL | 555 |
3003 | NULL | 444 |
|
|
|