How can normalization and proper database design principles improve the efficiency of filtering in PHP?

Normalization and proper database design principles can improve the efficiency of filtering in PHP by reducing redundancy in the database, making queries more optimized and faster. By organizing data into separate tables and establishing relationships between them, filtering operations can be performed more efficiently.

// Example of filtering using normalized database design
$query = "SELECT products.name, categories.category_name
          FROM products
          JOIN categories ON products.category_id = categories.id
          WHERE categories.category_name = 'Electronics'";
$result = mysqli_query($connection, $query);

// Process the result set
while ($row = mysqli_fetch_assoc($result)) {
    echo $row['name'] . " - " . $row['category_name'] . "<br>";
}