CodeWithSQL.com
Home SQL Beginner Course Introduction to SQL

Introduction to SQL

Learn the fundamentals of SQL ? what it is, its rich history from the 1970s to SQL:2019, and how it compares to NoSQL databases.

3 Topics Chapter 1 of 8 Beginner

1 What is SQL and why is it important?

Top

SQL (Structured Query Language) is the standard language for working with relational databases. If a website shows you a list of products, a bank checks your balance, or a hospital pulls up your medical records — SQL is doing the work behind the scenes.

Think of a database as a collection of spreadsheets (called tables), and SQL as the language you use to ask questions about the data in those spreadsheets.

Your First SQL Query

Here's what a real SQL query looks like. This one asks the database: "Show me the name and email of every customer from the USA."

SQL SELECT name, email FROM customers WHERE country = 'USA' ORDER BY name;
Result
name            | email
----------------|-------------------------
Alice Johnson   | alice@example.com
Bob Smith       | bob@example.com
Carol Williams  | carol@example.com

Even without any prior experience, you can probably read that query and understand what it does. That's one of SQL's greatest strengths — it reads almost like English.

Good to know: SQL is pronounced either "S-Q-L" (letter by letter) or "sequel" — both are correct. The name comes from its predecessor, SEQUEL (Structured English Query Language), developed at IBM in the 1970s.

What Can You Do with SQL?

SQL isn't just about reading data. It covers the full lifecycle of working with databases:

TaskSQL CommandExample
Create a table CREATE TABLE Define a new customers table
Add data INSERT INTO Add a new customer record
Read data SELECT Find all orders over $100
Update data UPDATE Change a customer's email
Delete data DELETE Remove inactive accounts
Combine tables JOIN Show orders with customer names
Summarize data COUNT, SUM, AVG Total revenue by month

Why SQL Matters in the Real World

It's everywhere

SQL is used by virtually every industry that stores data. Banks, hospitals, e-commerce platforms, social media apps, government agencies, and startups all rely on SQL databases. MySQL, PostgreSQL, Microsoft SQL Server, and Oracle are among the most widely deployed software systems in the world.

It's a career skill

SQL is consistently ranked among the most in-demand technical skills. It's required not just for database administrators, but for data analysts, backend developers, data scientists, business intelligence analysts, and product managers. Learning SQL opens doors across industries.

It handles scale

SQL databases power systems that handle millions of transactions per second. Your bank's ATM network, an airline's booking system, and Amazon's order processing all run on SQL databases with proper indexing and performance tuning.

It's standardized

Unlike most programming languages, SQL has an international standard (ISO/IEC 9075). Code you write for MySQL will largely work on PostgreSQL, SQL Server, or Oracle. Learn once, apply everywhere.

Real-world example: When you search for a flight on a booking website, the site runs a SQL query like SELECT * FROM flights WHERE departure = 'Dubai' AND arrival = 'London' AND date = '2026-05-15' ORDER BY price to find and sort matching flights for you.

Key Takeaways

  • SQL is the standard language for communicating with relational databases
  • It reads like English — SELECT name FROM users WHERE age > 25
  • SQL handles creating, reading, updating, and deleting data (CRUD)
  • It's one of the most in-demand tech skills across all industries
  • Learning SQL gives you a skill that works across MySQL, PostgreSQL, SQL Server, and Oracle

2 History and Versions of SQL

Top

SQL has been around for over 50 years — which, in the tech world, makes it ancient. But unlike most technologies from the 1970s, SQL didn't just survive, it became the universal standard. Understanding how it got here helps you appreciate why it works the way it does.

The Origin Story (1970s)

In 1970, an IBM researcher named Edgar F. Codd published a paper proposing the relational model for databases — the idea that data should be stored in tables with rows and columns, linked by relationships. It was a radical departure from the complex hierarchical databases of the time.

IBM then tasked Donald Chamberlin and Raymond Boyce with building a language to interact with Codd's relational model. They created SEQUEL (Structured English Query Language) in 1974, later shortened to SQL due to a trademark conflict.

Fun fact: This is why many people still pronounce SQL as "sequel" rather than "S-Q-L." Both are correct, but "sequel" connects back to the original name.

The SQL Standards That Matter

SQL has been standardized by ANSI and ISO multiple times. You don't need to memorize every version — here are the ones that shaped the SQL you'll actually use:

VersionYearWhat It AddedWhy It Matters
SQL-86 1986 First ANSI standard; basic queries Made SQL official and portable
SQL-92 1992 JOINs, subqueries, CASE The foundation of modern SQL — most of what you'll learn in this course comes from here
SQL:1999 1999 CTEs, triggers, recursive queries Made SQL capable of complex logic
SQL:2003 2003 Window functions, XML support, sequences Window functions are now essential for analytics
SQL:2016 2016 JSON support, row pattern matching Bridged the gap between SQL and NoSQL worlds

SQL Dialects: Same Language, Different Accents

While there is one SQL standard, each database vendor adds its own extensions. Think of it like English — the grammar is the same, but there are regional differences:

DatabaseDeveloperBest Known ForDialect Name
MySQLOracle (open source)Web applications, WordPress, PHPMySQL SQL
PostgreSQLCommunity (open source)Complex queries, extensions, GISPL/pgSQL
SQL ServerMicrosoftEnterprise, .NET, AzureT-SQL
Oracle DBOracleLarge enterprise, bankingPL/SQL
SQLiteD. Richard HippMobile apps, embedded, browsersSQLite SQL

Practical tip: The core SQL you'll learn in this course (SELECT, INSERT, UPDATE, DELETE, JOINs, functions) works on all of these databases. Focus on learning standard SQL first — dialect-specific features can come later.

Key Takeaways

  • SQL was created at IBM in the 1970s and standardized by ANSI in 1986
  • SQL-92 is the version that shaped modern SQL — JOINs, subqueries, and CASE all come from there
  • SQL:2003 added window functions (RANK, ROW_NUMBER) which are critical for data analytics
  • MySQL, PostgreSQL, SQL Server, and Oracle all use SQL with minor dialect differences
  • Learn standard SQL first; it's 90%+ portable across all database systems

3 SQL vs. NoSQL

Top

You'll often hear the debate: "Should I use SQL or NoSQL?" The answer is: it depends on your data and your problem. Neither is universally better. Here's a clear breakdown to help you understand the trade-offs.

The Core Difference

SQL databases store data in structured tables with predefined columns — like a well-organized spreadsheet. Every row follows the same format.

NoSQL databases store data in flexible formats — documents (JSON), key-value pairs, graphs, or wide columns. Each record can have a different structure.

Here's the same customer data stored in each:

SQL (MySQL)

SQL Table -- Structured, every row has the same columns SELECT * FROM customers; id | name | email | country ---|---------|-----------------|-------- 1 | Alice | alice@mail.com | USA 2 | Bob | bob@mail.com | UK

NoSQL (MongoDB)

JSON Document // Flexible, each document can differ { "name": "Alice", "email": "alice@mail.com", "country": "USA", "preferences": { "theme": "dark" } }

Head-to-Head Comparison

FeatureSQL DatabasesNoSQL Databases
Data structure Fixed schema (tables, rows, columns) Flexible schema (documents, key-value, graphs)
Relationships Excellent — JOINs built-in Limited — often requires denormalization
Data integrity ACID transactions guaranteed Eventual consistency (usually)
Query power Rich — aggregations, window functions, subqueries Varies by database
Scaling Vertical (bigger server) Horizontal (more servers)
Schema changes Requires migration (ALTER TABLE) Just add new fields
Best for Financial data, ERP, CRM, e-commerce Real-time apps, IoT, content management

When to Choose SQL

  • Your data has clear relationships — orders belong to customers, products belong to categories
  • Data integrity is critical — banking, healthcare, financial reporting
  • You need complex queries — reports that join 5 tables, group by month, and calculate running totals
  • Your schema is stable — the structure of your data doesn't change every week

When to Choose NoSQL

  • Your data is unstructured — user-generated content, social media posts, sensor readings
  • You need massive horizontal scale — millions of concurrent users, globally distributed
  • Your schema changes frequently — rapid prototyping, evolving data models
  • Speed over consistency — real-time caching, session storage, leaderboards

The reality: Most modern applications use both. A typical setup might use PostgreSQL (SQL) for orders and payments, and Redis (NoSQL) for caching and session management. It's not SQL or NoSQL — it's SQL and NoSQL.

Popular Databases at a Glance

DatabaseTypeUsed By
MySQLSQLFacebook, Twitter, YouTube, WordPress
PostgreSQLSQLApple, Instagram, Spotify, Reddit
SQL ServerSQLMicrosoft, Stack Overflow, Dell
MongoDBNoSQL (Document)Uber, Forbes, eBay
RedisNoSQL (Key-Value)GitHub, Pinterest, Snapchat
CassandraNoSQL (Wide Column)Netflix, Apple, Instagram

Key Takeaways

  • SQL = structured data with strict schemas; NoSQL = flexible data with dynamic schemas
  • Choose SQL when data integrity and complex relationships matter (finance, e-commerce, healthcare)
  • Choose NoSQL when you need horizontal scaling and flexible schemas (real-time apps, IoT)
  • Most production systems use both — SQL for core data, NoSQL for caching and unstructured data
  • Learning SQL first gives you the strongest foundation, since relational concepts underpin all data work

What's next? Now that you understand what SQL is and where it came from, the next chapter covers Database Concepts — you'll learn how databases are structured, the different types that exist, and what a Database Management System (DBMS) actually does.