We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7231
    • 4,205 Posts
    I am trying to come up with an efficient way to be able to group companies by Region, then by Country according to the region, and finally by City according to the country. Since a company could have an office in more than one region,country and city I think that a setup with tags could work, where I would have a tag set for each region, country and city (3 independent tag sets).

    Now it gets tricky. How do I get the tags to relate to each other? For example, how do I get Paris to be related to France and then to Europe? And then if a company has multiple regions, countries and cities how to associate a particular region with the correct country and so forth. SO if I have the Europe and South America tags for regions, then France and Columbia for countries and then Paris and Bogota for cities how do I relate one tag with it’s corresponding tags?

    I am not sure if I am making any sense, it is getting confusing for me to follow myself so explaining it is even more confusing rolleyes
      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

      Something is happening here, but you don't know what it is.
      Do you, Mr. Jones? - [bob dylan]
      • 3749
      • 24,544 Posts
      It made me dizzy too and it’s been a long day, but maybe my rambling will give you something to grab onto.

      I see a minimum of three tables:


      Company
      ID, Name, address, phone, etc.

      e.g.
      1, IBM, etc. etc.
      2, Apple, etc. etc.

      City
      ID, Name, Region, Country

      e.g.
      1, Paris, France, Europe
      2, Chicago, USA, North America


      City-Company
      ID, CityID, CompanyID

      e.g.
      1, paris, IBM
      2. bogota, Apple
      3. New York, IBM
      4. New York, Apple

      You can get all the cities of a company from the city-company table, then get the region and/or country from the city table.

      Going the other way, you can get all the cities in a region or country from the city table, then get all the companies in that region or country from the city-company table.

      I think it would be more correct to also have a region table and a country table which each contained two fields: ID and Name and then use the two ID’s in the city table but I don’t think it’s necessary. If you did, though, all your tags would be ID numbers which would probably speed things up.

      I hope this makes at least some sense.

      Bob
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting