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