简体   繁体   中英

Candidate keys SQL

hi am recently learning about SQL and keys.

i am wondering if there is n attributes to a relation table how many possible Candidate keys would there be?

Each subset of the attributes of the relations can be a candidate key. So the number is equal to the number of the subsets of a set of n elements, that is 2 n

Edited

The original answer was 2 n -1, but it significant also to have the empty (or niladic) key. A key of such kind implies that the relation has only one tuple. Thanks to @ErwinSmout for the clarification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM