What are some best practices for structuring database tables to ensure efficient data retrieval in PHP applications?

To ensure efficient data retrieval in PHP applications, it is important to properly structure the database tables. One best practice is to normalize the database by breaking down data into separate tables to reduce redundancy and improve data integrity. Additionally, creating indexes on columns frequently used in queries can help speed up data retrieval.

// Example of creating a normalized database table
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(50) NOT NULL,
    email VARCHAR(100) NOT NULL,
    password VARCHAR(255) NOT NULL
);

// Example of creating an index on a column
CREATE INDEX idx_username ON users (username);