PRAGMA foreign_keys = ON; -- Apparently this one needs to be run every time we open the database (or maybe not, but better safe than sorry) create table users( name text, password text, salt text, id integer, primary key(id) ); create unique index userindex on users(name); create unique index useridindex on users(id); create table channels( name text, password text, id integer, primary key(id) ); create unique index channelindex on channels(name); create table mods( channel integer, userid integer, privilege integer, foreign key(channel) references channels(id), foreign key(userid) references users(id) ); create index modindex on mods(channel); -- mods per channel should be few enough not to index -- Sample data (user passwords are "test") --insert into users values('A', '07e007fe5f99ee5851dd519bf6163a0d2dda54d45e6fe0127824f5b45a5ec59183a08aaa270979deb2f048815d05066c306e3694473d84d6aca0825c3dccd559', 'salt', null); --insert into users values('B', '07e007fe5f99ee5851dd519bf6163a0d2dda54d45e6fe0127824f5b45a5ec59183a08aaa270979deb2f048815d05066c306e3694473d84d6aca0825c3dccd559', 'salt', null); --insert into channels values('testchannel', 'password', null); --insert into mods values(1, 1, 15); --insert into mods values(1, 2, 15);