Joe Lin
Joe Lin

Reputation: 496

What is the best practice of SQL Database table analogy in RocksDB

In a SQL database, we generally have related information stored in different tables in a database. From what I read from RocksDB document, there's really no clear or 'right' way to represent this kind of structure. So I'm wondering what is the practice to categorize information?

Say I have three types of information, Customer, Product, and Employee. And I want to implement these in RocksDB. Should I use prefix of the key, different column families, or different databases?

Thanks for any suggestion.

Upvotes: 5

Views: 1231

Answers (2)

amirouche
amirouche

Reputation: 7873

The way data is organized in key-value store is up the the implementation. There is no "one good way to go" it depends on the underlying key-value store features (is it key ordered in particular).

The same normalization/denormalization technics applies.

I think the piece you are missing about key-value store application design is the concept of key composition. Quickly, is the practice of building keys in such a way that they are amenable to querying. If the database is ordered then it will also also for prefix/range/scan queries and next/previous navigation. This will lead you to build key prefixes in such a way that querying is fast ie. that doesn't require a full table scan.

Expand your research to other key value stores like bsddb or leveldb here on Stack Overflow.

Upvotes: 1

ren
ren

Reputation: 3993

You can do it by coming up with some prefix which will mean such table, such column, such id. You could for simplicity store in one column family and definetely in one db since you have atomic operations, snapshots and so on. The better question why would you want to store relational data in nosql db unless you are building something higher level. By the way, checkout linqdb which is an example of higher-level db where you can store entities, perform linq-style operations and it uses rocksdb underneath.

Upvotes: 2

Related Questions