No-SQL has been an evolving norm these days. With plethora of data growing and multiplying day-by-day at an exponential rate, everyone is faced with a challenge to live-up to the new evolving standards for applications, grid computation, analytics, high-availability, fast responding user interfaces, etc.
One of the primary steps in migrating from the traditional RDBMS system to NO-SQL system is to come-up with new table design. Ironically, there is no direct mechanism that converts traditional RDBMS database schema to a NO-SQL table structure.
While RDBMS based systems evolve from a centralized database design to user interface development, newer No-SQL systems need to be designed based on the developing user interface and the queries needed for connecting the user interface together screen-by-screen one at a time.
There is however a small correlation on how the RDBMS table data can be represented in No-SQL table structure based on the mappings.
Example 1 : A one-to-one mapping of our traditional RDBMS table design will result in the following No-SQL design.
*****RDBMS Design****
Customer
----------------
Customer_id int,
first_name varchar,
last_name varchar,
email_id varchar
CustomerAddress
----------------------
Customer_id int,
Street_addr varchar,
apt varchar,
city varchar,
state varchar,
country varchar
pin varchar
******No-SQL Design******
Eliminate two tables and merge the columns into one table per customer_id
Customer
-----------
Customer_id int,
first_name varchar,
last_name varchar,
email_id varchar,
Street_addr varchar,
apt varchar,
......
Example 2 : A many-to-one and one-to-many mapping of our traditional RDBMS table design will result in the following No-SQL design
****RDBMS Design*****
--------------------------
Customer
---------------
Customer_id int,
first_name varchar,
last_name varchar,
....
CustomerPhone
--------------------
Customer_id int,
Phone_type varchar, //mobile, home, office
Phone_number varchar
****** No-SQL Design *****
-------------------------------
CustomerByPhoneNumber
------------------------
Customer_id int,
Phone_type varchar,
Phone_number varchar,
PRIMARY KEY (Phone_number)
PhoneByCustomerId
---------------------------
Customer_id int,
Phone_type varchar,
Phone_number varchar,
PRIMARY KEY (Customer_id)
Example 3 : Many-to-Many
--------------------------------
Many-to-Many in NoSQL is nothing but iteration of one-to-many and many-to-one queries and consolidating the result set.
In the above example, if you want to get list of all customers and all their phone numbers, you would have to perform two queries and iterate over to get complete set.