Advertisement Jump to content
Sign in to follow this  

primary key confusion

This topic is 4970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
When creating your table create the primary key last:

create table foo(
gameid int unsigned not null,
username varchar(80),
primary key( gameid, username )

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!