I created a database, and in the courses I did, we always used the id as primary key , it is a problem to use email as the primary key, because this would prevent the registration of a Email Alike!
I created a database, and in the courses I did, we always used the id as primary key , it is a problem to use email as the primary key, because this would prevent the registration of a Email Alike!
It's okay to use email as PRIMARY KEY
, however, it's not recommended.
There is a way to prevent a data from being logged more than once, so you can enter the value UNIQUE
CREATE TABLE IF NOT EXISTS 'usuarios' (
'id' int(11) NOT NULL AUTO_INCREMENT,
'email' varchar(60) NOT NULL,
'nome' int(60) NOT NULL,
'idade' tinyint(4) NOT NULL,
PRIMARY KEY ('id'),
UNIQUE KEY 'email' ('email')
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
If you have already created your table.
ALTER TABLE 'usuarios' ADD UNIQUE('email');