Primary Key
A primary key is a column, or set of columns, in a relational database table whose values uniquely identify each row. A table has at most one primary key, and none of its columns may hold NULL.
The database engine automatically builds a unique index on the primary key, which is what makes lookups and joins against it fast. Every foreign key in the schema points back to some table’s primary key, which is why the two concepts are always discussed together.
A primary key may be a natural key, a value that already carries business meaning, such as an email or an ISBN, or a surrogate key, an artificial value with no meaning outside the database, such as an auto-increment integer or a UUID. Surrogate keys are the more common choice, since natural keys can change over time or turn out not to be as unique as assumed.
A composite primary key spans several columns; this is common on join tables in many-to-many relationships, where the pair of foreign keys together forms the key.
<?php
// Doctrine migration declaring a primary key
$table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->setPrimaryKey(['id']);
?>