mysql - Proper way to create composite PK -
as far know, there 2 ways of creating composite pk, dont know differences or one:
create table appusers ( id int not null, username varchar(20) not null, lastname varchar(100), firstname varchar(100), primary key (id, username) )
vs
create table appusers ( id int not null, username varchar(20) not null, lastname varchar(100), firstname varchar(100), constraint pk_appusers primary key (id, username) )
specifications:
according http://dev.mysql.com/doc/refman/5.0/en/create-table.html , http://dev.mysql.com/doc/refman/5.0/en/alter-table.html, constraint
key word optional primary key
.
best practice:
i say, use 1 whichever prefer regarding readability. i'd tend limit letters though, using join
instead of inner join
.
Comments
Post a Comment