September 2017
Intermediate to advanced
244 pages
6h 44m
English
A blog post comment can have the following fields:
id: It will have type integer. It will be unique and will have auto-incremented values. id will be the primary key of the blog post.
comment: It will have type varchar with a length of 250 characters.
post_id: post_id will be of type integer. It will be the foreign key related to the id from the posts table.
Here, user_id is the ID of the author/writer of the comment while post_id is the ID of the post on which the comment is made.
Here is an SQL query for creating a comments table:
CREATE TABLE `blog`.`comments` ( `id` INT NOT NULL AUTO_INCREMENT ...
Read now
Unlock full access