What is the recommended approach for storing user-submitted comments in a PHP application, considering database relations?

When storing user-submitted comments in a PHP application, it is recommended to create a separate table in the database to store the comments. This table should have a foreign key relationship with the users table to associate each comment with the user who submitted it. This approach helps maintain data integrity and allows for easier retrieval and management of comments.

// Create a comments table with a foreign key relationship to the users table
CREATE TABLE comments (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT,
    comment TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (user_id) REFERENCES users(id)
);