 -- 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,

	FOREIGN KEY (doc_contributer, doc_id) REFERENCES document_delete_upload);

CREATE TABLE inspect_review(
	inspector_uni VARCHAR(10),
	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_on(
	client_uni VARCHAR(10),
	doc_contributer VARCHAR(10),
	doc_id INTEGER,
	PRIMARY KEY (client_uni, doc_contributer, doc_id),
	FOREIGN KEY (client_uni) REFERENCES client,
	FOREIGN KEY (doc_contributer, doc_id) REFERENCES document_delete_upload);

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

CREATE TABLE download( 
	client_uni VARCHAR(10),
	doc_contributer VARCHAR(10),
	doc_id INTEGER,
	PRIMARY KEY (client_uni, doc_contributer, doc_id),
	FOREIGN KEY (client_uni) REFERENCES client,
	FOREIGN KEY (doc_contributer, doc_id) REFERENCES document_delete_upload);

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



	create_date TIMESTAMP,
	publish_date TIMESTAMP,
	raw_file TEXT,
	PRIMARY KEY (contributer, id, course_prof, course_id),
	FOREIGN KEY (contributer) REFERENCES client ON DELETE CASCADE,
	FOREIGN KEY (course_prof, course_id) REFERENCES course_instruct);

CREATE TABLE review_write (
	-- Foreigns
	writer VARCHAR(10) NOT NULL,
	course_prof VARCHAR(10) NOT NULL,
	course_id VARCHAR(15) NOT NULL,
	-- Locals
	id INTEGER NOT NULL,
	inspectors TEXT[],
	votes INTEGER,
	create_date TIMESTAMP,
