What is the primary key?

The primary key is an item in a database that is unique for one record. This key is generally derived in one of two ways: a unique identification code from an external database or a generated database number. If the database contains information that is always unique to an item, such as the Social Security number or the part identification number, then they are usually used as a primary key. If the data does not have such an identifier, the database often creates numbers based on its internal systems to provide each record with a unique code.

There are three main restrictions on the primary key: existence, uniqueness and non -changeability. There must be a key at a time when the record is - cannot be added later. Each key must be completely different from any other key. This means that ordinary identifiers such as the name or date of birth cannot be used because it is possible that two people are born on the same day with the same name. And finally, the primary key can not change after creationa shank.

Since the database can have a potentially infinite number of items, the primary key must also be endless. To make sure that the database never runs the key, most records use the numeric code. Because the numbers can always increase and computers can simply add zero to older items that are retained, the system will never run out. Sometimes these numbers are based on inconsistent information, but a unique identifier is added to make sure the key is viable.

Databases will use the primary key as a data organization. Since the key is never repeated, this information will allow the database to maintain each record separate from all others. Each information in the record is connected to the key; In this way, no matter what happens to the system, the database can rebuild free information records.

Assignment of the classified primary keyNo is often considered to be a better practice than automatic value generation. This will be provided by an identifier that both works as a key and provides data. In small databases, this resolution is rarely necessary, but in large systems, another space used by the generated key, which is the result of a serious flatulence of the database. This slows down the system and databases require significantly more storage space.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?