ToolSphere

Candidate Key Finder

Computer science

Find every candidate key of a relation from its functional dependencies, with prime attributes and normal form.

Candidate key finder

Every candidate key for a relation, plus its prime attributes and highest normal form. Write one dependency per line as A,B -> C. Single letters may be written together, as in AB -> C.

Closure

A+ = { A, B, C }

It determines every attribute, so A is a superkey.

Candidate keys

A

Relation:
R(A, B, C)
Prime:
A
Non-prime:
B, C
In every key:
A

Highest normal form: 2NF

DependencyBreaksWhy
B → C3NFB is not a superkey and determines the non-prime C — a transitive dependency.

On this browser only

Give feedback

Did this tool help?

Tell us what worked, what didn’t, or what you’d like next.

Opens Google Forms in a new tab with this tool’s name filled in. No sign-in or email required. Feedback is optional.

How to use Candidate Key Finder

  1. 1Enter the functional dependencies, one per line, as A,B -> C.
  2. 2Add any attribute that appears in no dependency in the extra attributes box.
  3. 3Read every candidate key, and which attributes are prime and non-prime.
  4. 4Check the highest normal form and the dependency that breaks the next one.

About Candidate Key Finder

Candidate Key Finder

Finds every candidate key of a relation from its functional dependencies, then uses them to decide the highest normal form the relation satisfies and to name the dependency responsible for each failure.

How the keys are found

An attribute that appears on no right-hand side cannot be determined by anything else, so it must belong to every candidate key. Those attributes seed each candidate, and only the remaining ones get combined — which usually collapses the search from every possible subset to a handful.

Each candidate is then tested twice: its closure must contain all attributes (superkey), and no proper subset may also be a superkey (minimal). Smaller sets are tried first, so a genuine candidate key is always found before any superset of it.

A relation can have several candidate keys. With AB → C and C → A, both AB and BC determine everything, so both are candidate keys — and that is exactly the shape that satisfies 3NF while breaking BCNF.

Prime and non-prime

A prime attribute belongs to at least one candidate key; a non-prime attribute belongs to none. The distinction only exists because 2NF and 3NF are defined in terms of it, and getting it wrong is what usually produces the wrong normal form.

How the normal form is decided

2NF fails when part of a candidate key determines a non-prime attribute — a partial dependency. It can only happen when a candidate key has more than one attribute.

3NF fails when a non-superkey determines a non-prime attribute — a transitive dependency.

BCNF fails when a non-superkey determines anything at all, prime or not. It is the strictest of the three, and a relation can sit in 3NF but not BCNF, which is the case worth understanding.

1NF is assumed here. It says values must be atomic, which is a property of the data rather than of the dependencies, so no dependency list can prove or disprove it.

Limits worth knowing

The relation is taken to be exactly the attributes you mention, so anything appearing in no dependency must go in the extra attributes box or the keys will be wrong. The search covers up to 18 attributes, far beyond coursework size. Multivalued dependencies and 4NF are outside what a functional-dependency list can express.

Guides and tutorials

Frequently asked questions

Can a relation have more than one candidate key?

Yes, and it is common. With AB -> C and C -> A, both AB and BC determine every attribute, so both are candidate keys. One is chosen as the primary key; the rest remain candidate keys, and all their attributes count as prime.

How do I know an attribute is in every candidate key?

If it never appears on the right-hand side of any dependency, nothing can determine it, so every key must contain it. The tool lists these separately — they are the fastest shortcut when working keys out by hand.

What is the difference between a superkey and a candidate key?

A superkey determines every attribute. A candidate key is a superkey with nothing to spare: remove any attribute and it stops determining everything. Every candidate key is a superkey; most superkeys are not candidate keys.

Why is my relation in 3NF but not BCNF?

Because a non-superkey determines a prime attribute. 3NF permits that, since it only forbids non-prime attributes depending on a non-superkey; BCNF forbids any non-superkey determinant. The classic case is AB -> C with C -> A.

What counts as a partial dependency?

Part of a candidate key determining a non-prime attribute. It requires a composite candidate key: with key AB, a dependency A -> C where C is non-prime is partial, and the relation is only in 1NF.

Why does the tool ask for extra attributes?

Because the relation is inferred from the dependencies you type. An attribute in no dependency is invisible to that, yet it belongs in every candidate key, so leaving it out silently changes the answer.

Have a suggestion for Candidate Key Finder?Share your feedback ↗