What is a Parent table and a Child table in Database?

What is a Parent table and a Child table in Database?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

What is a Parent table and a Child table in Database?

In relational database design, the terms "parent" and "child" describe the relationship between two tables based on how they reference one another. This isn't just nomenclature; it dictates how data is queried, normalized, and maintained. A parent table typically represents the primary entity or the "one" side of a relationship, while the child table represents the "many" side. The technical mechanism connecting them is almost exclusively the foreign key, which creates an explicit link from the child back to the parent.

Consider a classic users and orders scenario. The users table acts as the parent because it defines the core entity—a single user record. The orders table is the child because a single user can place multiple orders. To maintain data integrity, every row in the orders table must contain a column referencing the id of a user in the users table. This reference column is the foreign key.

Here is how that structure looks in practice using SQL:

-- Parent Table
CREATE TABLE users (
    id INT PRIMARY KEY AUTO_INCREMENT,
    name VARCHAR(255),
    email VARCHAR(255) UNIQUE
);

-- Child Table
CREATE TABLE orders (
    id INT PRIMARY KEY AUTO_INCREMENT,
    user_id INT NOT NULL, -- This is the foreign key linking to users.id
    total_amount DECIMAL(10, 2),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT fk_orders_user FOREIGN KEY (user_id) 
        REFERENCES users(id) 
        ON DELETE CASCADE
);

The ON DELETE CASCADE constraint is a critical detail often overlooked. Without it, if you delete a user from the parent table, their associated orders remain orphaned in the database with a NULL or invalid user_id. This violates referential integrity and can lead to data corruption or logic errors when querying for "active users' recent orders." Defining this behavior explicitly ensures that the lifecycle of related data is managed consistently.

When writing queries, understanding this hierarchy changes how you retrieve information. If you need a list of all orders placed by a specific user, you join the child table to the parent:

SELECT o.id, o.total_amount, u.name
FROM orders o
JOIN users u ON o.user_id = u.id
WHERE u.email = 'dev@example.com';

Conversely, if you simply need to count how many orders a user has, an aggregation on the child table joined with the parent provides the necessary context without pulling unnecessary order details.

Performance implications also stem from this structure. The foreign key in the child table should ideally be indexed. Most database management systems automatically create an index on the foreign key column when you define the REFERENCES constraint, but verifying this is standard practice. An unindexed foreign key turns a lookup into a full table scan, which degrades performance as the child table grows. Conversely, adding unnecessary indexes to the parent table can slow down write operations like inserts and updates.

Another consideration is normalization. Placing all order details in the users table would violate third normal form (3NF) because the user's name and email would be repeated for every single order they place. This leads to data redundancy and update anomalies; changing a user's email would require updating multiple rows. By keeping the data in separate parent and child tables, you ensure that each fact is stored in exactly one place.

While some application frameworks abstract these concepts away, understanding the underlying schema remains essential for debugging complex queries or optimizing database performance. In modern PHP development, tools like Laravel simplify managing these relationships through Eloquent models, but the database structure underneath follows these fundamental rules of parent and child associations.

Our network