BEGIN TRANSACTION;
-- DROP TABLE IF EXISTS `word`;
CREATE TABLE IF NOT EXISTS `word` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT,
	`word`	TEXT UNIQUE
);
-- DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` (
	`id`	INTEGER NOT NULL UNIQUE,
	`username`	TEXT NOT NULL,
	`first_name`	INTEGER NOT NULL,
	`last_name`	INTEGER NOT NULL,
	`date`	INTEGER NOT NULL,
	PRIMARY KEY(`id`)
);
-- DROP TABLE IF EXISTS `reset`;
CREATE TABLE IF NOT EXISTS `reset` (
	`id`	INTEGER PRIMARY KEY AUTOINCREMENT,
	`user_id`	INTEGER,
	`conf_id`	INTEGER,
	`date`	INTEGER,
	`relation_id`	INTEGER,
	FOREIGN KEY(`user_id`) REFERENCES `user`(`id`)
);
-- DROP TABLE IF EXISTS `relations`;
CREATE TABLE IF NOT EXISTS `relations` (
	`id`	INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
	`word_id`	INTEGER NOT NULL,
	`user_id`	INTEGER NOT NULL,
	`conf_id`	INTEGER NOT NULL,
	`date`	INTEGER NOT NULL,
	FOREIGN KEY(`conf_id`) REFERENCES `conf`(`id`),
	FOREIGN KEY(`word_id`) REFERENCES `word`(`id`),
	FOREIGN KEY(`user_id`) REFERENCES `user`(`id`)
);
-- DROP TABLE IF EXISTS `conf`;
CREATE TABLE IF NOT EXISTS `conf` (
	`id`	NUMERIC NOT NULL UNIQUE,
	`title`	TEXT,
	`date`	INTEGER NOT NULL,
	PRIMARY KEY(`id`)
);
COMMIT;
