How would one build a relational database on a key-value store, a-la Berkeley DB's SQL interface?
I've been checking out Berkeley DB and was impressed to find that it supported a SQL interface that is "nearly identical" to SQLite.

http://docs.oracle.com/cd/E17076_02/html/bdb-sql/dbsqlbasics.html#identicalusage

I'm very curious, at a high-level, how this kind of interface might have been architected.  For instance:

- since values are "transparent", how do you efficiently query and sort by value
- how are limits and offsets performed efficiently on large result sets
- how would the keys be structured and serialized for good average-case performance
How would one build a relational database on a key-value store, a-la Berkeley DB's SQL interface?
===

I've been checking out Berkeley DB and was impressed to find that it supported a SQL interface that is "nearly identical" to SQLite.

http://docs.oracle.com/cd/E17076_02/html/bdb-sql/dbsqlbasics.html#identicalusage

I'm very curious, at a high-level, how this kind of interface might have been architected.  For instance:

- since values are "transparent", how do you efficiently query and sort by value
- how are limits and offsets performed efficiently on large result sets
- how would the keys be structured and serialized for good average-case performance