retagged by
455 views
0 votes
0 votes
what is the advantage of keeping the Foreign Key null as we know if we make the Foreign Key null we cant reference it again so thats a disadvantage ......so there must be some advantage which outweighs this disadvantage so whats that advantage
retagged by

1 Answer

2 votes
2 votes
suppose two table EMPLOYEE(eid,ename) and DEPARTMENT(Did,Dname) and now we make eid as a foreign key , now if we delete any Eid from EMPLOYEE and that Eid was refrenced by foriegn key of DEPARTMENT table then to maintain refrential integrity we hav to also delete that coressponding refrenced key from DEPARTMENT.

but if we donot want to loss data of DEPARTMENT table so instead of deleting that refrenced key of foriegn key we put null values , by this we do not loss the data of DEPARTMENT table

Related questions

3 votes
3 votes
2 answers
1
Hira Thakur asked Nov 3, 2016
1,503 views
What is on delete no action,on delete cascade, on delete set null action??explain through some eg??
1 votes
1 votes
1 answer
2
rishu_darkshadow asked Sep 28, 2017
5,271 views
Explain recursive foreign key with suitable example..