Database Fundamentals
databasedatabase-fundamentalsCore ConceptBeginner
Database Tables & Schemas
Understand relational database tables, schema design, entity modeling, and naming conventions.
Verified: 2026-09-30
Platforms:
nodelinux
#database#sql#tables#schema#modeling
What is a Database Table?
A Table is the core structural unit in a relational database. It represents a single entity type (e.g. users, orders, products) and consists of vertical columns (attributes) and horizontal rows (records).
Schema Definition Example
CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
is_active BOOLEAN DEFAULT true,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);Table Design Best Practices
- Use Plural, Snake_case Names: Prefer
users,order_items,user_profilesrather thanUserorTBL_USER. - Always Define a Primary Key: Every table must have a distinct primary key (e.g.
id) to uniquely identify each row. - Include Audit Timestamps: Include
created_atandupdated_attimestamps on all mutable entities. - Enforce Nullability Explicitly: Add
NOT NULLconstraints whenever a field is required to prevent missing or ambiguous null data. - Separate Concerns: Avoid mixing unrelated business domains into a single wide table; split them into distinct relational entities.