Better Programming

Advice for programmers.

Follow publication

Member-only story

Create a Graph Database and API With PostgreSQL and Node.js

Nick Pashkov
Better Programming
Published in
10 min readOct 3, 2021
Photo by Alina Grubnyak on Unsplash

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:

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Nick Pashkov
Nick Pashkov

Written by Nick Pashkov

Data Engineer, Full-Stack dev

Write a response