A second pass at comprehending data storage theory.
I recently had the opportunity to take some time and review a lesson of my choosing. We also recently dove into data modeling and application data storage theory. This topic is something that I find a ton of value in, but by being a not-so-organized person, I also have a hard time comprehending the topics at hand.
What is the difference between a relational and non-relational database?
Relational databases store data in tables and rows with each table being connected by a primary key. This structure is known as a schema, and data types for each row are defined in this schema. For example: If I were to create a database that would keep track of journals that a user wrote in. A) A user could have many journals. B) Journals could have many entries. A journal entry would be connected to a journal by a journal ID. Likewise, a journal would be connected to a user by a user ID. We’ve recently utilized this by creating APIs using a PostgreSQL database.
In contrast, non-relational databases store data without having to follow the structure of tables and rows. These types of databases are meant to handle data that doesn’t conform to a structured schema. It also allows for data types to vary. We had used this type of model when working with Firebase, which stores data as a nested JSON object. With this model, our previous example would not be tied by a primary key. Instead, our user would have a value of a journal, which would then have a value of readings.
When we first learned about how to persist data in our applications, we did so with localStorage. This allowed users to set items in storage to be retrieved in the browser at a later date. This is also an example of a non-relational database as we stored values as a key-value store. At the time that we learned this, we were making very small to-do list applications and only needed to store a minimal amount of values. localStorage worked well for this because it was simple, synchronous, and the events that are called on the localStorage API were semantic.
What do I have a better understanding of now that you have reviewed for a second time?
After my second pass at this lesson, I feel that I have a better understanding of the differences between relational and non-relational databases. I also have a greater appreciation for the way that we evolved from learning to store data in web storage with localStorage to learning how to store data in a more complex non-relational database via Firebase, and lastly creating a full-fledged relational database.