How can the current data structure be modified to handle multiple ratings for each comment?
The current data structure can be modified by changing the 'rating' field in the comments table to a separate ratings table that stores each rating along with the comment ID. This way, multiple ratings can be associated with each comment. The ratings table would have columns for comment_id and rating_value.
// Comments table structure
CREATE TABLE comments (
id INT PRIMARY KEY,
comment TEXT
);
// Ratings table structure
CREATE TABLE ratings (
id INT PRIMARY KEY,
comment_id INT,
rating_value INT,
FOREIGN KEY (comment_id) REFERENCES comments(id)
);
Related Questions
- How can the PHP parser process code more efficiently when echoing HTML content with embedded variables?
- Are there any specific PHP functions or libraries that can simplify the process of styling tables for better readability and user experience?
- Are there any potential pitfalls to be aware of when interacting with users in PHP scripts?