The table statement for the main table is as follows
create table topic(id int primary key not null auto_increment,title varchar(10),content varchar(20));
The data from the table is primarily used to store replies as long as there is the name and content of the reply, so how should the table be built to be associated with the main table? Ask for advice
Reply content:
The table statement for the main table is as follows
create table topic(id int primary key not null auto_increment,title varchar(10),content varchar(20));
The data from the table is primarily used to store replies as long as there is the name and content of the reply, so how should the table be built to be associated with the main table? Ask for advice
CREATE TABLE reply( reply_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, replier VARCHAR, content VARCHAR NOT NULL, topic_id INT NOT NULL, FOREIGN KEY (topic_id) REFERENCES topic(id) ON UPDATE CASCADE);
Just keep it correct with the foreign key.
table reply field id auto_increment primary key, field topic_id, field user_id, field content, field datetime
Brother, have you heard of foreign keys?