Hello all, first post...
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