A primary key is designed to uniquely identify every record in a table. For example, in a student table, it will be the student ID column. We need to be mindful that a primary key can be a composite key, in which two different columns can be combined into a unique identifier of records within a table.
Within any table, every record must have a non-empty value in the primary key column, and it should always be unique and never repeated.
For relational tables, it is imperative to have a primary key defined. After its definition, you cannot define another primary key within the same table.
An index is used to store a primary key so that it remains unique and ensure that a foreign key can reference it.
We used the [Key] attribute in the examples earlier in this chapter to define a primary key on a model.