I am trying to understand how foreign keys would work from an internal processing perspective (i'm using SQLServer). In other words, how would a table be impacted from the addition of a Foreign Key?
Say i have two tables(PK are Non Nulls):
TableA: PK Student_ID, StudentName, StudentAddress
TableB: PK Books_ID, FK Student_ID, Books_IssueMonth
select Student_ID from TableB where Books_IssueMonth=January;
When i run a sql statement in TableB
calling on Student_ID
, is the system told to first look it up in TableA
and then pointed towards the clustered index (Books_ID
) in TableB
?
Would it be two-table seeks?
or would it be a seek in TableA and scan in TableB?