chapter two

2 Your first SQL query

 

Chapter 1 ended with a word about being immediately effective, and so this chapter aims to do just that. We’re going to start looking at some data as it might be stored in a relational database, and we’re going to examine the way that data is structured. Doing this will help you better understand some terms to describe the data, which we will use throughout the book. Don’t worry, though: You’ll see just a handful of terms, and they are all words you have seen and used in conversation. We are just defining them in the context of data stored in relational databases.

Additionally, we’ll get you started with your first query. In case you didn’t know, a query refers to any time you execute some SQL to retrieve data. As you can imagine, as you progress through this book, you’ll execute quite a lot of queries to level up your SQL skills. If you have not already completed the installations of MySQL and the MySQL Workbench, referred to in Chapter 1, as well as executed the Create_SQLNovel_database.sql script to create our sample database, please do this now so that you are ready to begin querying data.

Before we begin querying, let’s look at some data.

2.1 You know tables if you already know spreadsheets

2.2 Learning SQL is like taking an English class

2.3 Writing your first SQL query

2.4 Key terms and keywords

2.5 Lab

2.6 Lab answers