What's the point of a candidate key?

前端 未结 9 618
借酒劲吻你
借酒劲吻你 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:22

    In the RM (relational model): A superkey is a unique column set. A CK (candidate key) is a superkey containing no smaller superkey. It is a candidate for being a PK (primary key). A PK is just some CK you decided to call the PK. The other CKs are AKs (alternate keys).

    A SQL PK is a UNIQUE NOT NULL, not necessarily a CK/PK. So we can say an SQL CK is UNIQUE NOT NULL, a candidate for being declared as SQL PK, and we can call the others SQL AKs. In an SQL context you have to ask people what they mean when they use these terms with different meanings in the RM & SQL.

提交回复
热议问题