Understanding the Building Blocks: Tables, Rows, and Columns

After setting up your PostgreSQL environment in Chapter 1, you're ready to delve into the nitty-gritty.

When it comes to databases, especially in PostgreSQL, as we've begun exploring in Chapter 1, the basic building blocks are tables, rows, and columns.

To truly grasp these concepts, we'll break them down one by one.

Tables: The Framework of Data Storage

A table is a collection of related data organized within a database. Think of a table as a neatly structured grid, like a spreadsheet. It's a space where you can store information about a specific topic, such as employees in a company.

In our ongoing exploration, we're working with an employees table. This table is designed to hold all the information about employees in a particular organization.

An employee table inside PostgreSQL

An employee table inside PostgreSQL

Columns: Defining the Characteristics

Columns in a table define what kind of information will be stored. Each column has a unique name and a specific data type, which sets the rules for the data that can be stored in that column.

In the employees table, here are some of the columns:

CREATE TABLE employees (
  first_name VARCHAR(50),
  gender VARCHAR(10),
  start_date DATE,

These columns provide structure and enforce consistency within the data.

A column in a table

A column in a table

Rows: Individual Entries of Data