SQL Tutorial for Beginners 1: Installing PostgreSQL and Creating Your First Database
Based on Corey Schafer's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
Postgres.app is the recommended macOS installation path because it runs a PostgreSQL server in the menu bar without a traditional installer.
Briefing
SQL’s value for beginners comes down to practicality: most software systems rely on databases, and SQL offers a relatively small set of core commands for common tasks like filtering and retrieving data. That makes it a strong on-ramp for computer science and programming careers, especially compared with learning a full programming language’s syntax and logic. With that motivation, the setup process focuses on getting a working PostgreSQL environment so SQL queries can be run immediately.
The tutorial walks through installing PostgreSQL on a Mac using the “Postgres.app,” a native macOS app that runs in the menu bar and avoids a traditional installer. After downloading and moving the app into the Applications folder, the PostgreSQL server starts and shows an elephant icon indicating it’s running on port 5432. The app also offers an option to open a command-line interface for issuing database commands.
To create a first database, the tutorial uses the command-line tool with a simple SQL statement: `create database sample_db;` (ending the command with a semicolon). It then verifies the new database by listing databases with `\\l`, confirming that `sample_db` now exists alongside the default databases created during installation. Exiting the command line is done with `\\q`.
Because command-line output can be harder to visualize, the tutorial adds a graphical interface: “pgAdmin” is not used here; instead it installs “PSequel,” chosen for a clean layout and the ability to enlarge fonts—useful for recording and readability. After installing and launching PSequel, a macOS security prompt may appear (“developer cannot be confirmed”); the workaround is to right-click and choose “Open” to proceed.
With PSequel running, the connection settings largely follow defaults, including port 5432, which must match the PostgreSQL server’s port. The key change is selecting the database name created earlier: `sample_db`. Once connected, the database initially appears empty because no tables exist yet.
From there, the tutorial demonstrates the next step conceptually: creating a table (named `test_table`) and adding at least one column (column `a`). After running the table-creation SQL and refreshing the table list in the interface, the new table appears with the expected column structure. The takeaway is a complete starter workflow—install PostgreSQL, create a database, connect through a GUI, and run SQL to create tables—setting up the next tutorial to focus on adding tables and writing more detailed SQL commands.
Cornell Notes
SQL is positioned as a practical entry point because most software relies on databases and SQL’s core commands cover common tasks like retrieving and filtering data. The setup uses PostgreSQL on macOS via Postgres.app, which runs in the menu bar and listens on port 5432. A first database is created from the command line with `create database sample_db;`, then verified using `\l`. For easier inspection, PSequel is installed as a GUI client; it connects to PostgreSQL using port 5432 and the `sample_db` database. After connecting, the database is empty until a table is created (e.g., `test_table` with column `a`), after which the table appears in the interface.
Why does the tutorial recommend SQL as a beginner-friendly skill, and what kinds of tasks does it emphasize?
What is the simplest way shown to install PostgreSQL on a Mac, and what does it provide immediately?
How is the first database created and confirmed in the command line?
Why add a GUI tool like PSequel, and what connection details must match PostgreSQL?
What happens after connecting to `sample_db`, and how does the tutorial demonstrate the next step?
Review Questions
- What exact command is used to create the initial database, and why is the semicolon important?
- Which port must the GUI client use to connect to PostgreSQL in this setup, and how is that port identified?
- After connecting to `sample_db`, what must be created before any tables appear in the GUI?
Key Points
- 1
Postgres.app is the recommended macOS installation path because it runs a PostgreSQL server in the menu bar without a traditional installer.
- 2
The PostgreSQL server runs on port 5432, and clients must use the same port to connect successfully.
- 3
A first database is created with `create database sample_db;` and verified using `\l`.
- 4
PSequel is used as a GUI client to inspect databases and tables more easily than command-line output.
- 5
macOS may block launching PSequel with a “developer cannot be confirmed” warning; right-clicking and choosing “Open” bypasses it.
- 6
After connecting to `sample_db`, the database is empty until SQL creates tables such as `test_table` with column `a`.
- 7
Refreshing the GUI’s table list confirms that table-creation SQL executed correctly.