CREATE TABLE in SQL
Introduction
CREATE TABLE is a Data Definition Language statement that creates a new relational table and defines the rules governing its data. A table definition identifies the table name, its columns, each column's data type, nullability, default values, keys, and other constraints. The statement creates structure; it does not normally insert application records.
CREATE TABLE employees (
employee_id INT,
employee_name VARCHAR(100),
salary DECIMAL(10, 2)
);
This simple example creates an empty table with three columns. Real designs usually add stronger guarantees, such as a primary key, required fields, valid ranges, and relationships to other tables. Those decisions matter because a table is not merely a container. It is an executable data contract that every application, report, integration, and administrator must follow.
What Is a Relational Table?
A relational table stores facts in rows and describes those facts through columns. Each row represents one occurrence of an entity or event, such as an employee, payment, order, or test result. Each column represents one attribute, such as an identifier, name, amount, or timestamp. All rows follow the structure declared when the table is created.
| employee_id | employee_name | department | salary |
|---|---|---|---|
| 101 | John | IT | 75000.00 |
| 102 | Priya | HR | 62000.00 |
| 103 | David | Sales | 68000.00 |
The structure gives values meaning. The number 101 is an employee identifier because it appears under employee_id, while 75000.00 is a salary because the schema assigns it that role and an exact numeric type. Good table design makes these meanings explicit and prevents invalid states where practical.
CREATE TABLE Is DDL
CREATE TABLE belongs to Data Definition Language because it changes database metadata and structure. DDL statements include commands such as CREATE, ALTER, DROP, and often TRUNCATE. By contrast, Data Manipulation Language statements such as INSERT, UPDATE, and DELETE work with rows inside an existing structure.
The distinction has operational consequences. Some database systems apply special transaction or locking behavior to DDL. A table creation can also affect deployment order, schema permissions, replication, migration history, and application startup. Treat schema changes as versioned engineering changes rather than commands typed casually into production.
Basic Syntax and Anatomy
CREATE TABLE table_name (
column_name data_type column_constraints,
column_name data_type column_constraints,
table_constraint
);
The parentheses contain a comma-separated list of column definitions and optional table-level constraints. Every column needs a name and data type. Constraints can appear next to a column or after all columns, depending on their purpose and the syntax supported by the DBMS. The final definition is not followed by a comma, and the statement normally ends with a semicolon.
A common beginner error is leaving a trailing comma before the closing parenthesis. Another is omitting a comma between definitions. Formatting one column per line makes both errors easier to see and produces cleaner code reviews. Consistent indentation is especially valuable when a table contains named keys and multi-column constraints.
CREATE TABLE versus INSERT
Creating a table establishes an empty structure. Inserting data is a separate action performed after the table exists. Keeping these concepts separate helps explain why a successful creation does not prove that application writes, conversions, constraints, or generated values behave as expected.
CREATE TABLE departments (
department_id INT PRIMARY KEY,
department_name VARCHAR(100) NOT NULL
);
INSERT INTO departments (department_id, department_name)
VALUES (10, 'Quality Engineering');
The first statement defines what a valid department row looks like. The second attempts to create one row that conforms to that definition. If the same identifier already exists or the name is missing, the database rejects the insert because the schema enforces those rules.
Table and Column Naming
Names should communicate business meaning and remain predictable across the schema. Choose either singular table names such as employee or plural names such as employees, then apply the choice consistently. Use names that describe the represented concept rather than implementation details such as data_table_1.
Column names should be specific enough to remain clear in queries. Names such as created_at, order_status, and customer_id are easier to understand than date, status, and id when several tables are joined. Avoid spaces, punctuation-heavy identifiers, and reserved SQL keywords. Quoted identifiers can technically permit them, but they create portability and maintenance problems.
Naming conventions should also cover primary keys, foreign keys, constraints, indexes, and timestamps. The exact convention matters less than consistency, clarity, and compatibility with the team's database tools and application framework.
Choosing Correct Data Types
A data type defines the values a column can store and influences validation, sorting, arithmetic, storage, indexing, and application mapping. Use integer types for whole-number quantities and identifiers, exact decimal types for money and measurements requiring fixed precision, character types for text, date and timestamp types for temporal values, and appropriate boolean or binary types where supported.
| Business value | Typical type | Design reason |
|---|---|---|
| Quantity | INT | Stores whole numbers and supports arithmetic |
| Price | DECIMAL(12, 2) | Preserves exact fixed-scale values |
| Customer name | VARCHAR(150) | Stores variable-length text |
| Birth date | DATE | Represents a calendar date without arbitrary formatting |
| Created time | TIMESTAMP | Represents a date and time |
Numeric-looking data is not always numeric. Postal codes, product codes, phone numbers, and government identifiers can contain leading zeros, letters, or formatting characters and are not normally used in arithmetic. Text is often the correct representation. Conversely, storing every value as VARCHAR removes useful validation and can make ordering, calculations, indexing, and integrations less reliable.
Size columns for realistic future requirements, not only current sample data. Oversizing every field is not a substitute for analysis, but narrow assumptions can force disruptive migrations. For exact money, avoid floating-point types because binary approximation can produce rounding differences. Use DECIMAL or NUMERIC with precision and scale selected for the business range.
Nullability Is a Business Decision
A nullable column permits the absence of a known value. NOT NULL requires every row to supply a value directly or receive one through a default or generated expression. Required business facts, such as an order's customer or a payment's amount, should usually be non-null. Optional facts, such as a middle name or completion time for an unfinished process, may legitimately be null.
CREATE TABLE students (
student_id INT PRIMARY KEY,
student_name VARCHAR(120) NOT NULL,
middle_name VARCHAR(120),
graduation_date DATE
);
Null does not mean an empty string, zero, false, or an invented date. It represents missing, unknown, or inapplicable information according to the model. Fake placeholders such as 'N/A' or 1900-01-01 blur those meanings and make queries unreliable. Decide nullability deliberately for every column and document unusual semantics.
Primary Keys
A primary key uniquely identifies each row and cannot contain null. A table has one primary key constraint, although that key can contain multiple columns. Stable primary keys make relationships, updates, deduplication, and application references dependable.
CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(150) NOT NULL,
unit_price DECIMAL(12, 2) NOT NULL
);
Column-level syntax is compact for a single-column key. Table-level syntax is useful for named constraints or composite keys. A composite key identifies a row through a combination, as in an order item identified by both order and product.
CREATE TABLE enrollment (
student_id INT NOT NULL,
course_id INT NOT NULL,
enrolled_on DATE NOT NULL,
CONSTRAINT pk_enrollment PRIMARY KEY (student_id, course_id)
);
Choose key columns that are stable, compact, and unlikely to change. A generated surrogate key often works well for technical identity, but it does not eliminate business uniqueness. A customer table can use customer_id as its primary key while still requiring a unique email or external account number when the business rule demands it.
Generated Identifiers across Database Systems
Database systems use different syntax for generated numeric identifiers. MySQL commonly uses AUTO_INCREMENT, SQL Server uses IDENTITY, PostgreSQL supports standards-oriented identity columns, and Oracle supports identity syntax in modern versions. SQLite gives special behavior to an INTEGER PRIMARY KEY.
-- PostgreSQL example
CREATE TABLE customers (
customer_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE
);
-- SQL Server example
CREATE TABLE customers (
customer_id BIGINT IDENTITY(1, 1) PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE
);
Generated identifiers solve key allocation, not business identity. They should not be exposed as proof of authorization, assumed to be gapless, or treated as meaningful sequence numbers. Failed transactions, caching, replication, and manual reseeding can create gaps.
UNIQUE Constraints
A UNIQUE constraint prevents duplicate values in one column or combination of columns. Unlike the primary key, a table can have several unique constraints. Null treatment can vary across database systems, so applications should not assume identical behavior without testing the selected platform.
CREATE TABLE user_accounts (
user_id BIGINT PRIMARY KEY,
email VARCHAR(255) NOT NULL,
tenant_id BIGINT NOT NULL,
username VARCHAR(80) NOT NULL,
CONSTRAINT uq_user_email UNIQUE (email),
CONSTRAINT uq_tenant_username UNIQUE (tenant_id, username)
);
The composite constraint allows the same username in different tenants while preventing duplicates inside one tenant. This illustrates why uniqueness must reflect the actual business scope rather than being added mechanically to individual columns.
Foreign Keys and Relationships
A foreign key requires values in a child table to match an eligible key in a parent table, unless the child value is null and nullability permits it. The constraint protects referential integrity so an order cannot silently refer to a customer that does not exist.
CREATE TABLE customers (
customer_id BIGINT PRIMARY KEY,
customer_name VARCHAR(150) NOT NULL
);
CREATE TABLE orders (
order_id BIGINT PRIMARY KEY,
customer_id BIGINT NOT NULL,
ordered_at TIMESTAMP NOT NULL,
CONSTRAINT fk_orders_customer
FOREIGN KEY (customer_id)
REFERENCES customers (customer_id)
);
The parent table must normally exist before the child table is created. This requirement determines migration order. The child column does not need the same name as the referenced column, but matching names often improve readability. The types should be compatible, and frequently joined foreign-key columns may need indexes depending on the DBMS and query workload.
Delete Actions on Foreign Keys
Foreign keys can define what happens when a referenced parent row is deleted. ON DELETE CASCADE removes matching child rows, ON DELETE SET NULL clears the reference when the child column permits null, and RESTRICT or NO ACTION blocks deletion while dependent rows exist. Exact behavior and timing vary by platform.
Cascade is useful when child rows have no independent meaning, such as temporary details belonging exclusively to a draft. It can also amplify a mistaken deletion through many tables. Choose an action from lifecycle requirements, not convenience, and test multi-level cascades with production-like data volumes.
CHECK Constraints
A CHECK constraint rejects rows that violate a predicate. It can enforce ranges, allowed states, and relationships between columns close to the data, protecting the database even when writes come from several applications.
CREATE TABLE inventory (
inventory_id BIGINT PRIMARY KEY,
quantity_on_hand INT NOT NULL,
reorder_level INT NOT NULL,
CONSTRAINT ck_inventory_quantity CHECK (quantity_on_hand >= 0),
CONSTRAINT ck_inventory_reorder CHECK (reorder_level >= 0)
);
Cross-column checks can express rules such as an end date being on or after a start date. Remember that SQL uses three-valued logic: a condition evaluating to unknown because of null may not fail as beginners expect. Combine nullability and checks deliberately. Complex workflow rules involving other rows, external services, or frequent policy changes may belong in another layer rather than one increasingly complicated constraint.
DEFAULT Values
A default supplies a value when an insert omits a column. Defaults are useful for creation timestamps, initial states, flags, and safe domain values. They do not automatically make a column non-null; an explicit null can still be accepted unless NOT NULL also applies.
CREATE TABLE support_tickets (
ticket_id BIGINT PRIMARY KEY,
subject VARCHAR(200) NOT NULL,
status VARCHAR(30) NOT NULL DEFAULT 'OPEN',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT ck_ticket_status
CHECK (status IN ('OPEN', 'IN_PROGRESS', 'RESOLVED', 'CLOSED'))
);
A default must represent a truthful business assumption. Supplying zero, an empty string, or a fake date merely to avoid null often hides incomplete data. Also consider whether the database or application should own timestamp generation and how time zones are represented.
Naming Constraints
Explicit constraint names make errors, migrations, monitoring, and support easier to understand. Names such as pk_orders, fk_orders_customer, uq_customers_email, and ck_products_price reveal both constraint type and ownership. Without explicit names, the DBMS may generate identifiers that differ across environments and complicate later changes.
Keep names within platform length limits and include enough context to remain unique in the relevant namespace. A migration that needs to drop or replace a constraint is more portable and predictable when its name is controlled by the schema definition.
Designing Many-to-Many Relationships
A many-to-many relationship requires a junction table. For example, one order contains many products and one product can appear in many orders. The junction table stores one row per association and can carry facts about that association, such as quantity and the price captured at purchase time.
CREATE TABLE order_items (
order_id BIGINT NOT NULL,
product_id BIGINT NOT NULL,
quantity INT NOT NULL,
unit_price DECIMAL(12, 2) NOT NULL,
CONSTRAINT pk_order_items PRIMARY KEY (order_id, product_id),
CONSTRAINT fk_items_order FOREIGN KEY (order_id)
REFERENCES orders (order_id),
CONSTRAINT fk_items_product FOREIGN KEY (product_id)
REFERENCES products (product_id),
CONSTRAINT ck_items_quantity CHECK (quantity > 0),
CONSTRAINT ck_items_price CHECK (unit_price >= 0)
);
Storing unit price here preserves the price agreed for that order even if the product's current catalog price later changes. This distinction between current master data and historical transaction facts is central to reliable modeling.
Normalization and Table Boundaries
CREATE TABLE turns a logical model into physical schema. A strong design generally gives each table one coherent subject and uses relationships instead of repeating groups. Columns such as phone_1, phone_2, and phone_3 are a warning when the number of values can vary. A separate phone table represents each value as a row and scales without adding new columns.
Normalization reduces inconsistent duplication, but splitting every attribute into a separate table creates needless joins and complexity. Table boundaries should follow entity identity, lifecycle, cardinality, ownership, security, and query needs. Begin with a normalized model, measure real workloads, and denormalize only when a documented tradeoff justifies it.
Audit, Status, and Soft-Delete Columns
Operational tables often include created_at, created_by, updated_at, and updated_by. These columns support troubleshooting and accountability but are not a complete immutable audit trail. Update timestamps require reliable maintenance through application code, triggers, or platform-specific features.
A nullable deleted_at timestamp can represent soft deletion and records when the state changed. A boolean flag is simpler but carries less information. Soft deletion affects uniqueness, foreign keys, queries, indexes, privacy retention, and reporting, so it must be an intentional lifecycle design rather than one extra column added at the end.
Status columns should use a type and constraint appropriate to the expected evolution. A check constraint is practical for a small stable set. A reference table can carry metadata and permit controlled additions. Neither approach alone enforces every transition, such as allowing PAID only after payment authorization; workflow logic may still be required.
Indexes and CREATE TABLE
A primary key and unique constraint normally create or use supporting index structures, although implementation details vary. Additional indexes can improve lookups, joins, sorting, and filtering, but each index consumes storage and adds work to inserts, updates, and deletes.
Do not index every column during initial creation. Derive indexes from access patterns, selectivity, join paths, ordering, and measured execution plans. Consider indexing foreign-key columns used in joins or parent deletions. Avoid unnecessarily wide primary keys because their values may be repeated in child tables and secondary indexes.
Temporary Tables
Temporary tables hold intermediate data for a session, transaction, batch, or procedure. They can simplify multi-step transformations and reduce repeated expensive calculations. Their visibility, naming, persistence, and cleanup behavior differ across database products.
CREATE TEMPORARY TABLE recent_orders (
order_id BIGINT PRIMARY KEY,
customer_id BIGINT NOT NULL,
order_total DECIMAL(12, 2) NOT NULL
);
SQL Server commonly uses names such as #recent_orders, while MySQL and PostgreSQL support temporary-table keywords with their own lifecycle details. Temporary tables are not a universal replacement for common table expressions or well-designed permanent staging tables. Choose based on scope, volume, optimizer behavior, and concurrency.
Creating a Table from a Query
Many systems support CREATE TABLE AS SELECT, often abbreviated CTAS, to create a table from query results. It is useful for snapshots, analytical transformations, test fixtures, and staging work.
CREATE TABLE high_value_customers AS
SELECT customer_id, SUM(order_total) AS lifetime_value
FROM orders
GROUP BY customer_id
HAVING SUM(order_total) >= 10000;
CTAS does not necessarily copy primary keys, foreign keys, defaults, checks, indexes, identity behavior, comments, or every source type exactly. Inspect the resulting schema before treating it as a production replacement. Some platforms also provide syntax such as CREATE TABLE LIKE or SELECT INTO, but their copied properties differ.
IF NOT EXISTS and Idempotency
Some DBMSs support CREATE TABLE IF NOT EXISTS to avoid an error when the named table already exists. It is convenient for local setup and simple initialization, but it does not confirm that the existing table has the expected columns, types, constraints, or indexes.
CREATE TABLE IF NOT EXISTS application_settings (
setting_key VARCHAR(100) PRIMARY KEY,
setting_value VARCHAR(500) NOT NULL
);
Schema migration tools should track versions and validate outcomes rather than silently accepting any existing object. A table with the correct name and wrong structure is more dangerous than a clear deployment failure. Also verify whether the selected DBMS supports this clause and what warnings it emits.
Cross-Database Syntax Differences
The relational concepts are shared, but implementation details vary among MySQL, PostgreSQL, SQL Server, Oracle, and SQLite. Differences include generated identifiers, boolean types, timestamp semantics, temporary tables, schemas, table options, check enforcement in older versions, identifier limits, transaction behavior, storage engines, and syntax for copying tables.
| Concern | Common variations | Portable approach |
|---|---|---|
| Generated ID | AUTO_INCREMENT, IDENTITY, sequence, identity clause | Isolate dialect-specific migration code |
| Boolean | BOOLEAN, BIT, numeric representation | Confirm driver and DBMS semantics |
| Schema name | Database, owner, or namespace behavior | Qualify names according to deployment policy |
| Current timestamp | Type, time-zone, and precision differences | Define a consistent temporal strategy |
Portability does not mean using only the smallest common feature set. It means identifying dependencies deliberately, keeping dialect-specific code controlled, and testing migrations against every supported engine and version.
Security and Sensitive Data
Table design affects security before any permission is granted. Separate highly sensitive data when it requires different access, retention, encryption, or auditing. Store password hashes produced by a suitable password-hashing algorithm, never plaintext passwords. Avoid collecting secrets or personal data that the product does not need.
Apply least privilege to schema creation. Normal application identities usually need data access, not permission to create or alter production tables. Use controlled migration identities, reviewed scripts, and audit records. Consider row-level security, masking, encryption, key management, and retention requirements alongside the table definition.
Performance and Storage Considerations
Column types and constraints influence row width, cache use, indexes, joins, logging, and network transfer. Large text, binary, and JSON columns can be appropriate, but they should not become default containers for unrelated information. Frequently accessed narrow attributes may belong in the main table while large optional payloads can have a separate lifecycle when measurement supports that design.
JSON provides flexibility for variable attributes, but core relational facts that require filtering, joining, uniqueness, or referential integrity often deserve typed columns. A hybrid model can combine stable relational columns with a constrained metadata document. Validate document structure where possible and avoid using JSON to bypass data modeling.
Design from Requirements
Begin with business questions: what does one row represent, how is it identified, which facts are mandatory, which values must be unique, what relationships exist, how do records change, and how long are they retained? Translate each requirement into a type, null rule, key, constraint, relationship, or documented application rule.
For an appointment table, requirements might state that every appointment belongs to a patient, has a start and end time, and cannot end before it starts. The schema can enforce ownership, required timestamps, and cross-column ordering. Scheduling conflicts across rows may require transactional application logic or a platform-specific exclusion constraint.
Use realistic sample data and boundary values during review. Include maximum lengths, zero and negative numbers, nulls, duplicate business keys, daylight-saving transitions, Unicode text, and concurrent inserts. A definition that works only for three ideal sample rows is not production-ready.
Schema Migrations and Deployment
Place CREATE TABLE statements in version-controlled migration files. A migration should have a clear order, owner, review history, and verification plan. Automated deployment applies the same change through environments and records which versions succeeded. Avoid manually creating production tables and later trying to reconstruct their definitions.
Creation order follows dependencies: referenced tables come before foreign keys that target them. In larger deployments, teams may create base tables first and add cyclic relationships in a later migration. Test both forward deployment and recovery procedures on a production-like database.
Consider compatibility during rolling deployments. An older application instance may run briefly beside a newer schema. Additive changes are often easier to coordinate than immediate destructive changes. A new table might be deployed before application code starts using it, followed by backfill, validation, traffic migration, and cleanup in separate releases.
Production Creation Workflow
- Confirm the entity, ownership, lifecycle, and access patterns.
- Review names, types, lengths, nullability, defaults, keys, and relationships.
- Validate privacy, retention, security, and audit requirements.
- Test the migration on the supported DBMS version with realistic data.
- Review locks, transaction behavior, replication, and deployment order.
- Apply through the approved migration identity and capture execution evidence.
- Verify columns, constraints, indexes, permissions, and application behavior.
- Monitor errors, latency, storage, and replication after release.
A successful SQL response is only one check. Query the database catalog, run positive and negative tests, verify that invalid rows are rejected, inspect permissions, and confirm observability. Production readiness includes operational ownership and recovery, not only syntactic validity.
Common Mistakes
- Creating a table without a stable key.
- Using vague names, spaces, quoted identifiers, or reserved keywords.
- Storing dates, numbers, and booleans as arbitrary text.
- Using floating point for exact money.
- Allowing null everywhere or using fake values to avoid it.
- Forgetting business uniqueness after adding a surrogate key.
- Omitting foreign keys because the application currently validates references.
- Using cascading deletion without understanding its full path.
- Assuming IF NOT EXISTS proves the schema is correct.
- Adding indexes to every column without workload evidence.
- Putting repeating values into numbered columns.
- Deploying manual production DDL outside migration history.
Most of these mistakes are cheaper to correct before data accumulates. A focused schema review with application, database, QA, security, and business perspectives can prevent years of workarounds.
Complete Practical Example
CREATE TABLE employees (
employee_id BIGINT GENERATED ALWAYS AS IDENTITY,
employee_number VARCHAR(30) NOT NULL,
department_id BIGINT NOT NULL,
employee_name VARCHAR(150) NOT NULL,
email VARCHAR(255) NOT NULL,
salary DECIMAL(12, 2) NOT NULL,
employment_status VARCHAR(20) NOT NULL DEFAULT 'ACTIVE',
hired_on DATE NOT NULL,
terminated_on DATE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_employees PRIMARY KEY (employee_id),
CONSTRAINT uq_employees_number UNIQUE (employee_number),
CONSTRAINT uq_employees_email UNIQUE (email),
CONSTRAINT fk_employees_department
FOREIGN KEY (department_id)
REFERENCES departments (department_id),
CONSTRAINT ck_employees_salary CHECK (salary >= 0),
CONSTRAINT ck_employees_status
CHECK (employment_status IN ('ACTIVE', 'LEAVE', 'TERMINATED')),
CONSTRAINT ck_employees_dates
CHECK (terminated_on IS NULL OR terminated_on >= hired_on)
);
This example combines technical identity, business uniqueness, a required relationship, exact monetary storage, controlled status values, defaults, and cross-column validation. The generated-identity syntax may need adjustment for the target DBMS, and production design would still consider indexes, permissions, time-zone policy, soft deletion, auditing, and personal-data controls.
Interview Questions and Answers
What does CREATE TABLE do? It creates a table and defines its columns, data types, constraints, and related metadata.
Is CREATE TABLE DDL or DML? It is DDL because it defines database structure rather than manipulating rows.
Does CREATE TABLE insert rows? Normally no. Use INSERT or another loading mechanism after creating the structure.
What is the difference between a primary key and UNIQUE? Both enforce uniqueness, but a table has one primary key, the primary key cannot be null, and several unique constraints can exist.
Why use foreign keys? They protect referential integrity by preventing invalid references between related tables.
Does DEFAULT imply NOT NULL? No. Add NOT NULL separately when null must be rejected.
Why name constraints? Stable names improve error messages, migrations, troubleshooting, and consistency across environments.
What is a composite key? It is a key made from more than one column, with uniqueness applying to the combination.
Is CREATE TABLE syntax identical across databases? Core syntax is similar, but generated IDs, types, temporary tables, table options, and other features differ.
Does IF NOT EXISTS validate an existing table? No. It usually suppresses a name-conflict error and does not compare the existing definition.
Practical Review Checklist
- Define exactly what one row represents.
- Choose clear and consistent table, column, and constraint names.
- Select types and lengths from business ranges and operations.
- Decide nullability and defaults explicitly.
- Add stable primary and required business keys.
- Enforce relationships and safe delete actions.
- Use checks for durable row-level rules.
- Review indexing from measured access paths.
- Address security, privacy, auditing, and retention.
- Test migration, compatibility, rollback, and production verification.
Key Takeaway
CREATE TABLE is the foundation of relational design. Its syntax is straightforward, but its decisions shape data quality, query behavior, application contracts, security, performance, and future migrations. A reliable table gives each row a clear meaning, uses accurate types, protects identity and relationships, rejects invalid states, and remains understandable to the people who operate it.
RELIABLE TABLE = CLEAR ENTITY
+ CORRECT DATA TYPES
+ DELIBERATE NULLABILITY
+ STABLE KEYS
+ VALID RELATIONSHIPS
+ USEFUL CONSTRAINTS
+ TESTED MIGRATION
Do not treat CREATE TABLE as a form to complete mechanically. Begin with requirements, model the data, review the lifecycle, test boundary conditions, and deploy through controlled migrations. A carefully designed table prevents errors at their source and provides a stable base for every service and report built on top of it.