Member-only story
Create a Graph Database and API With PostgreSQL and Node.js
Harness the power of JSON and table partitioning in PostgreSQL

Yes, you read it right, whenever we hear “SQL” the first concepts that come up in our minds are Relational Database, Foreign Keys, Table Management, everything we learned in our early computer science days… And we would be right, reason being is that SQL was designed to manage relational databases, where each of the Data Abstractions will be represented by tables, and the relations between these tables will be enforced by Foreign Key Constraints such as One to One, One to Many or Many to Many.
While this structure has been time-proven, it won’t work well for some projects or applications. Let’s suppose we are working on a Social Media project. How would we model that in a Relational paradigm?
Person (id, name, email, ...) /* Table for a Person */PersonFriends (id_1, id_2) /* N-N relation for Friends */
Each time a Person
adds a friend
, the relation would be added into PersonFriends
table twice, because this relation is bi-directional. Let's suppose we have two people in our database, Nick
and Melissa
, with ids of 1
and 2
respectively, to create a relation between them we will have to run this SQL statement: