Lesson 1 of 24

Introduction to Databases

What is a Database?

A database is an organized collection of data stored and accessed electronically. At its core, a database lets you store, retrieve, update, and delete data efficiently and reliably.

You interact with databases every day without realizing it. When you log in to a website, browse products in an online store, or check your bank balance, a database is doing the heavy lifting behind the scenes.

Why PostgreSQL?

PostgreSQL (often called "Postgres") is one of the most powerful open-source relational database systems in the world. It has over 35 years of active development and a reputation for reliability, correctness, and extensibility.

Key strengths of PostgreSQL:

FeatureDescription
ACID ComplianceGuarantees data integrity even during crashes
SQL StandardClosely follows the SQL specification
ExtensibilityCustom types, functions, operators, and extensions
JSON SupportFirst-class support for JSON and JSONB data
ConcurrencyMVCC allows reads and writes without blocking each other
Open SourceFree to use, modify, and distribute

Tables, Rows, and Columns

Relational databases organize data into tables. A table is a structured collection of related data, much like a spreadsheet.

  • Table: A named collection of data about a specific entity (e.g., products, users, orders)
  • Column: A single field within a table, with a name and a data type (e.g., name TEXT, price DECIMAL)
  • Row: A single record in the table, containing one value for each column

Here is an example of what a products table might look like:

idnamepricecategory
1Laptop999.99Electronics
2Headphones79.99Electronics
3Coffee Maker49.99Kitchen

Each row represents one product. Each column represents an attribute of that product.

SQL: The Language of Databases

Fun fact: On the USS Enterprise, the crew queries the ship's computer with natural language: "Computer, display all crew members sorted by rank." That is essentially a SELECT query with an ORDER BY clause. We are not quite there yet, but SQL gets the job done.

SQL (Structured Query Language) is the standard language for interacting with relational databases. You use SQL to:

  • Query data with SELECT
  • Insert new records with INSERT
  • Update existing records with UPDATE
  • Delete records with DELETE
  • Define table structures with CREATE TABLE, ALTER TABLE, and DROP TABLE

Tip: SQL keywords like SELECT and FROM are case-insensitive. SELECT, select, and Select all work the same way. By convention, most developers write SQL keywords in uppercase for readability.

Your Task

Run the query below to see all the products in the database. This is the sandbox you will use throughout the SQL course.

SQL runtime loading...
Loading...
Click "Run" to execute your code.