Search code examples
databasemathsetrelational-databaseinjective-function

PK candidate must be an Injective, Surjective or Bijective function?


I have a doubt regarding information strength of a candidate to be a PK.

From my understanding, and this is what I want to share in order to check if it is correct, a PK candidate must be strong enough to uniquely identify a set of information, correct?

I started to looking to this matter with a math approach.

If I define the codomain as the set generated by my SEQUENCE and my domain as a set of data to be identifiable by the PK is correct to state that my PK candidate must be at least Injective Function.

Why at least Injective? Because I can "burn" some elements of my sequence that is my Codomain, so I can not make sure I have Injection and Surjection.

Are my assumptions and understanding corret?


Solution

  • You're definitely on the right track thinking about this using set theory.

    You can define your codomain as the set generated by your SEQUENCE including "burned" values, but you should define your key as the range, containing only those values that are actually selected and map to tuples. Thus, any key is bijective with the set of tuples.