From 54064158d84fc4006e651deb314cde156cc383e8 Mon Sep 17 00:00:00 2001
From: tomsmeding <tom.smeding@gmail.com>
Date: Tue, 14 Mar 2017 11:05:35 +0100
Subject: Register working

---
 schema.sql | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 schema.sql

(limited to 'schema.sql')

diff --git a/schema.sql b/schema.sql
new file mode 100644
index 0000000..5a888d6
--- /dev/null
+++ b/schema.sql
@@ -0,0 +1,43 @@
+pragma foreign_keys = on;
+
+create table Rooms (
+	id integer primary key,
+	name text
+);
+
+create table RoomNames (
+	name text primary key,
+	room integer not null,
+	foreign key(room) references Rooms(id) on delete cascade
+);
+
+create table Members (
+	room integer,
+	user integer,
+	primary key(room, user),
+	foreign key(room) references Rooms(id) on delete cascade,
+	foreign key(user) references Users(id) on delete cascade
+);
+
+create table Users (
+	id integer primary key,
+	username text,
+	pass text
+);
+
+create table UserNames (
+	name text primary key,
+	user integer,
+	foreign key(user) references Users(id) on delete cascade
+);
+
+create table Messages (
+	id integer primary key,
+	room integer not null,
+	user integer null,
+	time integer not null,
+	message text,
+	foreign key(room) references Rooms(id) on delete cascade,
+	foreign key(user) references Users(id) on delete set null
+);
+create index messages_time_index on Messages(time);
-- 
cgit v1.2.3-70-g09d2

