 -- Entities
-CREATE TABLE cu_er (
-    uni VARCHAR(10),
+CREATE TABLE professor(
+	uni VARCHAR(10) NOT NULL,
+	e_mail TEXT,
+	PRIMARY KEY (uni) );
+
+CREATE TABLE user (
+    uni VARCHAR(10) NOT NULL,
     name VARCHAR(100),
     passwd TEXT,
     e_mail TEXT,

    PRIMARY KEY (uni) );

CREATE TABLE inspector (
	uni VARCHAR(10),
	countdown INTEGER,
	max_course_number INTEGER,
	PRIMARY KEY (uni),
	FOREIGN KEY (uni) REFERENCES cu_er );

CREATE TABLE client (
	uni VARCHAR(10),
	max_download_rate INTEGER,
	max_upload_rate INTEGER,
	PRIMARY KEY (uni),
	FOREIGN KEY (uni) REFERENCES cu_er );

CREATE TABLE course_permit_instruct (
	professor_id VARCHAR(10),
	id VARCHAR(15),
	star REAL,
	doc_permission BOOLEAN,
	workload REAL,

	FOREIGN KEY (doc_contributer, doc_id) REFERENCES document_delete_upload);

CREATE TABLE inspect_review(
	inspector_uni VARCHAR(10) NOT NULL,
	review_writer VARCHAR(10) NOT NULL,
	review_id INTEGER NOT NULL,
	PRIMARY KEY (inspector_uni, review_writer, review_id),
	FOREIGN KEY (inspector_uni) REFERENCES inspector, 
	FOREIGN KEY (review_writer, review_id) REFERENCES review_write);

CREATE TABLE report_doc(
	client_uni VARCHAR(10) NOT NULL,
	doc_contributer VARCHAR(10) NOT NULL,
	doc_id INTEGER NOT NULL,
	PRIMARY KEY (client_uni, doc_contributer, doc_id),
	FOREIGN KEY (client_uni) REFERENCES client,
	FOREIGN KEY (doc_contributer, doc_id) REFERENCES document_upload);

CREATE TABLE vote_doc(
	client_uni VARCHAR(10) NOT NULL,
	doc_contributer VARCHAR(10) NOT NULL,
	doc_id INTEGER NOT NULL,
	PRIMARY KEY (client_uni, doc_contributer, doc_id),
	FOREIGN KEY (client_uni) REFERENCES client,
	FOREIGN KEY (doc_contributer, doc_id) REFERENCES document_upload);

CREATE TABLE download_doc( 
	client_uni VARCHAR(10) NOT NULL,
	doc_contributer VARCHAR(10) NOT NULL,
	doc_id INTEGER NOT NULL,
	PRIMARY KEY (client_uni, doc_contributer, doc_id),
	FOREIGN KEY (client_uni) REFERENCES client,
	FOREIGN KEY (doc_contributer, doc_id) REFERENCES document_upload);

CREATE TABLE vote_review(
	client_uni VARCHAR(10) NOT NULL,
	review_writer VARCHAR(10) NOT NULL,
	review_id INTEGER NOT NULL,
	PRIMARY KEY (client_uni, review_writer, review_id),
	FOREIGN KEY (client_uni) REFERENCES client,
	FOREIGN KEY (review_writer, review_id) REFERENCES review_write);


