SQL and databases

Stage 1 · Lesson 8 of 8

Your first tables by hand

Relational thinking and your setup

Before relying on sample data, create two related tables yourself with CREATE TABLE, for example authors and books. Give each one a , and give books a that points at authors. Add a few rows with and read them back with SELECT.

Then try to add a book for an author who does not exist, and read the error. Next, drop the tables and recreate them from a saved .sql file. This gets you used to keeping your work as scripts, not as clicks.

Write a script, run it, check the result, repeat: this small loop is how you will work for the rest of the roadmap. CREATE TABLE belongs to , and INSERT and SELECT to data manipulation language, the families from earlier.

Common trapbuilding tables through graphical dialogs and having no script to recreate them.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • CourseFree
    CS50's Introduction to Databases with SQL

    Harvard University · Beginner

    Watch Lecture 0 (Querying) for the relational model; it uses SQLite, and the ideas carry straight across

  • GuideFree
    PostgreSQL Tutorial

    PostgreSQL Global Development Group · Beginner

    The short official tutorial: Chapters 1 and 2 cover creating a database and your first tables

Keep handy

  • Read the installation and psql pages for your platform, and bookmark the SQL commands reference

  • A one-page map of SQL topics: use it to see where each stage of this roadmap fits

Mark this stage as not done?