

CREATE TABLE Topics (
    topicId INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    topicTitle varchar (255) NOT NULL,
    topicTime VARCHAR(255) NOT NULL,
    topicText TEXT
);

CREATE TABLE Posts (
    postId INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    postText TEXT,
    postTime datetime,
    postOP varchar(150),
    topicId INT UNSIGNED,
    FOREIGN KEY (topicId) REFERENCES Topics(topicId)
);

INSERT INTO Topics (topicTitle,topicTime, topicOP) VALUES('test1',NOW(), 'tOP');

ALTER TABLE Posts ADD FOREIGN KEY(postText) REFERENCES Topics(topicId) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE Posts ADD FOREIGN KEY(postOP) REFERENCES finalUser(id) ON DELETE RESTRICT ON UPDATE CASCADE;
