052 - Relational Databases Intro

16 Jan, 2018

Working with data is one of the most important aspects of development. This week I got an intro to relational databases, and here’s what I learned.

As we all know, a database is where we store data…what makes it relational is the method we use to store it: information is stored in tables, and then we relate those tables to each other by referencing unique id numbers from one table to the next. To interact with the data, we use a relational database management system (RDBMS) like MySQL, PostgreSQL, MariaDB, etc.

Another option for storing data is to use a non-relational database like MongoDB or Neo4j which takes a less rigid approach to how and where data can be stored. These are also sometimes called NoSQL (not only SQL) databases and they provide flexibility when the data you’re working with vary a lot in structure and content. However when the information is uniform, relational databases can be very efficient because there is not a lot of repetition, and you can easily access exactly the information you need with SQL, when you need it.

With an RDBMS like MySQL, you can write queries to do everything from basic CRUD commands (create - read - update - delete/destroy) to refining searches and aggregating information. Using these queries and commands not only allows you to determine what information is displayed in your application, but it can also help with marketing decision, business development, advertising and much more.

One correction—when I gave the Instagram example, I said that you would have a table for users, and then a table for “that user’s photos” and so on. I meant to say you would have a table for ALL photos—it would not be a table for each user. You then link a user id to the photos table to show which user that photo belongs to. Sorry I misspoke!

If you have some tips on how to practice woking with a database, leave a comment below or tweet me @startovercoder.