Schemaless SQL database for strong and lasting back end

Benefits of the solution

  • Schemaless structures maintain in the code
  • Your documents stored as relational tables transparently
  • Performance and efficiency of relational database
  • Easier to maintain in the long term
  • Consume much fewer resources (cheaper in the cloud)

Examples

Single document - code side

var doc = {
         email: "[email protected]",
         firstname: "Dwain",
         lastname: "Jonhson",
         username: "dwainjonhson"
  };
  doc.save();

  collection("users").find({username: "dwainjonhson"});

  /*
      {
         trid : 2,   // auto id generation
         email: "[email protected]",
         firstname: "Dwain",
         lastname: "Jonhson",
         username: "dwainjonhson"
      }
  */

Single document - Database side

> select * from users;

TRID   EMAIL                       FIRST_NAME     LAST_NAME     USERNAME
------ --------------------------- -------------- ------------- --------------
     2 dwain.jonhson@gmail.com     Dwain          Jonhson       dwainjonhson

Nested documents - code side

var doc = {
         email: "[email protected]",
         firstname: "Dwain",
         lastname: "Jonhson",
         username: "dwainjonhson",
         phones: [{
           alias: "home",
           number: "+1-202-555-0143" 
         },{
           alias: "mobile",
           number: "+1-202-555-0156" 
         }]
  };
  doc.save();

  collection("users").find({username: "dwainjonhson"});

  /*
      {
         trid : 2,   // auto id generation
         email: "[email protected]",
         firstname: "Dwain",
         lastname: "Jonhson",
         username: "dwainjonhson"
         phones: [{
           trid : 1,   // auto id generation
           alias: "home",
           number: "+1-202-555-0143" 
         },{
           trid : 2,    // auto id generation
           alias: "mobile",
           number: "+1-202-555-0156" 
         }]
      }
  */

Nested documents - database side

> select * from users;

TRID   EMAIL                       FIRST_NAME     LAST_NAME     USERNAME
------ --------------------------- -------------- ------------- --------------
     2 dwain.jonhson@gmail.com     Dwain          Jonhson       dwainjonhson

-- Nested phone documents automatically organized in table with the proper relationship.
> select * from users_phones;

TRID   USERD_TRID   ALIAS             NUMBER
----------- ----------- ----------------- ------------------------
     1           2 home              +1-202-555-0143
     2           2 mobile            +1-202-555-0156

Conclusion

Push your document in the database without any worries about restructuring them later. Made all the modifications that you didn't predict because wasn't part of the initial requirements. And do this afterward with the comfort of SQL. Finally, reduce the cloud cost due to the resource consumption involved with traditional NoSQL databases.

This concept allows you to code fast with your data objects as documents (like Mongodb) while benefiting transparently from the relational databases (like PostgreSQL) .

Any questions? Please comment below :)

19