What are some best practices for structuring and normalizing a database to avoid complications in PHP queries?

When structuring and normalizing a database to avoid complications in PHP queries, it is important to follow best practices such as creating relationships between tables, using primary and foreign keys, and normalizing data to reduce redundancy. By organizing the database in this way, it will be easier to write efficient queries in PHP and avoid potential issues with data integrity.

// Example of creating a table with primary and foreign keys in MySQL
CREATE TABLE users (
    id INT PRIMARY KEY,
    name VARCHAR(50)
);

CREATE TABLE orders (
    id INT PRIMARY KEY,
    user_id INT,
    total_amount DECIMAL(10, 2),
    FOREIGN KEY (user_id) REFERENCES users(id)
);