The relationship between the two tables is pretty obvious. The two tables join on the PersonID. If we introduce a further relationship to the above so that we now have :
DivorceID, PersonID, DateOfDivorce
Again, we can see that the Divorce table links to the Person table and the Earmarked table joins with the Divorce table. I hope you are all happy with this extremely simplified version of a relational database.
I am currently writing an SP that would take a person NationalIDNumber and return to me the tables where there is data that belongs to this member.
So something like,
DECLARE @PersonID INTEGER
SET @PersonID = (Select PersonID from Person where NationalIDNumber = ‘XXXYYY123’)
Once we have our PersonID, we can then search our Employee table for the PersonID and we can do the same for Divorce. The problem is, the Earmarked table does not directly links to the Person table so how do you do it?
I thought of implementing a Binary tree structure, but I am not sure how to approach the whole concept. Any suggestion son how to tackle this kind of problems?