DevLearningTools

LEARN · SQL

SQL Introduction

SQL is the language you use to ask a database for data, or to change it. Learn how a relational database organizes data into tables, and why SQL and MySQL aren't the same thing.

It's your first week as a junior developer at Beacon Robotics, a small company building warehouse robots. Your manager walks over: "Can you pull up every employee in the Engineering team earning over 90,000, we're planning next quarter's budget." The company's employee records live in a database. The only way to actually answer that question is to ask the database directly, in its own language. That language is SQL, and this course follows you through learning it, one real task at a time, using Beacon Robotics' own data the whole way through.

Why Not Just Open a Spreadsheet?

Beacon Robotics has 40,000 employee records across its history, not 40. A spreadsheet would take real time to scroll and filter by hand, and that's before combining it with department budgets, project assignments, or anything else stored separately. A database stores exactly this kind of large, structured, interconnected data efficiently, and SQL is how you ask it precise questions and get an exact answer back in milliseconds, instead of scrolling.

Learning Objectives

  • Explain what a relational database stores data in, and why that shape makes SQL possible.
  • Describe where SQL sits between an application and its data.
  • Tell SQL (the language) apart from MySQL, PostgreSQL, and other database systems that run it.

Your App

"Get this user's orders"

SQL Query

SELECT * FROM orders...

Database Engine

Finds the matching rows

Result

Rows sent back to your app

Data, Organized Into Tables

A relational database stores data in tables, which look a lot like spreadsheets. Beacon Robotics keeps an employees table, a departments table, a projects table, each one holding one kind of thing, and each row in that table is one record of that thing, one specific employee, one specific department. Each column is one piece of information every row has.

Spreadsheet termDatabase termExample, at Beacon Robotics
SheetTableemployees
RowRow (or "record")one specific employee, like Ada
Column headerColumn (or "field")first_name, salary, department
One cellA value"Engineering"
NOTE

Your manager's question, every Engineering employee earning over 90,000, is really asking for specific rows (employees) from this table, filtered down to the ones where two column values match what's being asked for. That's exactly what the next few lessons teach you to do.

SQL Is a Language, Not a Product

SQL itself is a standard (maintained by ISO/ANSI), not a piece of software you install. A very common mix-up for new developers: hearing "I'm learning SQL" and "I installed MySQL" and assuming they're the same statement. They're not, MySQL, PostgreSQL, SQLite, SQL Server, Oracle Database, and MariaDB are all separate database systems, called SQL applications or database engines, built by different companies and projects, that all understand SQL as their query language. They agree on the core of SQL, which is what this course focuses on, but each adds its own extra features and small syntax differences, called out throughout this course wherever they genuinely matter.

SQL Applications: Which One, for What

SQL applicationBuilt byBest for
MySQLOracle Corporation (open source)Web apps and WordPress-style hosting, huge community, easy to find help for
PostgreSQLOpen source communityNew production apps that want advanced features and strict standards compliance
SQLiteOpen sourceLearning, mobile apps, small local tools, no server to manage
SQL ServerMicrosoftEnterprises already invested in Microsoft infrastructure (.NET, Azure)
Oracle DatabaseOracle CorporationLarge, long-standing enterprise systems, especially finance and government
MariaDBOpen source (a MySQL fork)A drop-in MySQL alternative, the default on many Linux distributions
NOTE

This course's examples cover all six: MySQL, MariaDB, PostgreSQL, SQLite, SQL Server, and Oracle, and call out the specific syntax for each wherever a real difference exists. SQLite is the easiest to follow along with yourself, since it needs no server to install, just a free tool like DB Browser for SQLite.

SQL vs NoSQL

SQL databases (also called relational databases) are only one branch of how databases store data. The other major branch is NoSQL ("not only SQL"), a broad umbrella term, not one single technology, covering several different ways of storing data that don't use the table-with-fixed-columns model this course is built around.

NoSQL applicationData modelKnown for
MongoDBDocumentThe most popular document database, stores JSON-like records
RedisKey-valueIn-memory, extremely fast, often used for caching and sessions
CassandraWide-columnBuilt to scale across many servers with no single point of failure
DynamoDBKey-value / documentAmazon's managed NoSQL database, used heavily on AWS
Firebase FirestoreDocumentGoogle's managed database, popular for mobile and small web apps
Neo4jGraphBuilt specifically for data that's mostly about relationships, social networks, recommendations
SQL (Relational)This course
  • Data lives in tables with a fixed set of columns
  • Every row in a table has the same structure
  • Relationships between tables are explicit (foreign keys)
  • Best fit when data is structured and relationships matter, orders, accounts, inventory
NoSQL (Non-relational)
  • Several different models: documents, key-value pairs, wide columns, graphs
  • Structure can vary from one record to the next
  • Built to scale across many servers easily
  • Best fit for very large, fast-changing, or loosely-structured data, logs, caching, real-time feeds
NOTE

This course focuses entirely on SQL and relational databases, by far the most common choice for a typical application's main data. NoSQL databases are worth knowing exist, and are often used alongside a SQL database for a specific job (Redis for caching, for example), rather than as a full replacement for it.

Try It Yourself

A products table has columns id, name, price, and category. Without writing any SQL yet, just in plain English: what question would "find every product under $20" become once it's expressed as a request to a relational database?

Answer
-- In plain English: "Give me the name and price of every row
-- in the products table where price is less than 20."
-- As SQL (covered in full over the next few lessons):
SELECT name, price
FROM products
WHERE price < 20;

Frequently Asked Questions

Is SQL a programming language?

Not in the same sense as Python or JavaScript. SQL is a declarative language: you describe the result you want ("rows where age > 18"), not the step-by-step logic to get it. The database engine figures out how to actually fetch it.

What's the difference between SQL and MySQL?

SQL is the language. MySQL is one specific database system that uses SQL. It's the same relationship as HTML (the language) and a web browser like Chrome (software that reads it).

Is SQL case-sensitive?

SQL keywords (SELECT, WHERE, FROM) aren't case-sensitive, SELECT and select work the same. By convention this course writes keywords in uppercase to make queries easier to read, covered in full in the next lesson.

What's the difference between SQL and NoSQL, and when would you choose each?

SQL (relational) databases enforce a fixed table structure and make relationships between tables explicit, a good fit when data is structured and consistent, orders, accounts, inventory. NoSQL databases cover several looser models (document, key-value, graph) that scale more easily and tolerate records with varying shapes, a better fit for logs, caching, or very large, fast-changing data.

Common Beginner Mistakes

Saying "I'm learning MySQL" when you mean SQL in general

This quietly narrows every tutorial, job listing, and search you'll do. Say "SQL" for the language and skill, and name the specific system only when a feature or quirk is actually specific to it.

Assuming a feature that works on one database works everywhere

Core SQL (SELECT, WHERE, JOIN, basic aggregates) is shared, but plenty of real features aren't, covered throughout this course whenever a genuine difference exists.

Treating NoSQL as "the same thing, just newer"

NoSQL isn't a newer version of SQL, it's a different data model entirely (documents, key-value, graphs) that solves a different set of problems. Neither one replaces the other, they're suited to different kinds of data.

Best Practices

  • Say "SQL" when talking about the language or skill, and name the specific database system only when a difference actually matters.
  • Write queries in standard SQL first, and reach for a database-specific extension only once you actually need it.
  • Start learning on SQLite, it needs no server, just a free tool, and the SQL you learn transfers directly to MySQL, PostgreSQL, and SQL Server later.
  • Default to a relational database for a new project unless you have a specific, identified reason to reach for NoSQL.

Interview Questions

What actually makes a database "relational"?

Data is organized into tables with a fixed set of typed columns, where every row shares the same structure, and where tables can be explicitly connected to each other through foreign keys rather than nesting or duplicating data inside one record.

Is SQL a standard, and who maintains it?

Yes, SQL is standardized by ISO and ANSI. Database vendors implement that core standard and then add their own extensions on top, which is why two databases can both be "correct SQL" and still differ in places.

Name three SQL database systems and one thing that differentiates each.

MySQL: the most widely deployed, especially in web hosting and WordPress-style stacks. PostgreSQL: stronger standards compliance and more advanced features, popular for new production apps. SQLite: no server at all, a database is a single file, used for learning and embedded apps.

Summary

This lesson covered how a relational database organizes data into tables of rows and columns, where SQL sits between your application and the database engine, why SQL (the language) is a separate thing from MySQL, PostgreSQL, and the other systems that implement it, and how SQL databases differ from the NoSQL databases that solve a different kind of data problem.

What's Next?

The next lesson covers SQL syntax, the actual rules for writing a statement, before the lesson after that writes your first real query to actually answer your manager's question.

</>

Ready to Practice SQL?

Write and run real SQL queries online, right in your browser, no install or signup required. Pick a playground based on which database you want to practice on.

SQLite / PostgreSQL

Fast, no server, no ads.

Open DB Fiddle ↗

MySQL / SQL Server

Switch databases with one dropdown.

Open SQL Fiddle ↗

Both open a third-party SQL playground in a new tab. External site terms and privacy policy apply.