Skip to content
Snippets Groups Projects
Structure.sql 23.7 KiB
Newer Older
RomanSteinberg's avatar
RomanSteinberg committed
-- phpMyAdmin SQL Dump
PavelBegunkov's avatar
PavelBegunkov committed
-- version 4.0.10
-- http://www.phpmyadmin.net
--
-- Хост: 127.0.0.1:3306
PavelBegunkov's avatar
PavelBegunkov committed
-- Время создания: Авг 22 2014 г., 14:07
PavelBegunkov's avatar
PavelBegunkov committed
-- Версия сервера: 5.5.37-log
-- Версия PHP: 5.3.28

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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 */;

--
PavelBegunkov's avatar
PavelBegunkov committed
-- База данных: `Sample2`
PavelBegunkov's avatar
PavelBegunkov committed
--

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

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

PavelBegunkov's avatar
PavelBegunkov committed
-- CHANGE:

PavelBegunkov's avatar
PavelBegunkov committed
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
-- --------------------------------------------------------

--
PavelBegunkov's avatar
PavelBegunkov committed
-- Структура таблицы `accounts`
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

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

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

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,
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`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `FacultyID` (`FacultyID`)
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

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

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

CREATE TABLE IF NOT EXISTS `general_settings` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Val` int(11) DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `ValS` varchar(300) CHARACTER SET utf8 DEFAULT NULL,
  `Name` varchar(50) CHARACTER SET utf8 NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`)
PavelBegunkov's avatar
PavelBegunkov committed
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
PavelBegunkov's avatar
PavelBegunkov committed

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

--
PavelBegunkov's avatar
PavelBegunkov committed
-- Структура таблицы `logs_rating`
PavelBegunkov's avatar
PavelBegunkov committed
CREATE TABLE IF NOT EXISTS `logs_rating` (
PavelBegunkov's avatar
PavelBegunkov committed
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `StudentID` int(11) NOT NULL,
  `SubmoduleID` int(11) NOT NULL,
  `TeacherID` int(11) NOT NULL,
  `Rate` int(11) NOT NULL,
  `Date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `Action` enum('add','change','delete') NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
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

PavelBegunkov's avatar
PavelBegunkov committed

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

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

CREATE TABLE IF NOT EXISTS `logs_signin` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `AccountID` int(11) NOT NULL,
  `Date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`ID`),
  KEY `AccountID` (`AccountID`)
) 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

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

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

CREATE TABLE IF NOT EXISTS `page_access` (
PavelBegunkov's avatar
PavelBegunkov committed
  `ID` int(11) NOT NULL AUTO_INCREMENT,
PavelBegunkov's avatar
PavelBegunkov committed
  `Pagename` text CHARACTER SET utf8 NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Bitmask` int(11) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
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 NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `Status` enum('opened','processed','closed') NOT NULL DEFAULT 'opened',
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

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

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

-- CREATE TABLE IF NOT EXISTS `requests` (
--   `ID` int(11) NOT NULL AUTO_INCREMENT,
--   `To` int(11) NOT NULL,
--   `From` int(11) NOT NULL,
--   `Field1` 	int(11) NOT NULL DEFAULT '0',
--   `Field2` 	int(11) NOT NULL DEFAULT '0',
--   `Field3` 	int(11) NOT NULL DEFAULT '0',
--   `Data` 	text 	NULL DEFAULT NULL,
--   `DataExt` text 	NULL DEFAULT NULL,
--   `Date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
--   `Type` enum('delegate_discipline','delete_discipline','clear_discipline','report') NOT NULL,
--   `Status` enum('opened','processed','closed') NOT NULL DEFAULT 'opened',
--   PRIMARY KEY (`ID`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- CREATE TABLE IF NOT EXISTS `requests_old` (
--   `ID` int(11) NOT NULL AUTO_INCREMENT,
--   `To` int(11) NOT NULL,
--   `From` int(11) NOT NULL,
--   `Field1` 	int(11) NULL DEFAULT NULL,
--   `Field2` 	int(11) NULL DEFAULT NULL,
--   `Field3` 	int(11) NULL DEFAULT NULL,
--   `Data` 	text 	NULL DEFAULT NULL,
--   `DataExt` text 	NULL DEFAULT NULL,
--   `Date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
--   `Type` enum('delegate_discipline','delete_discipline','clear_discipline','report') NOT NULL,
--   `Status` enum('opened','processed','closed') NOT NULL DEFAULT 'opened',
--   PRIMARY KEY (`ID`)
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
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`)
PavelBegunkov's avatar
PavelBegunkov committed
) 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,
  `SpecializationID` int(11) NOT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  `Name` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  UNIQUE KEY `GradeID_2` (`GradeID`,`GroupNum`,`SpecializationID`),
  KEY `GradeID` (`GradeID`),
PavelBegunkov's avatar
PavelBegunkov committed
  KEY `SpecializationID` (`SpecializationID`)
PavelBegunkov's avatar
PavelBegunkov committed
) 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`
# TODO: just name
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,
  `IsStudyLeave` tinyint(1) NOT NULL DEFAULT '0',
  `Date` date NULL DEFAULT NULL,
PavelBegunkov's avatar
PavelBegunkov committed
  PRIMARY KEY (`ID`),
  UNIQUE KEY `StudentID_2` (`StudentID`,`GroupID`,`SemesterID`),
  KEY `SemesterID` (`SemesterID`),
  KEY `StudentID` (`StudentID`),
  KEY `GroupID` (`GroupID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


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

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

CREATE TABLE IF NOT EXISTS `session_options` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `SubmoduleID` int(11) NOT NULL,
  `StudentID` int(11) NOT NULL,
  `Type` enum('absence','pass') NOT NULL,
  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 ;


RomanSteinberg's avatar
RomanSteinberg committed
--
-- Дамп данных таблицы `user_roles`
--

PavelBegunkov's avatar
PavelBegunkov committed
-- 1 - common
-- 2 - student
-- 4 - teacher
-- 8 - admin
-- 16 - deans
RomanSteinberg's avatar
RomanSteinberg committed
INSERT INTO `user_roles` (`ID`, `Type`, `RoleName`, `Mark`) VALUES
PavelBegunkov's avatar
PavelBegunkov committed
(1, 'student', 'Студент', 3),
(2, 'teacher', 'Преподаватель', 5),
PavelBegunkov's avatar
PavelBegunkov committed
(3, 'teacher', 'Преподаватель-Администратор', 31),
RomanSteinberg's avatar
RomanSteinberg committed
(4, 'teacher', 'Работник деканата', 21);
RomanSteinberg's avatar
RomanSteinberg committed

--
-- Дамп данных таблицы `user_roles`
--

INSERT INTO `page_access` (`ID`, `Pagename`, `Bitmask`) VALUES
PavelBegunkov's avatar
PavelBegunkov committed
(1, 'common:index', 1),
(2, 'common:settings', 1),
(3, 'common:profile', 1),
(4, 'teacher:index', 4),
(5, 'teacher:settings', 4),
(6, 'teacher:map:create', 4),
(7, 'teacher:map:edit', 4),
(8, 'teacher:rating', 4),
(9, 'teacher:profile', 4),
(10, 'admin:common', 8),
(11, 'student:index', 2),
(12, 'student:settings', 2),
(13, 'student:subject', 2),
(14, 'teacher:map:discipline', 4),
(15, 'teacher:map:structure', 4),
(16, 'teacher:map:groups', 4),
(17, 'teacher:map:students', 4),
(18, 'teacher:map:teachers', 4),
(19, 'handler:AdmAccounts', 8),
(20, 'handler:AdmStudents', 8),
(21, 'handler:AdmTeachers', 8),
(22, 'handler:GetHelp', 1),
(23, 'handler:Map', 4),
(24, 'handler:Rating', 4),
PavelBegunkov's avatar
PavelBegunkov committed
(25, 'handler:Settings', 1),
(26, 'teacher:exam', 4),
RomanSteinberg's avatar
RomanSteinberg committed
(27, 'dean_office:index', 16);
PavelBegunkov's avatar
PavelBegunkov committed

INSERT INTO `general_settings` (`ID`, `Val`, `ValS`) VALUES
(1, 1, NULL),
(2, NULL, 'sdhrhsdrh');

PavelBegunkov's avatar
PavelBegunkov committed
--
PavelBegunkov's avatar
PavelBegunkov committed
-- Ограничения внешнего ключа сохраненных таблиц
PavelBegunkov's avatar
PavelBegunkov committed
-- Ограничения внешнего ключа таблицы `accounts`
PavelBegunkov's avatar
PavelBegunkov committed
--
PavelBegunkov's avatar
PavelBegunkov committed
ALTER TABLE `accounts`
  ADD CONSTRAINT `accounts_ibfk_1` FOREIGN KEY (`UserRoleID`) REFERENCES `user_roles` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed

--
-- Ограничения внешнего ключа таблицы `departments`
--
ALTER TABLE `departments`
  ADD CONSTRAINT `departments_ibfk_1` FOREIGN KEY (`FacultyID`) REFERENCES `faculties` (`ID`);

--
-- Ограничения внешнего ключа таблицы `disciplines`
--
ALTER TABLE `disciplines`
PavelBegunkov's avatar
PavelBegunkov committed
  ADD CONSTRAINT `disciplines_ibfk_1` FOREIGN KEY (`SubjectID`) REFERENCES `subjects` (`ID`),
  ADD CONSTRAINT `disciplines_ibfk_2` FOREIGN KEY (`SemesterID`) REFERENCES `semesters` (`ID`),
  ADD CONSTRAINT `disciplines_ibfk_3` FOREIGN KEY (`AuthorID`) REFERENCES `teachers` (`ID`),
  ADD CONSTRAINT `disciplines_ibfk_4` FOREIGN KEY (`FacultyID`) REFERENCES `faculties` (`ID`),
  ADD CONSTRAINT `disciplines_ibfk_5` FOREIGN KEY (`GradeID`) REFERENCES `grades` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed
--
-- Ограничения внешнего ключа таблицы `disciplines_groups`
--
ALTER TABLE `disciplines_groups`
  ADD CONSTRAINT `disciplines_groups_ibfk_1` FOREIGN KEY (`DisciplineID`) REFERENCES `disciplines` (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  ADD CONSTRAINT `disciplines_groups_ibfk_2` FOREIGN KEY (`GroupID`) REFERENCES `study_groups` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed

--
-- Ограничения внешнего ключа таблицы `disciplines_students`
--
ALTER TABLE `disciplines_students`
  ADD CONSTRAINT `disciplines_students_ibfk_1` FOREIGN KEY (`DisciplineID`) REFERENCES `disciplines` (`ID`),
  ADD CONSTRAINT `disciplines_students_ibfk_2` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`);

PavelBegunkov's avatar
PavelBegunkov committed
--
-- Ограничения внешнего ключа таблицы `disciplines_teachers`
--
ALTER TABLE `disciplines_teachers`
  ADD CONSTRAINT `disciplines_teachers_ibfk_1` FOREIGN KEY (`DisciplineID`) REFERENCES `disciplines` (`ID`),
  ADD CONSTRAINT `disciplines_teachers_ibfk_2` FOREIGN KEY (`TeacherID`) REFERENCES `teachers` (`ID`);

--
PavelBegunkov's avatar
PavelBegunkov committed
-- Ограничения внешнего ключа таблицы `logs_rating`
PavelBegunkov's avatar
PavelBegunkov committed
--
PavelBegunkov's avatar
PavelBegunkov committed
ALTER TABLE `logs_rating`
  ADD CONSTRAINT `logs_rating_ibfk_1` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`),
  ADD CONSTRAINT `logs_rating_ibfk_2` FOREIGN KEY (`SubmoduleID`) REFERENCES `submodules` (`ID`),
  ADD CONSTRAINT `logs_rating_ibfk_3` FOREIGN KEY (`TeacherID`) REFERENCES `teachers` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed
--
-- Ограничения внешнего ключа таблицы `logs_signin`
--
ALTER TABLE `logs_signin`
  ADD CONSTRAINT `logs_signin_ibfk_1` FOREIGN KEY (`AccountID`) REFERENCES `accounts` (`ID`);


PavelBegunkov's avatar
PavelBegunkov committed
--
-- Ограничения внешнего ключа таблицы `recovery_tokens`
--
ALTER TABLE `recovery_tokens`
  ADD CONSTRAINT `recovery_tokens_ibfk_1` FOREIGN KEY (`AccountID`) REFERENCES `accounts` (`ID`);


PavelBegunkov's avatar
PavelBegunkov committed

PavelBegunkov's avatar
PavelBegunkov committed
--
-- Ограничения внешнего ключа таблицы `modules`
--
ALTER TABLE `modules`
PavelBegunkov's avatar
PavelBegunkov committed
  ADD CONSTRAINT `modules_ibfk_1` FOREIGN KEY (`DisciplineID`) REFERENCES `disciplines` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed

--
-- Ограничения внешнего ключа таблицы `rating_table`
--
ALTER TABLE `rating_table`
  ADD CONSTRAINT `rating_table_ibfk_1` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  ADD CONSTRAINT `rating_table_ibfk_2` FOREIGN KEY (`SubmoduleID`) REFERENCES `submodules` (`ID`),
  ADD CONSTRAINT `rating_table_ibfk_3` FOREIGN KEY (`TeacherID`) REFERENCES `teachers` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed

-- CHANGE:
-- --
-- -- Ограничения внешнего ключа таблицы `requests`
-- --

-- ALTER TABLE `requests`
--   ADD CONSTRAINT `requests_ibfk_1` FOREIGN KEY (`AccountID`) REFERENCES `accounts` (`ID`) ON DELETE SET NULL ON UPDATE SET NULL;
PavelBegunkov's avatar
PavelBegunkov committed
-- Ограничения внешнего ключа таблицы `specializations`
PavelBegunkov's avatar
PavelBegunkov committed
--
PavelBegunkov's avatar
PavelBegunkov committed
ALTER TABLE `specializations`
  ADD CONSTRAINT `specializations_ibfk_1` FOREIGN KEY (`FacultyID`) REFERENCES `faculties` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed

--
-- Ограничения внешнего ключа таблицы `students`
--
ALTER TABLE `students`
  ADD CONSTRAINT `students_ibfk_2` FOREIGN KEY (`AccountID`) REFERENCES `accounts` (`ID`);

--
-- Ограничения внешнего ключа таблицы `study_groups`
--
ALTER TABLE `study_groups`
PavelBegunkov's avatar
PavelBegunkov committed
  ADD CONSTRAINT `study_groups_ibfk_1` FOREIGN KEY (`SpecializationID`) REFERENCES `specializations` (`ID`),
  ADD CONSTRAINT `study_groups_ibfk_2` FOREIGN KEY (`GradeID`) REFERENCES `grades` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed

--
-- Ограничения внешнего ключа таблицы `submodules`
--
ALTER TABLE `submodules`
  ADD CONSTRAINT `submodules_ibfk_1` FOREIGN KEY (`ModuleID`) REFERENCES `modules` (`ID`);

--
-- Ограничения внешнего ключа таблицы `teachers`
--
ALTER TABLE `teachers`
PavelBegunkov's avatar
PavelBegunkov committed
  ADD CONSTRAINT `teachers_ibfk_1` FOREIGN KEY (`AccountID`) REFERENCES `accounts` (`ID`),
PavelBegunkov's avatar
PavelBegunkov committed
  ADD CONSTRAINT `teachers_ibfk_2` FOREIGN KEY (`DepartmentID`) REFERENCES `departments` (`ID`),
  ADD CONSTRAINT `teachers_ibfk_3` FOREIGN KEY (`JobPositionID`) REFERENCES `job_positions` (`ID`);
PavelBegunkov's avatar
PavelBegunkov committed


--
-- Ограничения внешнего ключа таблицы `subjects_faculties`
--
ALTER TABLE `subjects_faculties`
  ADD CONSTRAINT `subjects_faculties_ibfk_1` FOREIGN KEY (`FacultyID`) REFERENCES `faculties` (`ID`),
  ADD CONSTRAINT `subjects_faculties_ibfk_2` FOREIGN KEY (`SubjectID`) REFERENCES `subjects` (`ID`);


PavelBegunkov's avatar
PavelBegunkov committed
--
-- Ограничения внешнего ключа таблицы `students_groups`
--
ALTER TABLE  `students_groups`
  ADD CONSTRAINT `students_groups_ibfk_1` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`),
  ADD CONSTRAINT `students_groups_ibfk_2` FOREIGN KEY (`GroupID`) REFERENCES `study_groups` (`ID`),
  ADD CONSTRAINT `students_groups_ibfk_3` FOREIGN KEY (`SemesterID`) REFERENCES `semesters` (`ID`);


--
-- Ограничения внешнего ключа таблицы `session_options`
--
ALTER TABLE `session_options`
  ADD CONSTRAINT `session_options_ibfk_2` FOREIGN KEY (`StudentID`) REFERENCES `students` (`ID`),
  ADD CONSTRAINT `session_options_ibfk_1` FOREIGN KEY (`SubmoduleID`) REFERENCES `submodules` (`ID`);


PavelBegunkov's avatar
PavelBegunkov committed

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