Tables(1)#
1️⃣ What does Tables (1) mean?#
In pgAdmin, under:
Schemas
└── public
└── Tables (1)
Tables (1) means:
There is exactly one table inside the public schema.
In my case, that table is:
students
2️⃣ What is a Table in PostgreSQL (core concept)#
- A table is:
A persistent storage structure
Stores data in rows (records) and columns (fields)
Enforces rules (constraints)
Can be secured (RLS)
Can be optimized (indexes)
Can trigger logic (triggers)
- Think of a table as:
The single source of truth for your data
3️⃣ Expand students — what each child means#
When you expand:
Tables
└── students
You see:
Columns
Constraints
Indexes
RLS Policies
Rules
Triggers
Each one is not optional fluff — they are core table properties.
4️⃣ Columns — structure of the table#
students
└── Columns
- Columns define:
What data is stored
Data types
Nullability
Defaults
Example:
first_name VARCHAR(100) NOT NULL
Without columns → table is meaningless.
5️⃣ Constraints — data integrity rules
students
└── Constraints
Constraints protect your data from corruption.
- Examples:
PRIMARY KEY
UNIQUE
CHECK
FOREIGN KEY
Example:
email UNIQUE NOT NULL
Constraints run inside PostgreSQL, not in your app
They cannot be bypassed
6️⃣ Indexes — performance layer#
students
└── Indexes
- Indexes:
Make queries fast
Are automatically created for:
Primary keys
Unique constraints
Example:
CREATE INDEX idx_students_email ON students(email);
Without indexes → slow queries at scale.
7️⃣ RLS Policies — security at row level#
students
└── RLS Policies
- Row Level Security controls:
Who can see which rows
Who can modify which rows
Example idea:
student_id = current_user_id
This is zero-trust security inside PostgreSQL.
8️⃣ Rules — query rewriting (advanced, rare)#
students
└── Rules
- Rules:
Rewrite queries before execution
Mostly legacy
Views often rely on rules internally
- In modern systems:
Prefer triggers or views
Rules are rarely used directly
9️⃣ Triggers — automatic actions
students
└── Triggers
- Triggers:
Run automatically on INSERT, UPDATE, DELETE
Enforce logic at DB level
- Example:
Auto-update updated_at
Audit logs
Validation
Triggers call Trigger Functions (which you saw earlier).
🔟 Why PostgreSQL tables are powerful#
A PostgreSQL table is not just data storage.
- It includes:
Structure (columns)
Integrity (constraints)
Performance (indexes)
Security (RLS)
Automation (triggers)
Logic hooks (rules)
- This is why PostgreSQL can safely power:
APIs (PostgREST, Hasura)
Financial systems
Multi-tenant SaaS
Zero-trust architectures
- Mental model:
A table is a mini-system, not a spreadsheet