Day 91 MySQL & Mongoose Databases

Today’s topic was about databases and this starts with a conceptual aside. First of all a relational database are tables of data related to each other as the name suggests. By breaking apart each part of the data it is easier to call it without repeating. An example would be having a person object name and name:value pair of first and last name

SQL stands for sequence query language and is a language designed for managing data. MySQL is an open sourced SQL database which we installed from NPM. Then I required it into the app and put it in the middleware like so.

The powerful feature of this is that fact that MySQL returns data from a table, which is essentially an array of JavaScript objects. Because of this we are able to manipulate the data from the database like how we would with JavaScript objects.

Before the issue with databases was the repetitiveness of data which is why they were set up in tables to save hard drive space. However, hard drive space is not much of an issue anymore.

NoSQL is a variety of technologies that are alternatives to tables and SQL. It removes the table concept completely and one of those databases is MongoDB for documents. Documents are similar to JavaScript objects as well and can be called like one.

Just like what I did with MySQL first thing I did with Mongoose was install it and require it to the file. As shown below.

After installing and requiring Mongoose the next step was to create a schema. A schema is where all of the data lives on mongoose. Schemas are similar to function constructors and also have methods like .save.

Documents are much more powerful than tables since they are more flexible with data. Every piece of data is separate and able to have different properties like a JavaScript object. This is powerful because each piece of information doesn’t have to have the same type of data for each name:value pair.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Up ↑

%d bloggers like this: