Home » Programming » Databases » Is PostgreSQL an SQL or NoSQL Database?

Is PostgreSQL an SQL or NoSQL Database?

A common question is whether PostgreSQL is an SQL or NoSQL database (it’s not) – this article explains why.

What is SQL

SQL (pronounced sequel or S-Q-L) is the Structured Query Language – a language used by many relational database systems for querying data. It is also increasingly being used for defining data schemas in data analytics applications where the data is not stored in a database but is arriving as a data stream.

Data defined and queried by SQL is structured tables that can have relationships between records – for example you may have a table representing a person that records, their name and age, and a table for pets, that stores a pets name and a reference to who owns them from the person table. No additional data can be added other than what is defined by the tables columns, so all records in a table are consistent.

What is NoSQL

NoSQL (Non-SQL), on the other hand, focusses on unstructured or semi-structured data.

Data is not restricted to a pre-defined list of tabulated columns and relationships are not enforced. Rather than storing data in tables, collections are used, to differentiate them from SQL’s tables. Within a collection, any data can be stored in a document (The equivelant of an SQL table row or record). Documents do not have to be consistent within collections – some data can be included in some that is not in others. This makes NoSQL incredibly flexible when storing data, as it does not have to be homogenized, however this lack of consistency can make querying difficult.

NoSQL databases can however often be queried using an SQL-like syntax, but this ability does not make them SQL databases.

What is PostgreSQL

PostgreSQL is an SQL database by definition, so it is definitely not a NoSQL Database. PostgreSQL is an object-relational database that implements tables with a rigid structure, queryable with SQL syntax. Complex table relations are supported, again making it, definitely, not a NoSQL database.

Photo of author
I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Comment