3. How data is stored inside SQL database

We’re one step away from writing our first SQL query and diving into Bindle’s story! Before we start let’s go through the basic SQL vocabulary.

The data in a SQL database is stored in a collection of tables.

Each table is basically a spreadsheet with columns and rows. Each column in a SQL table has its own name, for example, id, first_name, signup_date, country, etc. I’m pretty sure you’ve seen id column in Google Spreadsheets, but the difference with SQL tables is that columns in a SQL table could have any name or value. Some tables don’t have id column with a number. For example, we might have countries table with columns name and code. We’ll see all sorts of tables throughout the course 🚀

Data types

Inside one SQL table, we can store completely different types of data – numbers, text, coordinates, IP addresses, names, even images. Tables in SQL don’t have a specific type, but columns do ⚠. Within each column, values could be either empty (known as NULL values) or belong to a certain type, like only numbers (integers or float) or only text.

Here’s a list of the most popular data types:

  • numbers (integers like 1, 2, 99 and floats like 1.0, 3.1415926…)
  • string (first_name Mike)
  • text (when strings are usually limited to 255 characters text columns are able to hold lot’s of text, all chapters of a book for example)
  • NULL is a special value that means there is no actual value
  • boolean (such columns could have only 3 values: NULL, TRUE or FALSE. For example, is_customer could be such a column)
  • date (for example 2019-08-05)
  • datetime (basically a date with a specific time, like 2019-08-05 10:08:15 +0200)

Later in the course, we’ll learn how to work with each type and learn more types of course. For now, let’s just remember that columns have types and these types determine what kind of values are expected to be stored there.

We’re ready to start the course. LET’S GOOOO 🚀

Anatoli Makarevich, author of SQL Habit About SQL Habit

Hi, it’s Anatoli, the author of SQL Habit. 👋

SQL Habit is a course (or, as some of the students say, “business simulator”). It’s based on a story of a fictional startup called Bindle. You’ll play a role of their Data Analyst 📊 and solve real-life challenges from Business, Marketing, and Product Management.

SQL Habit course is made of bite-sized lessons (you’re looking at one atm) and exercises. They always have a real-life setting and detailed explanations. You can immediately apply everything you’ve learned at work. 🚀

“well worth the money”

Fluent in SQL in a month

Master Data Analysis with SQL with real life examples from Product Management, Marketing, Finance and more.
-- Type your query here, for example this one -- lists all records from users table: SELECT * FROM users
Loading chart... ⏳