A FOREIGN KEY constraint can
contain null values; however, if any column of a composite FOREIGN KEY constraint contains null values, verification of all values that make up the FOREIGN KEY constraint is skipped. To make sure that all values of a composite FOREIGN KEY constraint are verified, specify NOT NULL on all the participating columns.
If there is NULL value in Foreign key column means that we haven't decided the value for that column...
For example:
DEPARTMENT Table: DeptID (PK), DeptName
EMP Table: EMPID, DEPTID (FK)
You can have all departments details with DEPARTMENT table..
In EMP table, you should assign the deptid for each employee... Here you can insert NULL for DeptId of a employee if NOT YET assigned a department for the employee who joined the company...
If you doesn't want to insert NULL value in the case of "NOT Assigned Department" then you can have one departmentId ( Eg: -1, 0) for
Others department in the master table( DEPARTMENT Table)...
Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif
Pkanwar, if this helps please login to Mark As Answer. | Alert Moderator