What is the significance of referential integrity in database design, and how does it apply to PHP and MySQL?

Referential integrity ensures that relationships between tables are maintained in a database, preventing orphaned records and ensuring data consistency. In PHP and MySQL, referential integrity can be enforced by using foreign key constraints when defining table structures.

CREATE TABLE orders (
    order_id INT PRIMARY KEY,
    customer_id INT,
    FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);