MySQL: Everything You Need To Know To Get Started

  1. Whether learning SQL is worth learning in 2022
  2. The basics of how SQL works
  3. SQL syntax
  4. Core Queries and Functions

What is SQL

SQL (Structured Query language) is a (perhaps the) database management programming language. Put simply, it’s a language that communicates with databases!

How Does SQL Work

If you are already familiar with databases, then maybe skip this bit!

Data Warehouses

A common way of thinking about databases is like warehouses filled with filing cabinets. Each warehouse is a database, each filing cabinet is a data table’, and each file contains the actual data.

What SQL is the language that the staff at the warehouse understand. If you can talk SQL you can retrieve, delete, update and add files to cabinets.

For example, you have a warehouse that stores files on every pet in your town. Each filing cabinet contains information on a different type of pet. If you want to find out the names of all the labradors in your town, you tell the staff:

Is SQL Relevant?

It’s a bit of a cop out, but it really does depend on who you are and what situation you are in. As a rule of thumb though, if you are going to be having anything to do with databases, at least a basic understanding of SQL is pretty much indispensable for a programmer. In 2021’s Stack Overflow’s developer survey, SQL ranked fourth in a list of the most popular programming languages.

Simplicity

The popularity and success of SQL is probably due to its simplicity. Compared to other languages, SQL is reasonably easy to learn, in fact, we cover the basics of SQL programming in this article!

It’s Everywhere!

Simplicity has led to ubiquity. Databases are a part of all sorts of software development and SQL and RDBMS is by far the most common means of managing data. No wonder then that having a knowledge of SQL is considered an essential skill for most developers.

Interoperability

SQL breeds interoperability. There are so many databases that are accessible through SQL, it means that there is a high level of interoperability between systems. Having said that, there are some differences between the syntax used by the big RDBMS systems. These variations are normally slight though.

Database Management Systems

The systems for managing managing systems are perhaps more responsible for perpetuating the popularity of SQL than the language itself. Tools like SQL Server and MS Access have fully realized the power of SQL, thus

SQL Just Works

SQL works and has worked for 4 decades. SQL solved the problem of database management- and has become synonymous with relational databases. If you think of “data”, you’re only one step away from SQL!

NoSQL Databases

The fact that the accepted term for non-relational, non-tabular database solutions has ‘SQL’ in it, speaks more convincingly of the importance and popularity of the language than anything else!

Is SQL Worth Learning in 2022?

Yes. Of course. Even if you are hoping to land a data science job at Netflix (who use a NoSQL solution) it would be odd indeed if you didn’t also know SQL. The reality is that SQL is still massively popular. Even if non-relational databases become the standard for big data, SQL will almost certainly still be the best solution for a huge portion of databases for decades to come.

Start Working With SQL Databases

Convinced that SQL is worth your time? Great! Now it’s time to dive in! Before we actually looking at a few lines of code- let’s remind ourselves of the basics:

  • Relational databases
  • Table
  • Rows
  • Columns

CRUD — Create, Read, Update, Update

Create Table

  • ‘CREATE TABLE’ is a clause. Clauses are in-built instructions that act like standardized clumps of code. The ‘CREATE TABLE’ clause creates a new table (surprisingly!)
  • ‘Dogs’ is the table name.
  • Lines 2,3,4 & 5 are all parameters. In the statement, the parameters specify the column names and the data type.

Insert Row

Select

Commands

Here, we will take a brief look at a few SQL keywords that are commonly used when querying databases.

  • As
  • And
  • Or
  • Distinct

Operators

The table sets out some of the common operators used in SQL. Bear in mind that not all operators will work with all data. Mathematical operators like ‘+’ will only work with numerical data, but some operators will work with both string and integer data.

Working With Multiple Tables

A single table database wouldn’t be much of a database! Afterall, you wouldn’t rent a warehouse to store one filing cabinet! Relational databases have tables that relate to each other.

  • This statement will return a combined table that will return all the columns and rows that match the conditions of the ‘JOIN.’
  • So, we are selecting all the columns (as indicated by the ‘*’ symbol) from our combined table.
  • The ‘JOIN’ clause says what table to combine the ‘Dogs’ table with.
  • Line 4 says what column to join with what column.
  • So this statement will link the two tables based on the pet_id.

Summary

That’s a bit of a crash course in SQL and you will undoubtedly need a lot of practice and additional research before you are fully proficient. However, as we have already discussed, the true success of SQL is its simplicity, and the topics covered in this guide truly are the main building blocks of working with relational databases professionally, albeit in a simple form. If you have understood the concepts, then you can build upon this knowledge. You can get to a professional standard, it just takes hard work and a love of data!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store