HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

What does this definition of a Primary key mean?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
thisdefinitionprimarywhatmeandoeskey

Problem

My text book gives the following definition of a primary key in a relational database, which I don't entirely understand. Help would be greatly appreciated.


Let $R$ be a relation. Then the primary key for $R$ is a subset of the
set of attributes of $R$, say $K$, satisfying the following two properties:



-
Uniqueness Property: No two distinct tuples of $R$ have the same value for $K$.

-
Irreducibility Property: No proper subset of $K$ has the uniqueness property.


I'm getting lost by the Irreducibility property.

Solution

Note how $K$ can be a set of columns. Irreducibility means that you have to pick minimal sets of columns.

Nota bene: They should require $K \neq \emptyset$.

For instance, consider this relation.

A   B   C

1   4   4
2   4   6
3   6   6


Let us investigate all possible keys.

  • A -- unique and irreducible.



  • B -- not unique.



  • C -- not unique.



  • A,B -- reducible to A.



  • A,C -- reducible to A.



  • B,C -- unique and irreducible.



  • A,B,C -- reducible to A.



Hence, there are two choices for primare keys here: A and B,C.

Code Snippets

A   B   C

1   4   4
2   4   6
3   6   6

Context

StackExchange Computer Science Q#63512, answer score: 14

Revisions (0)

No revisions yet.