CREATE TABLE Class (
  idClass int PRIMARY KEY,
  className varchar(20) NOT NULL,
  classPassword varchar(16) NOT NULL,
  classIntituion varchar(20),
  classCutOff int NOT NULL
);

CREATE TABLE ExamType (
  idFirstGrade int PRIMARY KEY,
  examTypeDescription varchar(100) NOT NULL
);

CREATE TABLE Exam (
  idExam int PRIMARY KEY,
  examDescription varchar(15) NOT NULL,
  class_idClass int references Class(idClass),
  examType_idFirtsGrade int references ExamType(idFirstGrade)
);

CREATE TABLE TrezentosUserType (
  idTrezentosUserType int PRIMARY KEY,
  TrezentosUserTypeDescription varchar(100) NOT NULL
);

CREATE TABLE TrezentosUser (
  idTrezentosUser int PRIMARY KEY,
  TrezentosUserName varchar(45) NOT NULL,
  TrezentosUserEmail varchar(45) NOT NULL,
  TrezentosUserPassword varchar(45) NOT NULL,
  isFromFacebook boolean NOT NULL,
  TrezentosUserType_idTrezentosUserType int references TrezentosUserType(idTrezentosUserType)
);

CREATE TABLE TrezentosUser_has_Class (
  TrezentosUser_idTrezentosUser int references TrezentosUser(idTrezentosUser),
  class_idClass int references Class(idClass)
);

CREATE TABLE TrezentosUser_has_Exam (
  TrezentosUser_idTrezentosUser int references TrezentosUser(idTrezentosUser),
  exam_idExam int references Exam(idExam)
);

CREATE TABLE Party (
  idParty int PRIMARY KEY,
  partyDescription varchar(45) NOT NULL,
  exam_idExam int references Exam(idExam)
);

CREATE TABLE TrezentosUser_has_Party (
  idTrezentosUserHasparty int PRIMARY KEY,
  TrezentosUser_idTrezentosUser int references TrezentosUser(idTrezentosUser),
  party_idParty int references Party(idParty),
  TrezentosUserHelper boolean NOT NULL
);

CREATE TABLE RateType (
  idRateType int PRIMARY KEY,
  rateTypeDescription varchar(45) NOT NULL
);

CREATE TABLE Rate (
  idRate int PRIMARY KEY,
  ratesValue int NOT NULL,
  rateType_idRateType int references RateType(idRateType),
  party_idParty int references Party(idParty),
  TrezentosUserHasParty_idTrezentosUserHasParty int references TrezentosUser_has_Party(idTrezentosUserHasparty)
);
