Questions tagged [candidate-key]

A candidate key of a relational table is a set of columns whose subrow values are unique (a unique key, aka superkey) that doesn't contain a smaller such set. One can be chosen primary key; each other is then an alternate key. (An SQL PRIMARY KEY or UNIQUE NOT NULL declaration declares a superkey. It is a candidate key if no smaller one is declared within it.)

A candidate key of a relational table is a set of columns whose subrow values are unique (a unique key, aka superkey) that doesn't contain a smaller such set. One can be chosen primary key; each other is then an alternate key. (An SQL PRIMARY KEY or UNIQUE NOT NULL declaration declares a superkey. It is a candidate key if no smaller one is declared within it. In an SQL context "key" usually means a superkey.)

Candidate keys of a relational table (value or variable) are fixed by the functional dependencies that hold in it. Candidate keys play an important role in database normalization to higher normal forms, along with functional dependencies and join dependencies. A relational foreign key involves a column list referencing a list of columns forming a candidate key. (An SQL FOREIGN KEY declaration declares a foreign superkey. It is a foreign key if that superkey is a candidate key.)

9 questions
26
votes
3 answers

What is the difference between a primary key and a superkey in a DBMS

What is the difference between a primary key and a superkey in a DBMS? Can a primary key and a superkey both have multiple columns? Is a primary key a subset of a superkey or vice versa?
MikeHil
  • 369
  • 1
  • 3
  • 3
8
votes
3 answers

When should a primary key be meaningful?

Excuse the looseness of any definitions here, but I am trying to explore a simple concept. A Primary Key uniquely identifies a row. There are possibly other columns in a table with unique values, so they can also uniquely identify a row (Candidate…
Manngo
  • 3,065
  • 10
  • 38
  • 61
7
votes
2 answers

Does the concept of candidate key exist only in theory?

I know the concept of candidate key in RDBMS theory, but do candidate keys really exist in actual SQL engines? I mean is there any way to designate a particular column or set of columns as a candidate key in any of the SQL database management…
3
votes
1 answer

What is the meaning of "minimal key"?

In the definition, it says minimal key is a minimal set of attributes needed to identify the table. Does the "minimal" part mean "minimal number of attributes" or "cannot be eliminated"? For example: For a relation R(A, B, C, D, E, F), the closure…
2
votes
2 answers

Composite primary key plus a separate (surrogate) id column for foreign key references

I am trying to build a database about locations like so: Country → Region → Town Countries will be populated with a list of pre-defined worldwide countries, regions & towns are input by users. Region may not apply to every location and so a blank…
1
vote
1 answer

Simple and Composite Candidate Key and Nulls

One of the differences between a candidate key and a primary key is that "candidate keys can contain nulls." I have been unable to find a more precise definition of what this means. One explanation I have seen is that in a CK with only one…
1
vote
0 answers

Solution verification for functional dependency using armstrong axioms

I have the following functional dependencies which includes all attributes of the relation: {AB -> C, BC -> AD, D -> E, CF -> B} CF supposedly is a candidate key. The task is: Show that CF is a candidate key given the functional dependencies…
Rubus
  • 131
  • 5
1
vote
2 answers

What are the disadvantages of using surrogate keys?

I am using MS SQL Server but in general database design I want to know what problems can arise when every row in a database has its auto generated surrogate key value. I know some advantages, for example that there is no need to identify unique…
igelr
  • 2,162
  • 3
  • 26
  • 56
1
vote
2 answers

Defining a primary key: Customer numbers are unique only within a country but may be duplicated across different countries

I am facing the following problem: I have a table with customer information like the customer number, i.e. customerID set up as the primary key, and, besides a number of other data, also a country value in the form of a country code,…