SQL


Web Development

Updated May 11th, 2021

Relational databases using SQL are king. In fireship poll nearly 2/3 or 63% of his viewers and say their go-to database and starting a new project is SQL either mySQL or postgres, (document style meaning firestore or Mongo was 31%).

I ask you all powers WordPress Twitter Shopify Airbnb.

50 years ago Ted codd writes a paper a relational model of data for large shared data banks published in 1970. In the paper he lays out how a relational model can reduce duplication and redundancy.

Developers using relational databases don’t actually write SQL. To use libraries that perform object relational mapping which are tools that allow you to work with relational databases using the object-oriented programming language of your choice. J’s has sequelize. Python has SQL alchemy. This makes it so you never have to touch raw SQL code. This can be great most of the time for productivity but learning how raw SQL works will help you understand some of the magic that an ORM does under the hood.

Hey RDMBS is comprised of two things The database itself which is a collection of tables and each table you have actual data organized and columns and rows. The second thing is the language used to manipulate and read data in the database, which is most often a version of SQL.

I’m going to use a tool called drawSQL.app to help visual and model out your project. Database schema which is the blueprint that defines a different rules or constraints within the database.

Relationships can be one to one or one to many.

There are many different data types such as char date date time decimal double enum float and JSON, etc. For the most part they just represent different types of numbers and strengths.

Calms may have special constraints like unique not know primary key enum.

Very little duplication because every table is its own entity which means that the room’s table doesn’t need to store any information about the user just the reference to the user ID. We call this the normalized data structure because every entity is organized into its smallest normal form.

Install SQL on Windows there’s an installer on the website and you’re going to need the server only option to get mySQL server. Default options are fine and then you should have access to the MySQL command from the command line. To access mysql from the command line you’ll type mysql with the u flag which stands for username (Note this is probably root) and then also add flag P if you used a password. First thing you don’t want to do is create a database by executing create database and all caps followed by the database name.

Verify was created by using command show databases in caps. You can do this all in the command line but it’s better to download the SQL tools vs code extension by Mattheus Texeira That allows you to store connection details visualize a database and view a history of all the queries that you’ve run.

I’m going to skip over the rest of this but 6 minutes into the video Learn SQL in 23 easy steps.