patternModerate
What does this definition of a Primary key mean?
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.
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.
Let us investigate all possible keys.
Hence, there are two choices for primare keys here:
Nota bene: They should require $K \neq \emptyset$.
For instance, consider this relation.
A B C
1 4 4
2 4 6
3 6 6Let us investigate all possible keys.
A-- unique and irreducible.
B-- not unique.
C-- not unique.
A,B-- reducible toA.
A,C-- reducible toA.
B,C-- unique and irreducible.
A,B,C-- reducible toA.
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 6Context
StackExchange Computer Science Q#63512, answer score: 14
Revisions (0)
No revisions yet.