Search code examples
databaseredisrdbmskey-value-storeleveldb

How to convert an existing relational database to a key-value store?


I am trying to map a existing relational database to a key value store. Couple of example tables are represented below.

Example tables in the RDBMS Databse

For an instance the above "Employee Details" table can be represented as follows in Redis (or any similiar key-value store)

set emp_details.first_name.01 "John"
set emp_details.last_name.01 "Newman"
set emp_details.address.01 "New York"

set emp_details.first_name.02 "Michael"
set emp_details.last_name.02 "Clarke"
set emp_details.address.02 "Melbourne"

set emp_details.first_name.03 "Steve"
set emp_details.last_name.03 "Smith"
set emp_details.address.03 "Los Angeles"

The "Payments" table also can be represented as above. But this method does not build the one-to-many relationship between the "Employee Details" table and the "Payments" table. Therefore, is there any better way of implementing a key-value store from an existing RDBMS. You can refer to these two tables and suggest a better key schema to store values. Thanks in advance.


Solution

  • Nosql databases are basically aggregate stores. Relationships and its associated values are stored in a 'value' part of key - val design.

    Avoiding joins helps in better performance.

    Excellent llink on nosql modeling - https://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/