How to Add a Composite Key Using phpMyAdmin
The primary key for a table can be made up of more than one column, this is known as a composite primary key (or composite key).
Composite primary keys are often used when two pieces of information are required to uniquely identify a value in a table.
In the sample application, composite primary keys are used in the
likes table to link the id of the article and the id of the person who likes the article.
You can follow the steps below to add a composite primary key to a table.
Select the table you are working with and go to the
The page will start with a list of the columns in that table.
Select the checkboxes before the names of the columns that should be used as the composite primary key.
Then press the
Primary link (shown under the table).
The Indexes section of the page (located under the columns) will show that these two columns are being used in an index.
(If there was already a primary key on the table, you may see a screen that shows you the SQL that it will run to change the index, and ask you if you want to execute it. If so, press yes.)