Let's say that I have an articles
table that have two columns: title
and content
, and let's say that this articles
table don't have any relationship with any other table.
Why would this articles
table have a primary key?
The purpose of a Primary Key on a table is to ensure uniqueness of the rows in that table by the column(s) defined in the Primary Key. It does not need to be concerned with being part of a relationship with other tables.
Let's say the Primary Key of your example articles
table is defined on the title
column. This would guarantee that no two rows in the articles
table could have the same exact title
(because of the unique constraint that a Primary Key enforces).
Additionally, some database systems will automatically cluster the table on the column(s) defined in the Primary Key, typically known as a clustered index. This logically sorts the data by those fields, which can lead to improved query efficiency, especially when filtering or trying to sort the results by that field.