4 ms·
> Technically, a key is any column (or a set of columns) that you use to find records. Isn't that an index rather than a key? I thought 'key' meant: - a supe
by dghf 10y ago
> Technically, a key is any column (or a set of columns) that you use to find records.
Isn't that an index rather than a key?
I thought 'key' meant:
- a superkey (any set of columns the values of which must be unique in any given row; in a properly relational model, any relation will have at least one, the trivial superkey, the set of all attributes in the relation)
- a candidate key (a minimal superkey, i.e. one without redundant columns -- if you remove any column from the key, it will cease to be unique)
- a primary key (the candidate key considered to be and designated as the most important)
- a foreign key.
- carterehsmith 10y agoI agree, the definition I provided (not mine) sounds more like an 'index' than a 'key'. I am not familiar with that usage, I am used to 'key' being used as a logical concept, a constraint, while 'index' is a physical concept, some structure that is there 'just' to make shit go faster. Anyways, some sources don't even define the word 'key', but use it to mean 'unique key'. And some other sources (like the one by OP) use it to mean something else (totally not unique), as they recommend that it be 'unique to some degree' And then some others use the definition I provided above. Is that the one meant by OP? I don't know. I any case, I guess OP meant something like "indexes should be highly selective'. Which BTW is a performance tuning advice, I am not sure that that belongs in 'SQL Style Guide'.