CREATE TABLE IF NOT EXISTS answers (
	id INT PRIMARY KEY AUTO_INCREMENT,
	question_id INT NOT NULL,
	creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
	content TEXT NOT NULL
) ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS questions (
	id INT PRIMARY KEY AUTO_INCREMENT,
	from_who VARCHAR(255) NOT NULL,
	creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
	content TEXT NOT NULL,
	answered BOOLEAN NOT NULL DEFAULT FALSE,
	answer_id INT
) ENGINE=InnoDB;

ALTER TABLE questions
ADD CONSTRAINT fk_answer_id FOREIGN KEY (answer_id) REFERENCES answers(id) ON DELETE CASCADE;

ALTER TABLE answers
ADD CONSTRAINT fk_question_id FOREIGN KEY (question_id) REFERENCES questions(id) ON DELETE CASCADE;
