Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would you represent a relational entity as a single unit of retrievable data in BerkeleyDB?
    text
    copied!<p><a href="http://en.wikipedia.org/wiki/Berkeley_DB" rel="nofollow noreferrer">BerkeleyDB</a> is the database equivalent of a Ruby hashtable or a Python dictionary except that you can store multiple values for a single key. </p> <p><strong>My question is: If you wanted to store a complex datatype in a storage structure like this, how could you go about it?</strong></p> <p>In a normal relational table, if you want to represent a Person, you create a table with columns of particular data types:</p> <pre><code>Person -id:integer -name:string -age:integer -gender:string </code></pre> <p>When it's written out like this, you can see how a person might be understood as a set of key/value pairs: </p> <pre><code>id=1 name="john"; age=18; gender="male"; </code></pre> <p><strong>Decomposing the person into individual key/value pairs (name="john") is easy.</strong></p> <p><strong>But in order to use the BerkeleyDB format to represent a Person, you would need some way of recomposing the person from its constituent key/value pairs.</strong></p> <p><strong>For that, you would need to impose some artificial encapsulating structure to hold a Person together as a unit.</strong></p> <p><strong>Is there a way to do this?</strong></p> <p>EDIT: As Robert Harvey's answer indicates, there is an entity persistence feature in the <a href="http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/model/Entity.html" rel="nofollow noreferrer">Java edition</a> of BerkeleyDB. Unfortunately because I will be connnecting to BerkeleyDB from a Ruby application using <a href="http://github.com/wycats/moneta/tree/master" rel="nofollow noreferrer">Moneta</a>, I will be using the <a href="http://www.oracle.com/technology/products/berkeley-db/db/index.html" rel="nofollow noreferrer">standard edition</a> which I believe requires me to create a custom solution in the absence of this support.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload