Monday, December 21, 2009

primary Key Selection

Primary keys must be able to be quickly and easily generated and should not depend on other data for their generation. Because a record cannot be inserted in the database without a primary key, any violation in the generation of the primary key can result in loosing the data and not being able to insert the record. Therefore, the use of unique, automatically generated serial numbers is recommended for primary keys.

Each record (row) must be uniquely identified within the table.

Primary keys cannot be modified or updated throughout the life of the database. If the primary key must be updated because it was not selected properly, the entire row must be deleted and recreated. If the record has dependent records or children in other tables, which have children in other tables, deleting the record is an affair by itself. So encoding meanings in the value of the primary key is a dangerous practice that must be discontinued. For example the following candidate for identifying a citizen is not valid: the first three characters encode the city of residence, the next three digits encode the religion and the last seven digits are the unique home telephone number. All pieces of this candidate key are subject to change.



http://databases.about.com/od/specificproducts/a/primarykey.htm

No comments:

Post a Comment