An index can also be known as a key.  Therefore you can guess that the primary key is the most important index.  A primary key is used to uniquely identify each record in a table.  So in a database containing records of books you might use the ISBN as primary key as each book in the world has a unique ISBN.

Sometimes there is no obvious primary key but there must be one.  For example in this table of people:

firstname surname dob
John Smith 01/12/76
Sara Jones 13/06/69
Sara Jones 1/04/68
Fred Bloggs 11/11/73

You might think surname would be the primary key but then how can the database management system uniquely identify a single record (as there are two rows with the same surname).

You might index firstname and surname to enable you to quickly find people by searching for their names.  However, no single field allows you to uniquely identify each and every record.  How would you tell it to extract just the record for Sara Jones with the date of birth 12/6/69 and not the other Sara Jones?  One answer is a composite primary key which is an index made up of more than one field.  It is unlikely that there will be anyone in the database with the same first name, surname and date of birth but it could happen and this is one of the problems with composite primary keys so avoid them for now at least.

You are probably better off adding a new field which only exists to be the primary key:

personID firstname surname dob
1 John Smith 01/12/76
2 Sara Jones 13/06/69
3 Sara Jones 1/04/68
4 Fred Bloggs 11/11/73

The new first field is different for every row and so can be the primary key.  You can easily tell the DBMS to select the row/record with a personID equal to 3 and it will only get that one record for you.


Fields added just to allow them to be a simple primary key are used so often that most database management systems allow you to create a field which forces each entry to be unique.  Every time you add a new record in the table the primary key field is automatically filled in with the next available number.  That is automatic incrementation or auto increment.