primary key confusion

Started by
0 comments, last by Easca 18 years, 10 months ago
Ok, I'm creating a fantasy football game with someone, and I have a database question. Basically, I have a table of users like so: username varchar(20) No gameid int(11) firstname varchar(40) No lastname varchar(40) No address varchar(80) No phonenumber varchar(20) No email varchar(80) No password varchar(20) No signuptime timestamp No accountactive int(1) No Different people can have the same username as long as they're in different games. However, the pair (username, gameid) will be unique for each row. Anyhow, I was talking with this guy at a Yahoo! interview about the game, and he told me I should designate the pair (username, gameid) to be the primary key. Is this right? I can't figure out a way to designate more than one field as a primary key in MySQL. Also, I'm using phpMyAdmin as an interface. Mike C. http://www.coolgroups.com/zoomer/
Mike C.http://www.coolgroups.com/zoomer/http://www.coolgroups.com/ez/
Advertisement
When creating your table create the primary key last:
create table foo(    gameid int unsigned not null,    username varchar(80),    primary key( gameid, username ));

This topic is closed to new replies.

Advertisement