What are the advantages and disadvantages of storing multiple product entries in a single database row versus individual rows in PHP applications?

Storing multiple product entries in a single database row can save space and improve performance by reducing the number of database queries needed. However, it can also make it more difficult to retrieve and update individual product entries. On the other hand, storing each product entry in its own row can make it easier to manage and manipulate the data, but it may require more storage space and increase the complexity of database queries.

// Storing multiple product entries in a single database row
// Example: Storing product entries as a JSON string in a single column

// Retrieve product entries
$query = "SELECT products FROM products_table WHERE id = 1";
$result = mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($result);
$product_entries = json_decode($row['products'], true);

// Update product entries
$new_product_entry = ['name' => 'New Product', 'price' => 19.99];
$product_entries[] = $new_product_entry;
$new_product_entries_json = json_encode($product_entries);

$update_query = "UPDATE products_table SET products = '$new_product_entries_json' WHERE id = 1";
mysqli_query($conn, $update_query);