dbTalk Databases Forums  

Re: the way to go about his?

comp.databases.mysql comp.databases.mysql


Discuss Re: the way to go about his? in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
J.O. Aho
 
Posts: n/a

Default Re: the way to go about his? - 12-27-2011 , 10:19 AM






Michael Joel wrote:
Quote:
My project is to have a list of businesses, sorted by county and towns
(then sub sorted by names, etc).
Each business though is allowed to be listed in up to 3 counties and
towns.

I have it so I can list by "home" county and the "home" town of the
business. The 2nd and 3rd county listing works - except of course this
puts towns for those extra listings jumbled up.

What is the best way to handle this. I of course have no desire to
manually create a database of towns in the state.

Please keep explanations simple

Start with a table for states, name and id, fill it up at you get new entries
for your database (keep in mind that this can cause doubles).

Then have a table for counties with name, id and a state_id, fill it up as you
get new entries (keep in mind that this can cause doubles).

Then have the town table with name, id and a county_id, fill it up as you get
new entries (keep in mind that this can cause doubles)


Then have a last table which connects the business with the towns, with
business_id, town_id and is_home_town, this way you can have infinite number
of towns connected to a businesses and you can keep track of which one is the
home town.

As you don't want to enter all the values ahead of time, then you need to make
an administration tool which allows you to merge two states together, two
counties together to one and of course merge two town into one too, as people
tend to write things differently for example:

Newyork, New York, New-york are most likely the same place, but typed in a
different way.

There is far better places to get better answers than alt.php.sql, so we push
it to comp.databases.mysql and keep it there.

--

//Aho

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.