I'm in the process of learning Mysql, and I'm creating databases. So, after looking at several websites, the definition for a primary key is:
The PRIMARY KEY constraint uniquely identifies each record in a database table.
and is used like this:
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
PRIMARY KEY (P_Id) //primary key is on this line
)
However, I still don't know what it's used for and why we need it. So my question is.
Can someone explain to me what a primary key is (in basic english) and why we need one and what is it used for?
Thank-you.