What's the point of a candidate key?

前端 未结 9 622
借酒劲吻你
借酒劲吻你 2020-12-09 18:00

I\'m fairly new to database management and this question never seems to be answered in more than one sentence. All other SO answers say \"A candidate key is a minimal super

9条回答
  •  北海茫月
    2020-12-09 18:29

    In nutshell: CANDIDATE KEY is a minimal SUPER KEY.

    Where Super key is the combination of columns(or attributes) that uniquely identify any record(or tuple) in a relation(table) in RDBMS.


    For instance, consider the following dependencies in a table having columns A, B, C and D (Giving this table just for a quick example so not covering all dependencies that R could have).

    Attribute set (Determinant)---Can Identify--->(Dependent)

    A-----> AD

    B-----> ABCD

    C-----> CD

    AC----->ACD

    AB----->ABCD

    ABC----->ABCD

    BCD----->ABCD


    Now, B, AB, ABC, BCD identifies all columns so those four qualify for the super key.

    But, B⊂AB; B⊂ABC; B⊂BCD hence AB, ABC, and BCD disqualified for CANDIDATE KEY as their subsets could identify the relation, so they aren't minimal and hence only B is the candidate key, not the others.

    Thanks for asking.

提交回复
热议问题