DROP TABLE IF EXISTS dialogs;
CREATE TABLE dialogs (
	id            INTEGER PRIMARY KEY,
	npc_id        INTEGER NOT NULL,
	voiceover_id  INTEGER,
	title_text_id INTEGER,
	msg_text_id   INTEGER,
	closeable     INTEGER NOT NULL DEFAULT 1,
	signature     INTEGER NOT NULL,
	language      INTEGER NOT NULL,
	log_id        INTEGER NOT NULL,
	FOREIGN KEY (npc_id) REFERENCES dialog_npcs(id) ON UPDATE CASCADE,
	FOREIGN KEY (title_text_id) REFERENCES dialog_text(id) ON UPDATE CASCADE,
	FOREIGN KEY (msg_text_id) REFERENCES dialog_text(id) ON UPDATE CASCADE,
	FOREIGN KEY (voiceover_id) REFERENCES dialog_voiceovers(id) ON UPDATE CASCADE
);
CREATE INDEX idx_dialogs_voiceover_id ON dialogs(voiceover_id);
CREATE INDEX idx_dialogs_npc_id ON dialogs(npc_id);
CREATE INDEX idx_dialogs_title_text_id ON dialogs(title_text_id);
CREATE INDEX idx_dialogs_msg_text_id ON dialogs(msg_text_id);
