Yes, db design is not my strength, but after reading the article suggester by laserlight I can pat myself on the back, I did pretty well. not bad for a guy with no formal technical education.
My question sounds like I have a lot of redundant data in my table but it is not. I'll explain. I have a table with over 45,000 lines that contain zip code info. Each user can setup a range that can be anywhere from 25 to 300 miles. Imagine a circle drawn around you with a radius of 300 miles. Every zipcode that is touched by this radius is unique to this particular user. Think of it as a unique geo signature. I decided to add a cell in a table containing user information and store all zips in it separated by commas. Granted, I can have multiple users in the same zip code area, but their ranges could be quite different. I suppose I could attmpt to create a separate table with many-to-many relationships but I've never really done anything like this. It would probably look something like this:
User
------------------------------------------------------
ID | Name | Geo
1 | bob | 2
------------------------------------------------------
Geo
------------------------------------------------------
ID | Zip_Range | Zips
2 | 12345_100 | 12345, 12346.....
3 | 12345_25 | 12345, 12346.....
------------------------------------------------------
At least this way if I have 40 users from zip code 12345 and 20 of them set the same range of 100 miles all I would have to do is refer them to Geo.Zip_Range = 12345_100.
Am I still on the right track?
By the way, there could be a lot of zip codes withing a 100 miles radius. Is there a way to compact this data into db as opposed to leaving it in text format?
Oh, and not to worry, I won't be creating table with 45K zips time the number of possible ranges. Before I'll assign an id to reference a record from geo table I can take user zip and the range specified, create a var by putting those together and query geo table. If there is no such record, I can create and store it and then take last created id from geo and plug it into user table. In fact I think I'll consider expanding on this idea and store most of the my user zips that way instead of making a cal and compiling the zips each time they do some task. Although... it may need to be thought out properly.
Too bad it's already Friday, I'm just warming up!