<font face="arial" size="2"><p style="margin:0;padding:0;">Hi Toben,</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">Many thanks. Aw, so simple. I should have thought of that.</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">I'm working on a db that has a strong hierarchical structure similar to:</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">books</p>
<p style="margin:0;padding:0;">|</p>
<p style="margin:0;padding:0;">fiction | non-fiction</p>
<p style="margin:0;padding:0;">|</p>
<p style="margin:0;padding:0;">genre1 genre2 ...</p>
<p style="margin:0;padding:0;">|</p>
<p style="margin:0;padding:0;">author1 author2 ...</p>
<p style="margin:0;padding:0;">|</p>
<p style="margin:0;padding:0;">book1 book2</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">Queries would look like:</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">1) List all genres</p>
<p style="margin:0;padding:0;">2) List all authors in genre</p>
<p style="margin:0;padding:0;">3) Select author</p>
<p style="margin:0;padding:0;">3) List all books in genre</p>
<p style="margin:0;padding:0;">4) List all books in genre</p>
<p style="margin:0;padding:0;">5) Select book</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">Many times more reads than writes. As I understand, the whole structure has to be built in RAM. Genres could, conceivably be factored into separate graphs of up to several hundred books and authors/genre.</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">Which leaves the questions:</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">1) Is a transaction-like technique available to permit write graph structure to disk with losing record writes coming in in the meantime?</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">2) Any gains or simply querying a flat db?</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">3) Is there a yet better way?</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">Thanks again,</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">Lloyd</p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;"> </p>
<p style="margin:0;padding:0;">-----Original Message-----<br />From: "Torben Hoffmann" <torben.hoffmann@erlang-solutions.com><br />Sent: Tuesday, June 3, 2014 2:28am<br />To: "Lloyd R. Prentice" <lloyd@writersglen.com><br />Cc: "Erlang Users' List" <erlang-questions@erlang.org><br />Subject: Re: [erlang-questions] How to access digraph vertices<br /><br /></p>
<div id="SafeStyles1401804024">
<p style="margin:0;padding:0;">Hi Lloyd,<br />Lloyd R. Prentice writes:<br /><br />> Hello,<br />><br />> The documentation for digraphs tells us that vertices can be any Erlang term.<br />><br />> How would we retrieve a vertex expressed as a record? E.g., by key. Surely we<br />> wouldn't want to use or even know the whole record. <br />><br />Not quite sure what it is you are trying to do here, maybe an example would help us<br />(or just me) understand what you are up to.<br /><br />Even though vertex() is term() I would not push a record into the vertex. I would<br />push the key in as the vertex() type and let the record be the label of the vertex.<br /><br />But, again, it highly depends on what the use case is... hint, hint!!<br />Might be that digraph is not the right way to solve your problem.<br /><br />Cheers,<br />Torben<br /><br />> Many thanks,,<br />><br />> LRP<br />><br />> Sent from my iPad<br />> _______________________________________________<br />> erlang-questions mailing list<br />> erlang-questions@erlang.org<br />> http://erlang.org/mailman/listinfo/erlang-questions<br /><br /><br />-- <br />Torben Hoffmann<br />CTO<br />Erlang Solutions Ltd.<br />Tel: +45 25 14 05 38<br />http://www.erlang-solutions.com</p>
</div></font>