이번에는 사용자의 댓글을 저장하는 테이블을 만들어봅시다.
콘솔
mysql> CREATE TABLE nodejs.comments (
-> id INT NOT NULL AUTO_INCREMENT,
-> commenter INT NOT NULL,
-> comment VARCHAR(100) NOT NULL,
-> created_at DATETIME NOT NULL DEFAULT now(),
-> PRIMARY KEY(id),
-> INDEX commenter_idx (commenter ASC),
-> CONSTRAINT commenter
-> FOREIGN KEY (commenter)
-> REFERENCES nodejs.users (id)
-> ON DELETE CASCADE
-> ON UPDATE CASCADE)
-> COMMENT = '댓글'
-> ENGINE=InnoDB;
Query OK, 0 row affected (0.09 sec)