Primary key

Primary key definition:

Primary key is a unique sequency of characters (unique ID – identyfication text or number) assigned to specific data in the database. Thanks to primary key we can distinguish similar data from each other.

Primary key example:

Let’s analyze the database of some library which contains names and birth places of students:

Primary key

In the above database we have 3 people with the same name – James Williams. What is more, 2 of them were born in the same place – Los Angeles. In order to distinguish those people from each other we can add one more column (PERSON_ID) with unique ID sequency  assigned for each person.

Primary key

PERSION_ID  will be our primary key in this database, because each person has its own unique ID which cannot be assigned to other person.

Primary key

In case, when one of James Williams from Los Angeles (for example with PESRON_ID = A128) want to borrow a book in the library, the library staff can easly note only his PESRON_ID  and make sure that exactly this James Williams holds mentioned book. Primary key protects library staff from mistake and as a result, asking the wrong James Williams from Los Angeles to return book to the library.

Copyright © 2015-2016 • All Rights Reserved •

Leave a Reply

one + fourteen =