先 is one of those kanji which modifies kanji preceding it or following it.
For your first question, it refers to the same table from what I understand. [Is is from a technical spec?]
My understanding - In the separated table above [PK], add FK to it.
[元の表で quite literally refers to "table of origin"]
For your second question, 宛先 refers to "address" or "destination":
この宛先におくってもらえませんか。 Could you send it to this address?
[Kono atesaki ni okutte moraemasen ka?]
So in this instance, 先 is referring to "ahead" - you send things forward/ahead/to somewhere.
ログ先書きプロトコル is quite literally "Logging protocol". Here 先 obviously refers to something that happened previously - you log things which have happened.
[先書 means "log writing" in loose terms.]
This is what I meant by 先 having its meaning modified depending on the preceding of following kanji. It can mean "ahead/forward" in some circumstances, and "previous" in others as you correctly noted.
Other examples; an example of precedence in mazu, and looking ahead in sakiwamari:
先ず - mazu - First of all,...
先回り - sakimawari - going on ahead / anticipating [something]
Hope it helps.