Skip to content
Snippets Groups Projects
base.sql 14.6 KiB
Newer Older
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
PavelBegunkov's avatar
PavelBegunkov committed
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `accounts`
--

CREATE TABLE IF NOT EXISTS `accounts` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Login` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  `Password` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
  `EMail` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `UserRoleID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `ActivationCode` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `IsEnabled` tinyint(1) NOT NULL DEFAULT '1',
PavelBegunkov's avatar
PavelBegunkov committed
  `UserAgent` text,
PavelBegunkov's avatar
PavelBegunkov committed
  `Notification` int(11) NOT NULL DEFAULT '0',
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  UNIQUE KEY `Login` (`Login`),
  UNIQUE KEY `EMail` (`EMail`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `UserRoleID` (`UserRoleID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `job_positions`
PavelBegunkov's avatar
PavelBegunkov committed
CREATE TABLE IF NOT EXISTS `job_positions` (
PavelBegunkov's avatar
PavelBegunkov committed
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Name` varchar(200) CHARACTER SET utf8 NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  UNIQUE KEY `Name` (`Name`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `departments`
--

CREATE TABLE IF NOT EXISTS `departments` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Name` varchar(200) CHARACTER SET utf8 NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `FacultyID` int(11) NOT NULL,
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  UNIQUE KEY `Name` (`Name`,`FacultyID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `FacultyID` (`FacultyID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `compound_disciplines`
--

-- --------------------------------------------------------
CREATE TABLE IF NOT EXISTS `compound_disciplines` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(200) CHARACTER SET utf8 NULL DEFAULT 'Курс по выбору',
  `GradeID` int(11) NOT NULL,
  `SpecializationID` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

PavelBegunkov's avatar
PavelBegunkov committed
--
-- Структура таблицы `disciplines`
--

-- --------------------------------------------------------


PavelBegunkov's avatar
PavelBegunkov committed
CREATE TABLE IF NOT EXISTS `disciplines` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `GradeID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `SubjectID` int(11) NOT NULL,
  `AuthorID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `ExamType` enum('exam','credit', 'grading_credit') NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `SemesterID` int(11) NOT NULL,
  `PracticeCount` int(11) NOT NULL DEFAULT '0',
PavelBegunkov's avatar
PavelBegunkov committed
  `LectureCount` int(11) NOT NULL DEFAULT '0',
PavelBegunkov's avatar
PavelBegunkov committed
  `LabCount` int(11) NOT NULL DEFAULT '0',
PavelBegunkov's avatar
PavelBegunkov committed
  `FacultyID` int(11) NOT NULL,
  -- IsLocked (for editing structure)
PavelBegunkov's avatar
PavelBegunkov committed
  `IsLocked`  tinyint(1) NOT NULL DEFAULT '0',
PavelBegunkov's avatar
PavelBegunkov committed
  -- Milestone semester time (or is session time)
  `Milestone`  INT(1) NOT NULL DEFAULT '0',
  `MilestoneDate` DATE NULL DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Subtype` enum('scientific_coursework', 'disciplinary_coursework' ) NULL DEFAULT NULL,
  `CompoundDiscID` INT(11) NULL DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed

  `MaxRate` INT(11) NOT NULL DEFAULT 0,
  `CurRate` INT(11) NOT NULL DEFAULT 0,

PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `GradeID`   (`GradeID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `SubjectID` (`SubjectID`),
  KEY `TeacherID` (`AuthorID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `SemesterID` (`SemesterID`),
  KEY `FacultyID` (`FacultyID`),
  KEY `CompoundDiscID` (`CompoundDiscID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Структура таблицы `disciplines_groups`
--

CREATE TABLE IF NOT EXISTS `disciplines_groups` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `DisciplineID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `GroupID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  UNIQUE KEY `DisciplineID_2` (`DisciplineID`,`GroupID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `DisciplineID` (`DisciplineID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `GroupID` (`GroupID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Структура таблицы `disciplines_students`
--

CREATE TABLE IF NOT EXISTS `disciplines_students` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `DisciplineID` int(11) NOT NULL,
  `StudentID` int(11) NOT NULL,
  `Type` enum('attach','detach') NOT NULL,
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  UNIQUE KEY `DisciplineID_2` (`DisciplineID`,`StudentID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `DisciplineID` (`DisciplineID`),
  KEY `StudentID` (`StudentID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `disciplines_teachers`
--

CREATE TABLE IF NOT EXISTS `disciplines_teachers` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `DisciplineID` int(11) NOT NULL,
  `TeacherID` int(11) NOT NULL,
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  UNIQUE KEY `DisciplineID_2` (`DisciplineID`,`TeacherID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `DisciplineID` (`DisciplineID`),
  KEY `AccountID` (`TeacherID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `faculties`
--

CREATE TABLE IF NOT EXISTS `faculties` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Name` varchar(100) CHARACTER SET utf8 NOT NULL,
  `Abbr` varchar(20) CHARACTER SET utf8 NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  UNIQUE KEY `Name` (`Name`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `modules`
--

CREATE TABLE IF NOT EXISTS `modules` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Name` varchar(200) CHARACTER SET utf8 NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `OrderNum` int(11) NOT NULL,
  `DisciplineID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Type` enum('regular','exam', 'bonus', 'extra') NOT NULL DEFAULT 'regular',
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  UNIQUE KEY `OrderNum` (`OrderNum`,`DisciplineID`),
  KEY `DisciplineID` (`DisciplineID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed


PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `rating_table`
--

CREATE TABLE IF NOT EXISTS `rating_table` (
  `StudentID` int(11) NOT NULL,
  `TeacherID` int(11) NOT NULL,
  `SubmoduleID` int(11) NOT NULL,
  `Rate` int(11) NOT NULL,
  `Date` date NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`StudentID`,`SubmoduleID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `StudentID` (`StudentID`),
  KEY `SubmoduleID` (`SubmoduleID`),
  KEY `TeacherID` (`TeacherID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed


-- CHANGE:
PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `requests`
--

CREATE TABLE IF NOT EXISTS `requests` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `AccountID` int(11) DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Title` varchar(50) CHARACTER SET utf8 NULL DEFAULT NULL,
  `Description` text CHARACTER SET utf8 NULL DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `Status` enum('opened','processed','closed') NOT NULL DEFAULT 'opened',
ViolettaShevchenko's avatar
ViolettaShevchenko committed
  `HasImage` BOOLEAN NOT NULL DEFAULT FALSE,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  KEY `AccountID` (`AccountID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

PavelBegunkov's avatar
PavelBegunkov committed

PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `semesters`
--

CREATE TABLE IF NOT EXISTS `semesters` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Year` int(11) NOT NULL,
  `Num` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  UNIQUE KEY `Year` (`Year`,`Num`),
  KEY `Year_2` (`Year`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Структура таблицы `years`
--
CREATE TABLE IF NOT EXISTS `years` (
  `Num` int(11) NOT NULL,
  PRIMARY KEY (`Num`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;



PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `specializations`
--

CREATE TABLE IF NOT EXISTS `specializations` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Name` varchar(200) CHARACTER SET utf8 NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Abbr` varchar(20) CHARACTER SET utf8 NULL,
  `Code` varchar(12) CHARACTER SET utf8 NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `FacultyID` int(11) NOT NULL,
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  UNIQUE KEY `Name` (`Name`,`FacultyID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `FacultyID` (`FacultyID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `students`
--

CREATE TABLE IF NOT EXISTS `students` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `AccountID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `LastName` varchar(30) CHARACTER SET utf8 NOT NULL,
  `FirstName` varchar(30) CHARACTER SET utf8 NOT NULL,
  `SecondName` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  KEY `AccountID` (`AccountID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `study_groups`
--

CREATE TABLE IF NOT EXISTS `study_groups` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `GradeID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `GroupNum` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  UNIQUE KEY `FacultyGroup`(`FacultyID`,`GradeID`,`GroupNum`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `GradeID` (`GradeID`),
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;


-- --------------------------------------------------------

--
-- Структура таблицы `groups_years`
--

CREATE TABLE IF NOT EXISTS `groups_years` (
  `GroupID` int(11) NOT NULL,
  `Year` int(11) NOT NULL,
  `SpecializationID` int(11) NOT NULL,
  `Name` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
  PRIMARY KEY (`Year`, `GroupID`),
  KEY `GroupID` (`GroupID`),
  KEY `Year` (`Year`),
  KEY `SpecializationID` (`SpecializationID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `subjects`
--

CREATE TABLE IF NOT EXISTS `subjects` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Name` varchar(200) CHARACTER SET utf8 NOT NULL,
  `Abbr` varchar(20) CHARACTER SET utf8 DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  UNIQUE KEY `Name` (`Name`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `subjects`
--

CREATE TABLE IF NOT EXISTS `subjects_faculties` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `SubjectID` int(11) NOT NULL,
  `FacultyID` int(11) NOT NULL,
  PRIMARY KEY (`ID`),
  UNIQUE KEY `SubjectID_2` (`SubjectID`,`FacultyID`),
  KEY `SubjectID` (`SubjectID`),
  KEY `FacultyID` (`FacultyID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `submodules`
--

CREATE TABLE IF NOT EXISTS `submodules` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ModuleID` int(11) NOT NULL,
  `MaxRate` int(11) NOT NULL,
  `OrderNum` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Name` varchar(200) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Description` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `IsUsed` tinyint(1) NOT NULL DEFAULT 0,
PavelBegunkov's avatar
PavelBegunkov committed
  `Type` enum('CurrentControl','LandmarkControl') NOT NULL DEFAULT 'CurrentControl',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ModuleID_2` (`ModuleID`,`OrderNum`),
  KEY `ModuleID` (`ModuleID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed


-- --------------------------------------------------------

--
-- Структура таблицы `grades`
--

CREATE TABLE IF NOT EXISTS `grades` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Num` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Degree` enum('bachelor','master','specialist') NOT NULL,
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  UNIQUE KEY `Grade_2` (`Num`,`Degree`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `teachers`
--

CREATE TABLE IF NOT EXISTS `teachers` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `LastName` varchar(30) CHARACTER SET utf8 NOT NULL,
  `FirstName` varchar(30) CHARACTER SET utf8 NOT NULL,
  `SecondName` varchar(30) CHARACTER SET utf8 DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `JobPositionID` int(11) NOT NULL,
  `DepartmentID` int(11) NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `AccountID` int(11) NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `FacultyID` (`DepartmentID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `AccountID` (`AccountID`),
  KEY `JobPositionID` (`JobPositionID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------
PavelBegunkov's avatar
PavelBegunkov committed
-- Структура таблицы `user_roles`
PavelBegunkov's avatar
PavelBegunkov committed
CREATE TABLE IF NOT EXISTS `user_roles` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Type` enum('student','teacher') NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `RoleName` varchar(30) CHARACTER SET utf8 NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Mark` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

-- --------------------------------------------------------

--
-- Структура таблицы `recovery_tokens `
--

CREATE TABLE IF NOT EXISTS `recovery_tokens` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `AccountID` int(11) NOT NULL,
  `Date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PavelBegunkov's avatar
PavelBegunkov committed
  `Token` varchar(100) CHARACTER SET utf8 NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `IsUsed`  tinyint(1) NOT NULL DEFAULT '0',
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  KEY `AccountID` (`AccountID`),
  UNIQUE KEY `Token` (`Token`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;



PavelBegunkov's avatar
PavelBegunkov committed
-- --------------------------------------------------------

--
-- Структура таблицы `students_groups`
--
CREATE TABLE IF NOT EXISTS `students_groups` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `StudentID` int(11) NOT NULL,
  `GroupID` int(11) NOT NULL,
  `SemesterID` int(11) NOT NULL,
  `State` enum('common', 'outlet', 'expulsion', 'leave') NOT NULL DEFAULT 'common',
  `Date` date NULL DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  UNIQUE KEY `StudentID_2` (`StudentID`, `SemesterID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `SemesterID` (`SemesterID`),
  KEY `StudentID` (`StudentID`),
  KEY `GroupID` (`GroupID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


-- --------------------------------------------------------

--
-- Структура таблицы `exam_period_options`
CREATE TABLE IF NOT EXISTS `exam_period_options` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `SubmoduleID` int(11) NOT NULL,
  `StudentID` int(11) NOT NULL,
  `Type` enum('absence','pass'),
  PRIMARY KEY (`ID`),
  UNIQUE KEY `SubmoduleID` (`SubmoduleID`,`StudentID`),
  KEY `SubmoduleID_2` (`SubmoduleID`),
  KEY `StudentID` (`StudentID`),
  KEY `StudentID_2` (`StudentID`),
  KEY `StudentID_3` (`StudentID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


-- --------------------------------------------------------

--
-- Структура таблицы `auth_tokens`
--

CREATE TABLE IF NOT EXISTS `auth_tokens` (
  `Token` char(40) charset ascii NOT NULL,
  `AccountID` int(11) NOT NULL,
  `Created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `Accessed` TIMESTAMP NOT NULL DEFAULT 0,
  `Mask` int(11) NOT NULL DEFAULT 0,
  UNIQUE KEY `Token` (`Token`),
  KEY `AccountID` (`AccountID`)
);