What are the best practices for structuring database tables in PHP to avoid issues with data retrieval?

When structuring database tables in PHP, it is important to normalize the data to avoid redundancy and ensure efficient data retrieval. This can be achieved by breaking down data into separate tables and establishing relationships between them using foreign keys. By following normalization principles, such as ensuring each table represents a single entity and avoiding repeating groups of data, you can optimize database performance and prevent issues with data retrieval.

CREATE TABLE users (
    id INT PRIMARY KEY,
    username VARCHAR(50) NOT NULL,
    email VARCHAR(100) NOT NULL
);

CREATE TABLE posts (
    id INT PRIMARY KEY,
    title VARCHAR(100) NOT NULL,
    content TEXT,
    user_id INT,
    FOREIGN KEY (user_id) REFERENCES users(id)
);