What is a Primary Key?

In database relational modeling and implementation, a primary (or unique) key is a set of zero, one or more attributes, the value(s) of which are guaranteed to be unique for each record in a table. The value or combination of values of unique key attributes for any record cannot be duplicated for any other record in that table.


When more than one column is combined to form a primary key, their combined value is used to access each row and maintain uniqueness. Values are not combined, they are compared using their data types.


When a column or set of columns is defined as unique to the table, the system verifies that each set of value(s) is unique before assigning the unique constraint. After the column(s) are defined as unique, an error will occur if an insertion is attempted with values that already exist. Some systems do not allow key values to be updated, but all systems will not allow duplicates, ensuring that uniqueness is maintained.


Source:  Wikipedia


Page ID:4661-1945-1082