PDA

View Full Version : Advice: multiple tables or just one?


Michiel
07-08-2003, 06:54 PM
Hi,

I want to store a large set of variables into a database that are all characteristics of the users of my site. They can register by filling out their name/ adres/ city / day of birth etc.

Besides that they can set a number of preferences (e.g. 'available on monday', 'available on tuesday', 'category 1', 'category 2' etc.) that can be either '1' or '0'.

Furthermore I want to store some variables that tell me if the supplied email adress is validated, what the ip-adress of the registrant is and on what date he registered.

Using MySql, what method is preferred to store the data:

1) one table with +/- 40 columns (note that there a lot of values are booleans).

2) 3 tables, e.g. users, preferences, other with 5 to 20 columns each.

The thing is that I want to be able to perform searches that include all types of characteristics. E.g. I want to select all users that are:

'male, older that 18, are available on monday, preffer category 2 and where the email adress is validated'


Any advice on this topic is very welcome!

Cheers, Michiel

bcarl314
07-08-2003, 09:03 PM
Go with the normalized format, ie more tables. You can still get what you want, your SQL will just be a little different.