Great question!<br><br>Tie::DBI can only store one level of data. If a hash key contains a nested data structure, then that structure is just serialized with Storable and stored in one row.<br><br>The module I&#39;ve written is different in a few ways. First, it supports both hashes and arrays (it&#39;s really two modules, one for each). Second, it&#39;s totally recursive: if the root hash contains nested structures, those structures are automatically stored in the same way as the root. This means that key/value pairs and array elements of structures deep within the tree will also each have their own rows.<br>
<br>Here is the advantage of doing this: SPEED!<br><br>When I go to read just a few keys deep within a structure, the algorithm only has to follow the path through the tree to those specific keys (or array indexes). It can leave the rest of the data in the database. It doesn&#39;t have to pull the whole thing and de-serialize all of it.<br>
<br>Or, if I want an entire hash, then a different SQL query is used, returning the entire hash&#39;s key/value pairs in one SQL query. Also, the entire table schema is properly indexed in the SQL database, so lookups of individual values and entire structures are all done using index lookups and not table scans.<br>
<br>Finally, caching is employed, so data only has to be read from the SQL server once.<br><br><br>-Mike<br><br><div class="gmail_quote">On Mon, Nov 16, 2009 at 8:58 PM, Jonathan Hogue <span dir="ltr">&lt;<a href="mailto:jon@hogue.org">jon@hogue.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I would love to learn more! How is it different from Tie::DBI? :-)<br>
<div><div></div><div class="h5"><br>
<br>
2009/11/16 Michael Frager &lt;<a href="mailto:mike@dialyourleads.com">mike@dialyourleads.com</a>&gt;:<br>
&gt; Hello,<br>
&gt;<br>
&gt; The big difference between my module and DBM::Deep is that my module uses a<br>
&gt; SQL database (like MySQL) instead of flat files. DBM::Deep has implemented<br>
&gt; its own locking and concurrency system that is not likely to be a robust as<br>
&gt; a real SQL database.<br>
&gt;<br>
&gt; Other than that the concepts are very similar. Basically, you do what you<br>
&gt; want to your data structures and the results are transparently and<br>
&gt; persistently stored for you.<br>
&gt;<br>
&gt;<br>
&gt; -Mike<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Nov 16, 2009 at 5:27 PM, Rob Kinyon &lt;<a href="mailto:rob.kinyon@gmail.com">rob.kinyon@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I&#39;d be very interested in seeing how this and DBM::Deep could play<br>
&gt;&gt; together.<br>
&gt;&gt;<br>
&gt;&gt; Rob<br>
&gt;&gt;<br>
&gt;&gt; 2009/11/16 Michael Frager &lt;<a href="mailto:mike@dialyourleads.com">mike@dialyourleads.com</a>&gt;:<br>
&gt;&gt; &gt; Hello (again) Columbus.pm,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I have developed a module that is somewhat like MLDBM. In case you&#39;re<br>
&gt;&gt; &gt; not<br>
&gt;&gt; &gt; familiar with MLDBM, this module will take a hash and synchronize its<br>
&gt;&gt; &gt; contents with a DB file for persistent storage. Unlike a regular hash<br>
&gt;&gt; &gt; tied<br>
&gt;&gt; &gt; to a DB file, MLDBM will save entire data structures that are contained<br>
&gt;&gt; &gt; within the hash keys, serializing them on the fly.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I&#39;ve taken that concept a little bit further and developed a module that<br>
&gt;&gt; &gt; will synchronize both hashes and arrays with a SQL database. Each<br>
&gt;&gt; &gt; element of<br>
&gt;&gt; &gt; the data structure being stored can either be stored as its own row or<br>
&gt;&gt; &gt; its<br>
&gt;&gt; &gt; entire contents serialized (similar to MLDBM). The process is recursive<br>
&gt;&gt; &gt; so<br>
&gt;&gt; &gt; entire structures can be stored this way.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The upshot is that you can take an entire Perl data structure, made of<br>
&gt;&gt; &gt; any<br>
&gt;&gt; &gt; combination of hashes and arrays, and just place it into a SQL database.<br>
&gt;&gt; &gt; It<br>
&gt;&gt; &gt; works no matter how deep the structure is and without the need for a<br>
&gt;&gt; &gt; custom<br>
&gt;&gt; &gt; SQL schema. Since Perl&#39;s &quot;tie&quot; function is use, once the structure is<br>
&gt;&gt; &gt; stored, it can be manipulated like any variable, except that changes<br>
&gt;&gt; &gt; will be<br>
&gt;&gt; &gt; transparently stored in the SQL database.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I&#39;m in the processes of preparing this module for CPAN, I was wondering<br>
&gt;&gt; &gt; if<br>
&gt;&gt; &gt; there is anyone in the Columbus.pm group who might be interested in<br>
&gt;&gt; &gt; learning<br>
&gt;&gt; &gt; about it?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thanks,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Michael K Frager, Software Developer<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; ~ Dial Your Leads ~<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; [+] Phone:    (888) 310-4474<br>
&gt;&gt; &gt; [+] Website: <a href="https://www.dialyourleads.com/" target="_blank">https://www.dialyourleads.com/</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt; &gt; Columbus-pm mailing list<br>
&gt;&gt; &gt; <a href="http://columbus.pm.org/" target="_blank">http://columbus.pm.org/</a><br>
&gt;&gt; &gt; <a href="mailto:Columbus-pm@pm.org">Columbus-pm@pm.org</a><br>
&gt;&gt; &gt; <a href="http://mail.pm.org/mailman/listinfo/columbus-pm" target="_blank">http://mail.pm.org/mailman/listinfo/columbus-pm</a><br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Thanks,<br>
&gt;&gt; Rob Kinyon<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt; Michael K Frager, Software Developer<br>
&gt;<br>
&gt; ~ Dial Your Leads ~<br>
&gt;<br>
&gt; [+] Phone:    (888) 310-4474<br>
&gt; [+] Website: <a href="https://www.dialyourleads.com/" target="_blank">https://www.dialyourleads.com/</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Columbus-pm mailing list<br>
&gt; <a href="http://columbus.pm.org/" target="_blank">http://columbus.pm.org/</a><br>
&gt; <a href="mailto:Columbus-pm@pm.org">Columbus-pm@pm.org</a><br>
&gt; <a href="http://mail.pm.org/mailman/listinfo/columbus-pm" target="_blank">http://mail.pm.org/mailman/listinfo/columbus-pm</a><br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><br>Michael K Frager, Software Developer<br><br>~ Dial Your Leads ~<br><br>[+] Phone:    (888) 310-4474<br>[+] Website: <a href="https://www.dialyourleads.com/">https://www.dialyourleads.com/</a><br>
<br>