We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3706
    • 1 Posts
    Hello all, first post... grin

    I’m very new to ModX, and I have a question about recommended data modeling methods.

    Background: I have know just enough about PHP and MySQL to be dangerous, although I have a bit of experience developing the older version (2.2.x) of eZPublish. I am self-learning ModX in an attempt to prepare for several planned web projects (who isn’t?). Although I really liked the rigid structure, modularity, and simplicity of the older eZPublish, the bloated templating system (among other things) made development painfully slow.

    I’ve only been learning ModX in the evenings for a few days, but I am already beginning to get my head around the basic concepts -- snippets (logic), chunks (presentation), template variables (custom fields), and the like. I am really impressed with the flexibility and shallow learning curve required to produce advanced results.

    I’d like to get some ideas on "best practices" for handling and storing large amounts of raw data. For example, the learning project I am working on is a Google maps application that uses server-side clustering to render thousands of geographic points. For example, I need to be able to store/query several thousand geographic points (lat/lon, title, description, etc). The snippet will need to be able to query this large data set rapidly, as performance is a consideration.

    Should I...

    1. Create a template with template variables for each custom data field (lat/lon, title, description, etc), and then use something like the Docmanager class to import all of my raw data as ModX documents (records) within a single container. This would seem to have an advantage of scalability (could add additional data for each point easily) and it would keep everything within ModX’s existing environment. My snippet could then query the documents (records) within the container to return the appropriate template variables. Would creating 1000s of documents (and querying them) still be as efficient as "raw" MySQL queries?

    2. Create additional database tables containing appropriate fields (lat/lon, title, description, etc), and then build a snippet to query the database tables. This seems like it would be efficient, but it would reference tables outside of the standard ModX set (potential scalability and portability problems). If this is the best option, are there any conventions for database table/field labeling?

    For example, my points table might look like:
    CREATE TABLE `poi_location` (
      `poi_id` int(10) unsigned NOT NULL auto_increment,
      `category_id` int(10) unsigned NOT NULL,
      `name` varchar(35) default NULL,
      `description` varchar(200) default NULL,
      `icon` varchar(20) default NULL,
      `latitude` double default '0',
      `longitude` double default '0',
      PRIMARY KEY  (`poi_id`),
      KEY `category_id` (`category_id`)
    ) ENGINE=MyISAM

    ...or, is there another option?

    I welcome any feedback the dev community might be able to provide.

    For anyone else interested in server-side clustering techniques for the Google Maps API, I am using the code listings 7-6 and 7-7 from the "Beginning Google Maps Applications" book, and they work great. The web site doesn’t provide much explanation (you’ll need the book for that!), but the code is there. I have all the basic functionality working in ModX, but I just need to figure out the best way to store the data!

    I’ve taken a look at doze’s excellent GoogleMapMarker snippet, that essentially does #1 above -- but without template variables, using existing document variables.

    Sorry for the long post. Thanks again for any advice or suggestions,

    Bob
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I would recommend a custom database table and a custom snippet to access it. Either have the snippet itself written to allow management from the front-end for logged in manager users, or make a module to add the management to the Manager. I prefer the latter myself, as I like to keep back-end, management tasks clearly separated from front-end, user interaction.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7923
        • 4,213 Posts
        yes, own db table(s) definitely. In current modx version, there is issues in storing very large amount of documents.


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 32319
          • 129 Posts
          If you have not already I would take a look at the @SELECT and @EVAL bindings for TVs.

          I think you will be able to do much of what you need with limited snippet coding using these bindings. You can find documentation here:

          http://www.modxcms.com/select-binding.html

          http://www.modxcms.com/eval-binding.html
            "Regret for the things we did can be tempered by time; it is regret for the things we did not do that is inconsolable."
            -- Sydney Harris
            • 34017
            • 898 Posts
            Bob,

            You might want to use something like eForm and eForm2db to allow easy creations of new map points. This is pretty straightforward to do. This way you can input all the items or allow others to in the future from the frontend via user groups.

            For listing the items, you can check out ppp to see how he parses a chunk (with the table fields) for each row.

            Chuck
              Chuck the Trukk
              ProWebscape.com :: Nashville-WebDesign.com
              - - - - - - - -
              What are TV's? Here's some info below.
              http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
              http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008