Blake McCarthy
Blake McCarthy

Reputation: 39

When unique value can’t be used practically as a primary key in a database

I am having trouble answering the following question...

Illustrate by an example a scenario where an attribute has unique values in the different rows, yet it can’t be used practically as a primary key in the database relations/tables.

Upvotes: 0

Views: 842

Answers (3)

Amir Molaei
Amir Molaei

Reputation: 3810

If the suggested column that has unique values is nullable and contains null values too, it cannot be a practical primary key. Because primary keys can't be null.

Upvotes: 1

Slawomir Dziuba
Slawomir Dziuba

Reputation: 1325

"random" is unique but practically as a key I would not use it.

Upvotes: 0

Hans Kesting
Hans Kesting

Reputation: 39274

A non-sequential GUID is a bad candidate for a primary key, when the data is stored ordered by that key. An insert of a new row will not be appended to the table but must be inserted in the middle, meaning that data must be moved around to make room.

That is why there may also exist sequential GUIDs .

Upvotes: 0

Related Questions