---
title: "Dev Discussions: SQL vs NoSQL with James Quick of PlanetScale | CoderPad"
description: "James Quick of PlanetScale highlights some important differences between SQL and NoSQL databases, and when to use each one."
canonical: "https://coderpad.io/blog/development/sql-vs-nosql-with-james-quick/"
last_modified: "2023-06-05 14:35:03"
---
[Back to blog](https://coderpad.io/blog/)

# Dev Discussions: SQL vs NoSQL with James Quick of PlanetScale

April 8, 2022 4 Minute Read

By Ken Swearengen

[Development](https://coderpad.io/blog/development/)

We recently shared [some excellent job advice](https://coderpad.io/blog/getting-hired/dev-discussions-how-to-get-a-great-job-james-quick/) from YouTuber and Developer Advocate James Quick.

But Corbin and James’ conversation didn’t end with that – they also covered some great information about the differences between SQL and NoSQL and how to choose the proper database for your particular use case.

## Need a better way to interview candidates? Try CoderPad.

[Get a demo](https://coderpad.io/demo/)

## The difference between relational and non-relational databases

Developers have traditionally stored data in the form of a series of tables that relate to one another through a combination of primary and foreign keys – also known as relational databases. The main way we interact with relational databases is through Structured Query Language (SQL).

For example, two relational database tables might look like this:

hero_table:

name | superpower
Flash | Really fast
Storm | Controls weather

villain_table:

name | superpower
Magneto | Great with magnets
Bellatrix Lestrange | Powerful witch

A SQL statement to merge two tables would look something like this.

```
SELECT name, superpower FROM hero_table
UNION
SELECT name, superpower FROM villain_table;
```

SQL and relational databases work great when you have structured and orderly data. However, as data capturing has increased on such a massive scale – think of the terabytes of real-time data captured on users cruising the internet every day – issues with scaling and tracking data that don’t have a consistent structure have become rampant.

Enter Not Only SQL (NoSQL) and non-relational databases. Instead of using tables consisting of rows and columns to store data, a non-relational database generally uses a JSON object stored with similar objects in a collection. All relationships between collections are informal.

So rather than having a bunch of different tables that need to link to one another, you can store all the information you need in the collection of objects. So our superheroes and villains data collection might look like this:

```
[{
		"name": "Flash",
		"superpower": "really fast",
		"type": "hero"
	},
	{
		"name": "Storm",
		"superpower": "Controls weather",
		"type": "hero"
	},
	{
		"name": "Magneto",
		"superpower": "Great with magnets",
		"type": "villain"
	},
	{
		"name": "Bellatrix Lestrange",
		"superpower": "Powerful witch",
		"type": "villain"
	}
]
Code language: JSON / JSON with Comments (json)
```

The actual syntax of the NoSQL queries you make to a NoSQL database will depend on the database provider. For example, if you were using MongoDB, you’d use this query to list all the objects from your “supernatural characters” collection:

```
db.supernatural_characters.find()Code language: CSS (css)
```

So when should you use one and not the other?

## SQL vs NoSQL? It depends on the data

As we mentioned earlier, SQL is great if you have lots of structured data that won’t have too many regular schema or column changes.

An excellent example of structured data is a database that tracks baseball statistics. Generally, you’ll always have a player table with a player name, team name, homeruns, at bats etc–as well as a number of calculated averages like batting average and earned run average. You’ll also probably have a team table with the team’s name, team home runs, location, etc.

There is a risk to having data structured like this, however – if you have a set of data that regularly has empty or null values for specific fields (e.g., a calculated field like batting average for a year when a player was out on injury), then you’re unnecessarily increasing your disk space, storage costs, and data retrieval time because the database has to store and recall those empty fields.

NoSQL objects can contain whatever you want –or don’t want – them to have. For that reason, NoSQL databases can be a bit more performant than SQL databases when it comes to reading data.

You may want to use NoSQL over SQL if you need to scale your data across many machines horizontally.

Horizontal scaling allows you to spread processing power across multiple machines, increasing the speed of your [CRUD operations](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete). Because of the way relational databases are designed, it’s challenging to get them spread across multiple processing nodes.

On the flip side, NoSQL databases can fall apart if a data access pattern changes since there is no way to enforce schemas and relationships like there is with SQL databases. Without carefully managing what data gets logged and where, then it’s very easy to make a mess of the data.

For example, you could have a collection that tracks user demographics like their name, location, and age.

After three years the product pivots to track health data for users and stops tracking demographic data, so now the product is collecting height, weight, and birth date in the same user collection.

A month after that the product owner decides they want the birthday collected as a UTC string instead of a normal date string.

Now you have not only a collection with two different schemas (demographics and health info), but you have a field (birthday) that has two different data types. This can cause lots of processing issues and is one of the reasons you may want to have the schema-enforcement that SQL provides.

## The Power of Object-Relational Mapping (ORM)

James dove into object-relational mapping (ORM) towards the end of the database discussion.

If you’re unfamiliar with ORM, it’s a way for developers to interact with both relational and non-relational databases that doesn’t involve generating complex SQL statements – or any SQL at all.

ORMs are an abstraction layer that sits above a database and takes human-readable function calls and translates them into SQL or NoSQL. This is a considerable advantage to developers as it reduces errors from having to write complex queries and the same function definitions can be used to manage multiple different databases.

Here’s what it would look like to insert a row into a relational database with Prisma, an ORM for JavaScript:

```
2  await prisma.user.create({
3    data: {
4      name: 'Alice',
5      email: ' [[email protected]](mailto:alice@prisma.io)',
6      posts: {
7        create: { title: 'Hello World' },
8      },
9      profile: {
10        create: { bio: 'I like turtles' },
11      },
12    },
13  })
Code language: JavaScript (javascript)
```

You can find an ORM for just about every language; Hibernate is a popular one for Java, and Django ORM is often used with Python.

## Serverless computing, horizontal scaling SQL with PlanetScale

James discusses more or his database knowledge with Corbin along with a brief introduction to serverless computing.

You can find those conversations in the [Twitch replay video here](https://www.twitch.tv/videos/1425572449?t=0h0m1s).

## Subscribe for more CoderPad insights

## Trending Articles

Previous slide Next slide [Development

## What is Prompt Engineering?

Introducing AI tools such as ChatGPT and Bard helps increase the efficiency of tasks such as data generation, code generation and completion, text summarization, etc. How were these AI tools trained to answer almost every question you ask them? The answer, prompt engineering, is discussed in this blog post.

Read the post](https://coderpad.io/blog/development/what-is-prompt-engineering/) [Development

## A Guide To Using React’s useCallback() Hook

Are you looking to optimize your React applications? Have you heard of the useCallback hook? useCallback is a powerful React hook that helps you optimize your application by preventing unnecessary re-renders. In this post, we'll dive into React's useCallback() hook, define referential equality and callback functions and how to tie it all together.

Read the post](https://coderpad.io/blog/development/a-guide-to-using-reacts-usecallback-hook/) [Development

## MySQL vs. PostgreSQL: How Do They Compare?

A database is a convenient tool that allows users to access information, maintain records, and apply commonly used operations, such as insertion, modification, deletion, and data organization. Learn about MySQL vs PostgreSQL, their features, advantages, and disadvantages. Finally, check out which one is the best choice for you.

Read the post](https://coderpad.io/blog/development/mysql-vs-postgresql-how-do-they-compare/) [Development

## PostgreSQL LIKE Operator: A Detailed Guide

When using databases, searching for values that match a given pattern is a familiar necessity. Learn how you can retrieve entries with queries including a particular string using Postgres LIKE operator.

Read the post](https://coderpad.io/blog/development/postgresql-like-operator-a-detailed-guide/) [Development

## How To Use DataProvider In TestNG With Examples

When it comes to testing there are many tools and techniques available. In this post, we'll discuss how to use DataProvider with TestNG.

Read the post](https://coderpad.io/blog/development/how-to-use-dataprovider-in-testng-with-examples/) [Development

## How To Get Up And Running With Django Migrations: A Guide

Django migrations are a way of handling the application of changes to a database schema. By following the steps outlined in this guide, you can easily set up and use migrations in your Django projects.

Read the post](https://coderpad.io/blog/development/how-to-get-up-and-running-with-django-migrations-a-guide/) [Development

## Writing A Parameterized Test In JUnit With Examples

A JUnit parameterized test allows you to decouple data from structure, generating cleaner and more reliable tests. Learn more in this guide.

Read the post](https://coderpad.io/blog/development/writing-a-parameterized-test-in-junit-with-examples/) [Development

## How To Use Assert In JUnit With Examples

The JUnit Assert class is what you use to write unit testing assertions in JUnit. Learn more about it in this guide, full of examples.

Read the post](https://coderpad.io/blog/development/how-to-use-assert-in-junit-with-examples/) [Development

## A Simple Guide To TypeORM: What It Is And How To Use It

Considering current languages have object-oriented programming features, most database management systems are based on the relational model, with tables instead of objects. For these reasons, mapping relational objects is very important in development. In this article, you will learn what TypeORM, one of the main tools used today, is.

Read the post](https://coderpad.io/blog/development/a-simple-guide-to-typeorm-what-it-is-and-how-to-use-it/) [Development

## Using PreparedStatement in JDBC With Examples

In this post, we'll see why and how to work with JDBC and PreparedStatement. We will also learn along with examples using code.

Read the post](https://coderpad.io/blog/development/using-preparedstatement-in-jdbc-with-examples/) [Development

## React vs React Native: The Differences Explained

React and React Native are similar in that they both allow web developers to build applications based on the unique concept of components. But the two frameworks do this in radically different ways. In this post, we cover the key differences between react and react native frameworks, implementation, and which is an appropriate choice.

Read the post](https://coderpad.io/blog/development/react-vs-react-native-the-differences-explained/) [Development

## Logging in Django

The most challenging part of fixing a problem is identifying it. Unfortunately, this statement is exceptionally true when it comes to debugging. Learn how to use the power of logging into your Django applications to improve your debug process in this article.

Read the post](https://coderpad.io/blog/development/logging-in-django/)

## Hire with confidence.

See why engineering teams trust CoderPad to evaluate developers with realistic, AI-ready hiring workflows.

[Request a demo](https://coderpad.io/sales/)
