PDA

View Full Version : Mysql set up



hampster
01 Jun 2009, 03:06 PM
I have a question about setting up a table in MYSQL

Basically, one field would be a "Location". There is a minimum of 1 location, but it is possible for there to be several.

I was thinking about making "Location" a comma separated list of LIDs, then I can just select a certain LID to be IN Location.

It does not seem to be a fairly efficient method- is there a better way to be doing this? What are the pros and cons of this method vs others.

Thanks, Dave

Alan
01 Jun 2009, 04:00 PM
Can the same location occur in multiple records? If the answer is yes, then the best way to do this is to setup a many to many relationship. A comma separated list could be used aswell, but that's messy. You could use a serialized numeric array instead. It doesn't really matter tbh. A many to many is the way to go though.