What are the best practices for normalizing database design in PHP to avoid issues with querying and joining tables?

When normalizing database design in PHP, it is important to follow best practices such as breaking down data into separate tables to avoid redundancy and improve data integrity. This can help prevent issues with querying and joining tables, as well as reduce the risk of data inconsistencies.

// Example of normalizing database design in PHP

// Create a users table
CREATE TABLE users (
    id INT PRIMARY KEY,
    username VARCHAR(50) UNIQUE,
    email VARCHAR(100) UNIQUE
);

// Create a posts table
CREATE TABLE posts (
    id INT PRIMARY KEY,
    user_id INT,
    title VARCHAR(100),
    content TEXT,
    FOREIGN KEY (user_id) REFERENCES users(id)
);

// Query to retrieve posts with user information
SELECT posts.id, posts.title, posts.content, users.username
FROM posts
JOIN users ON posts.user_id = users.id;