How can SQL Normalization principles be applied to improve database structure and avoid issues in PHP applications?

Issue: By applying SQL normalization principles, we can improve the database structure by reducing redundancy and ensuring data integrity. This can help avoid issues such as data inconsistencies, update anomalies, and inefficient queries in PHP applications. PHP Code Snippet:

// Example of creating normalized tables in a MySQL database

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

// Create a table for storing user posts
CREATE TABLE posts (
    id INT PRIMARY KEY,
    user_id INT,
    title VARCHAR(255) NOT NULL,
    content TEXT,
    FOREIGN KEY (user_id) REFERENCES users(id)
);