aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarvin Borner2020-10-01 15:14:45 +0200
committerMarvin Borner2020-10-01 15:14:45 +0200
commit4466c1f5460bb0b805c7bd5b61ba46123385bc9f (patch)
treeae16753d08f5775079aa97c1eb4cedbf4f7e0326
parentbda5305e995023d8c2382754d9761ac92a76db88 (diff)
Improved layout
-rw-r--r--tables.sql23
1 files changed, 7 insertions, 16 deletions
diff --git a/tables.sql b/tables.sql
index c6230eb..39021f1 100644
--- a/tables.sql
+++ b/tables.sql
@@ -1,5 +1,3 @@
-set global innodb_large_prefix = ON;
-
CREATE TABLE IF NOT EXISTS theme(
id INTEGER PRIMARY KEY AUTO_INCREMENT,
main VARCHAR(255) NOT NULL,
@@ -11,27 +9,18 @@ CREATE TABLE IF NOT EXISTS theme(
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- TODO: Remove dropping
-DROP TABLE IF EXISTS teachers;
DROP TABLE IF EXISTS users;
+DROP TABLE IF EXISTS types;
DROP TABLE IF EXISTS class;
-CREATE TABLE IF NOT EXISTS teachers(
+CREATE TABLE IF NOT EXISTS types(
id INTEGER PRIMARY KEY AUTO_INCREMENT,
- username VARCHAR(255) NOT NULL,
- name VARCHAR(255) NOT NULL,
- middlename VARCHAR(255) NOT NULL,
- surname VARCHAR(255) NOT NULL,
- password VARCHAR(255) NOT NULL,
-
- UNIQUE KEY uk_name (name, middlename, surname)
+ name VARCHAR(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS class(
id INTEGER PRIMARY KEY AUTO_INCREMENT,
- name VARCHAR(255) NOT NULL,
- teacher_id INTEGER NOT NULL,
-
- CONSTRAINT `fk_teacher_class` FOREIGN KEY (teacher_id) REFERENCES teachers (id)
+ name VARCHAR(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS users(
@@ -42,7 +31,9 @@ CREATE TABLE IF NOT EXISTS users(
surname VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
class_id INTEGER NOT NULL,
+ type_id INTEGER NOT NULL,
UNIQUE KEY uk_name (name, middlename, surname),
- CONSTRAINT `fk_class_user` FOREIGN KEY (class_id) REFERENCES class (id)
+ CONSTRAINT `fk_class_user` FOREIGN KEY (class_id) REFERENCES class (id),
+ CONSTRAINT `fk_type_user` FOREIGN KEY (type_id) REFERENCES types (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;