0

This question was asked in my viva.


Each Foreign key must exist as a primary key.
Foreign keys values can change over time..


According to me the second statement is false.But he said that they can change values...Is it so???

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by amrita111
0

Not really, if the foreign key value changes, it loses the relational link to the primary key. So you then lose the integrity of the information as the row values will link to another primary key value of different data, or nothing if it doesn't exist causing an error.

You can physically change the foreign key value to match to another primary key value, when modifying a mistake made, e.g. the foreign key's record meaning to match a different primary key's record.

E.g. Employees and Employee Scores.
Employee101 scored at 55%
Employee102 scored at 60%

Say that these have (somehow!) mixed around in the database, so you have to change the foreign key EmployeeID of Employee102 (in the Scored table), to the EmployeeID of Employee101 so that Employeee101 scored 60% (and vice versa otherwise Employee101 scores both 55% and 60%).

This type of mistake wouldn't really happen unless you coded the front end to mess with the values input into the system.

Edited by StephNicolaou: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.