Web Analytics Made Easy -
StatCounter Efficient Country/Province City setup - CodingForum

Announcement

Collapse
No announcement yet.

Efficient Country/Province City setup

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Efficient Country/Province City setup

    I currently have a program that does a global query of all of the data. I want to break it down so as to drill the user down to thier local area. for example:

    Country
    Province
    Region
    City

    As you can see, a country can have many provinces, a province many regions and a region many cities or a province many cities. What is the most effecinet way to do this in MySql? I'm OK with doing single tables. ie:
    INSERT INTO Province VALUES (NULL, 'Ontario', 'ON');
    but I'm unclear if that's the way it should be done. I'm using PHP on the client side. Thanks!

  • #2
    what's your db design?
    do you have a foreign key inside the provinde-table to refer to the country-table ? and a foreign key finside the region-table to refer to the provinde table? and a foreign key inside the city-table to refer to the region-table?
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment

    Working...
    X