 ON DELETE CASCADE
 ) ENGINE = InnoDB;
 
+#Timetable
 CREATE TABLE `student_portal`.`system_tutorials` (
-	`moduleid` INT(11) NOT NULL,
-	`tutorialid` INT(11) NOT NULL AUTO_INCREMENT UNIQUE,
+	`moduleid` INT(11) NOT NULL UNIQUE,
+	`tutorialid` INT(11) NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
 	`tutorial_name` VARCHAR(300) NOT NULL,
 	`tutorial_assistant` INT(11) NOT NULL,
 	`tutorial_notes` VARCHAR(5000),

ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`user_timetable` (
	`userid` INT(11) NOT NULL,
	`moduleid` INT(11) NOT NULL,
FOREIGN KEY (userid)
REFERENCES user_signin(userid),
FOREIGN KEY (moduleid)
REFERENCES system_modules(moduleid)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`system_events` (
	`eventid` INT(11) NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
	`event_name` VARCHAR(70) NOT NULL,
	`event_notes` VARCHAR(5000),
	`event_url` VARCHAR(70),
	`event_class` VARCHAR(15) NOT NULL,
	`event_from` DATETIME NOT NULL,
	`event_to` DATETIME NOT NULL,
	`event_amount` NUMERIC(15,2) NOT NULL,
	`event_ticket_no` INT(11) NOT NULL,
	`event_category` VARCHAR(10) NOT NULL,
	`event_status` VARCHAR(10) NOT NULL,
	`created_on` DATETIME NOT NULL,
	`updated_on` DATETIME
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`booked_events` (
	`userid` INT(11) NOT NULL,
	`eventid` INT(11) NOT NULL,
	`event_name` VARCHAR(300) NOT NULL,
	`event_amount` NUMERIC(15,2) NOT NULL,
	`tickets_quantity` VARCHAR(11) NOT NULL,
	`booked_on` DATETIME NOT NULL,
FOREIGN KEY (userid)
REFERENCES user_signin(userid),
FOREIGN KEY (eventid)
REFERENCES system_events(eventid)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`system_books` (
	`bookid` INT(11) NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
	`book_name` VARCHAR(300) NOT NULL,
	`book_author` VARCHAR(300) NOT NULL,
	`book_notes` VARCHAR(5000),
	`book_copy_no` INT(11) NOT NULL,
	`book_status` VARCHAR(9) NOT NULL,
	`created_on` DATETIME NOT NULL,
	`updated_on` DATETIME
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`reserved_books` (
	`bookid` INT(11) NOT NULL,
  `userid` INT(11) NOT NULL,
	`book_class` VARCHAR(15) NOT NULL,
	`reserved_on` DATE NOT NULL,
	`toreturn_on` DATE NOT NULL,
  `returned_on` DATE NOT NULL,
	`isReturned` TINYINT(1) NOT NULL,
FOREIGN KEY (bookid) REFERENCES system_books(bookid),
FOREIGN KEY (userid) REFERENCES user_signin(userid)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`user_messages` (
	`messageid` INT(11) NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
	`message_subject` VARCHAR(300) NOT NULL,
	`message_body` VARCHAR(5000),
	`created_on` DATETIME NOT NULL,
	`deleted_on` DATETIME
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`user_messages_lookup` (
  `messageid` INT(11) NOT NULL AUTO_INCREMENT,
  `message_from` INT(11) NOT NULL,
  `message_to` INT(11) NOT NULL,
  `isRead` TINYINT(1) NOT NULL,
FOREIGN KEY (messageid)
REFERENCES user_messages(messageid),
FOREIGN KEY (message_from)
REFERENCES user_signin(userid),
FOREIGN KEY (message_to)
REFERENCES user_signin(userid)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE = InnoDB;

CREATE TABLE `system_map_markers` (
	`markerid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
	`marker_title` VARCHAR (70) NOT NULL,
	`marker_description` VARCHAR (5000) NOT NULL,
	`marker_lat` FLOAT(10,6) NOT NULL,
	`marker_long` FLOAT(10,6) NOT NULL,
	`marker_category` VARCHAR (70) NOT NULL
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`user_feedback` (
  `feedbackid` INT(11) NOT NULL AUTO_INCREMENT UNIQUE,
  `feedback_subject` VARCHAR(300) NOT NULL,
  `feedback_body` VARCHAR(5000) NOT NULL,
  `created_on` DATETIME NOT NULL
) ENGINE = InnoDB;

CREATE TABLE `student_portal`.`user_feedback_lookup` (
  `feedbackid` INT(11) NOT NULL,
  `feedback_from` INT(11) NOT NULL,

	`updated_on` DATETIME
) ENGINE = InnoDB;

#Timetable
CREATE TABLE `student_portal`.`user_timetable` (
	`userid` INT(11) NOT NULL,
	`moduleid` INT(11) NOT NULL,
FOREIGN KEY (userid)
REFERENCES user_signin(userid),
FOREIGN KEY (moduleid)
REFERENCES system_modules(moduleid)
ON UPDATE CASCADE
ON DELETE CASCADE
) ENGINE = InnoDB;

#Timetable
CREATE TABLE `student_portal`.`system_lectures` (
	`moduleid` INT(11) NOT NULL UNIQUE,
	`lectureid` INT(11) NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
	`lecture_name` VARCHAR(300) NOT NULL,
	`lecture_lecturer` INT(11) NOT NULL,
	`lecture_notes` VARCHAR(5000),
