LMDB is a key-value store. What types of keys and values can be stored here? Examples shows either int
or char arrays
.. Also I would like to know if it is possible to store related data in lmdb
like we store all data related to a student in a table
in RDBMS
相关问题
- Filter ldapsearch with awk/bash
- MongoDB: groupby subdocument and count + add total
- Does using non-SQL databases obviate the need for
- Querying with “contains” on a list of user defined
- How to create “trigger” in MongoDB
相关文章
- Can't get deleted items from OpenLDAP Server u
- How does Cassandra scale horizontally ?
- Modelling a Chat like Application in Firebase
- NoSQL Injection? (PHP->phpcassa->Cassandra)
- Connect Parse with external database?
- Does using NoSQL make sense for a non-distributed
- How to query nested keys in Riak?
- (Non-Relational) DBMS Design Resource
It sounds like you're not a C programmer, but in the context of the C language, the data for keys and values in LMDB are both (void *) - that is, generic pointers to anything. That means any data type that can be expressed in the programming language can be used. In other languages, through whatever bindings are provided, your options may be more limited.
LMDB doesn't care what you store, all it sees are blobs. Obviously it is not an RDBMS. If you want to store structured data, you need to manage that structure yourself. You could take a complex data structure and serialize it into a blob, and store it under a single key. This is the approach used in OpenLDAP's slapd. Or, you could setup individual columns of your data as separate named DBs in LMDB and store individual values in their respective DBs. (For example, indices in OpenLDAP and SQLite/SQLightning are handled this way.) So yes, while LMDB does not provide any functions for managing relations itself, you can certainly use it as the backing store of an RDBMS if you want to. (Again, see SQLightning for example. Backends for MySQL/MariaDB or Postgres are doable as well, but involve a lot more glue code between their frontends and the LMDB API.)
Both keys and data can contain any combination of zero or more bytes.
So your data blobs could be comma-separated text strings, JSON or some form of packet binary data (like flatbuffers).
It also means you must invest own work if you want to add multiple keys to locate the same data or if you want to store multiple types of data similar to multiple tables in a RMDB.
One simple way to store data could be like:
The above data would allow the users to be iterated on insertion order (id) by using the
users;<id>
keys. Or by age using theborn;<date>;<id>
keys.Iterating through
students;<teacher-id>;<student-id>
with teacher-id = 2 would give the id of all students mapped to user "benny".Iterating through
teachers;<student-id>;<teacher-id>
with student-id = 4 would give the id of all teachers for user "sue".Instead of using key prefixes for different type of data, it's also possible to create multiple key/value databases in LMDB.