views:

293

answers:

2

Hey all, my site is now going to start allowing two different types of users to sign up...

  1. normal people
  2. companies

the two will be able to do all the same things on the site, but their profiles will look different, and im sure they will want to store different types of information about themselves.

my question is: should i store them on separate mysql tables? or...should i put them on 1 and label them as "user" or "company"?

I could really use your input to help me to avoid pitfalls with either...

thanks!

+6  A: 

This link explains some best database practices.

I'd create an "Accounts" table with a UID, with common information between the two stored there, and which type of account it is.

Then a "Companies" table with company specific information, using the same UID as the account, and, I dunno, a "Users" table with information specific to users.

This prevents you from having to make two very similar tables, having unused columns, or duplicating data.

Like this:

Accounts
UID|UserName|Password|Account Type

Companies
UID|Company Name|Address|Contact Person

Users
UID|First Name|Last Name|Display Name
Stephen Pape
thats a cool setup...so basically just a table of BASIC user info and the perriferal (spelling?) tables to compliment the kind of user.LIKE IT
johnnietheblack
jesus, i dont know why i didn't see this before...but im doing cartwheels now...im a geek for organized info...THANKS
johnnietheblack
No problem, and yes, I remember how cool it was when it first clicked for me too. :)
Stephen Pape
cool, and useful (postgres does it cooler :P )
Osama ALASSIRY
+1  A: 

Don't put them in completely seperate tables or else you have to look up usernames, account details in 2 different places giving you if statements everywhere. Then you'll have a bitch of a time trying to do referential integrity and trying to make the "orders" table refer to a user OR a customer table. Either put shared info into one table and put specific stuff in extra tables or put everything in one big table.

Philluminati