+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ title TEXT NOT NULL,
+ description TEXT,
+ category TEXT,
+ date_begin INTEGER DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ date_end INTEGER NOT NULL,
+ quorum FLOAT DEFAULT 1,
+ reminder_last_days INTEGER DEFAULT 3 NOT NULL,
+ is_transparent BOOLEAN DEFAULT 1 NOT NULL,
+ is_public BOOLEAN DEFAULT 1 NOT NULL,
+ is_anonymous BOOLEAN DEFAULT 1 NOT NULL,
+ is_open BOOLEAN DEFAULT 0 NOT NULL,
+ is_terminated BOOLEAN DEFAULT 0 NOT NULL,
+ is_hidden BOOLEAN DEFAULT 0 NOT NULL,
+ id_author INTEGER DEFAULT 1 NOT NULL,
+ id_group INTEGER DEFAULT 1 NOT NULL,
+ id_cardinal INTEGER NOT NULL,
+ FOREIGN KEY(id_author) REFERENCES users (id) ON DELETE SET DEFAULT,
+ FOREIGN KEY(id_group) REFERENCES groups (id),
+ FOREIGN KEY(id_cardinal) REFERENCES cardinals (id),
+ CHECK (is_transparent IN (0, 1)),
+ CHECK (is_public IN (0, 1)),
+ CHECK (is_open IN (0, 1)),
+ CHECK (is_terminated IN (0, 1)),
+ CHECK (is_hidden IN (0, 1))
+);
+
+create table attachments (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ url TEXT NOT NULL,
+ id_vote INTEGER NOT NULL,
+ FOREIGN KEY(id_vote) REFERENCES votes (id) ON DELETE CASCADE
+);
+
+create table choices (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ name TEXT NOT NULL,
+ id_vote INTEGER NOT NULL,
+ FOREIGN KEY(id_vote) REFERENCES votes (id) ON DELETE CASCADE