Data Modeling: Non-relational Databases(NoSQL)

Non-Relational Databases, NoSQL, and why you might want to learn about these!

The Code on the Street
Learning SQL
5 min readMay 2, 2022

--

Previously we covered why data modeling is important and the importance of a relational database, but what about non-relational databases or NoSQL databases? NoSQL was originally meant as No SQL, then was changed to “not only SQL” to show it was SQL compatible. Non-relational databases are just as widely used as their relational counterparts, however their use-case is different. In this article we’ll cover what non-relational databases are, the different types, potential use-cases, advantages, and when it’s not ideal to use them.

Image by Gabriel Sollman from Unsplash

Table of Contents:

  • Intro to Non-Relational Databases.
  • Types of NoSQL Databases.
  • Advantages of a Non-Relational Database.
  • When Not to Use a Non-Relational Data Model.
  • Common Non-Relational Databases.
  • Conclusion.

Intro to Non-Relational Databases:

Non-relational databases are a great tool when dealing with unstructured data. By “unstructured data” I mean, virtually anything; not just text data. It could be images, audio, sensor data, videos, and much more! There is no easily identifiable predefined data model.

Non-relational databases were built to handle the limitations of relational databases. They are able to handle MASSIVE amounts of data, ease-ability into horizontal scaling, high throughput(fast read and write speeds), flexible schemas(meaning they can alter schema structure and allow flexible column sets for each row), high data availability, being able to store different types of data formats(text, audio, image, etc…), and minimize latency between distributed users. If your users are geographically located in different areas all over the world, this type of database ensures low latency between executing a query and receiving the results.

Types of NoSQL Databases:

  • Key/Value Storage:
    — Data being stored in key-value pairs.
    — Each key is unique has a value assigned to it.
    — The value can be in various types of formats, json, xml, string, csv, xlsx, audio, video etc…
    — Fast query performance.
    — Can be used for storing session information, user specific preferences, shopping cart data, product recommendations.
  • Document Storage:
    — Can be considered as an extension of the key/value storage system.
    — Values are stored in structured document formats like xml, json.
    — Does not support entity based relationships.
    — Allows for values to be in different formats.
    — You can query by more than just the unique key, you can query by attribute.
    — No foreign keys.
    —Great for user profiles, content storage.
  • Wide Column Data Storage/Column Family Storage:
    — Finds the common ground between a relational databases storage system and a key/value pairs storage system.
    — Stores data tables in sections based on a columnar format rather than row storage like a RDBMS.
    — Each row is associated with many columns of data and is identifiable by using the row key.
    — Endorses using columnar families. Which are groups of related columns being accessed together.
    — Highly flexible.
    — Supports semi-structured data.
    — Great for storing user preferences, reporting systems, managing data warehouses.
Image by Author

Columnar Family Storage:

Image by Author
  • Graph Databases:
    — Used for storing graph oriented data structures.
    — Where each node points to an adjacent node.
    — Doesn’t require indexing for lookups.
    — As the number of nodes continue to grow, cost of going from node to node remain the same(No performance inefficiencies).
    — Great for traversing through connected data (like friends on social media, account data for businesses, location data for maps.
Image by Author

When NOT to Use a Non-Relational Database:

  • Having small datasets.
  • ACID Transactions.
  • Need the ability of joining tables.
  • Trying to aggregate and analyze data.
  • If your business requirements are changing which would cause your queries to change. NoSQL queries are pretty fixed.

Common Non-Relational Databases:

Different NoSQL databases have different use cases, and implementations.

  • Apache Cassandra:
    -Can partition row storage.
    -Distribute data in partitions across nodes/servers.
    -Data organized in column/row format.
  • Amazon DynamoDB:
    -Data is represented as a key/value pair.
  • Apache Hbase:
    -Offers wide column storage.
    -Uses tables, rows, columns.
    -Name and format of columns can change between rows in the same table(flexible schema).
  • Neo4J:
    -Graphical database.
    -Focuses on relationship between entities.
    -Uses nodes and edges to represent the data.
  • MongoDB:
    -Data is stored as documents.
    -Uses key/value lookups.
    -Retrieves documents based on contents through a API/query language.
    -Allows ACID transactions.

Conclusion:

In the world of big data, NoSQL serves as a great tool for storing files as opposed to its relational counterpart, where you would need to load data from your .csv files into your tables. Unlike relational databases, there are various types of non-relational databases with their own unique use cases. Non-relational databases share the common theme of being scalable, providing consistency, having less complex queries, and handling massive amounts of data.

Go from SELECT * to interview-worthy project. Get our free 5-page guide.

--

--

The Code on the Street
Learning SQL

Data Engineer | Tech Enthusiast | Gamer | Hiker | Lifetime Student of Data | Mediumster| Technical Content: Codeots.com