teacher-tools/api/schema/classroom_compliance.sql

41 lines
1.3 KiB
SQL

CREATE TABLE classroom_compliance_class (
id INTEGER PRIMARY KEY,
number INTEGER NOT NULL,
school_year TEXT NOT NULL,
user_id INTEGER NOT NULL REFERENCES user(id)
ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE classroom_compliance_student (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
class_id INTEGER NOT NULL REFERENCES classroom_compliance_class(id)
ON UPDATE CASCADE ON DELETE CASCADE,
desk_number INTEGER NOT NULL DEFAULT 0,
removed INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE classroom_compliance_entry (
id INTEGER PRIMARY KEY,
class_id INTEGER NOT NULL REFERENCES classroom_compliance_class(id)
ON UPDATE CASCADE ON DELETE CASCADE,
student_id INTEGER NOT NULL REFERENCES classroom_compliance_student(id)
ON UPDATE CASCADE ON DELETE CASCADE,
date TEXT NOT NULL,
created_at INTEGER NOT NULL,
absent INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE classroom_compliance_entry_phone (
entry_id INTEGER PRIMARY KEY REFERENCES classroom_compliance_entry(id)
ON UPDATE CASCADE ON DELETE CASCADE,
compliant INTEGER NOT NULL DEFAULT 1
);
CREATE TABLE classroom_compliance_entry_behavior (
entry_id INTEGER PRIMARY KEY REFERENCES classroom_compliance_entry(id)
ON UPDATE CASCADE ON DELETE CASCADE,
rating INTEGER NOT NULL,
comment TEXT
);