-- http://www.phpmyadmin.net
--
-- Serveur: localhost
-- Généré le : Lun 24 Octobre 2011 à 16:33
-- Version du serveur: 5.1.41
-- Version de PHP: 5.3.2-1ubuntu4.10




--
-- Base de données: `cdc`
--

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

--
-- Structure de la table `belong`
--

CREATE TABLE IF NOT EXISTS `belong` (
  `id_message` int(11) NOT NULL,
  `id_report` int(11) NOT NULL,
  `id_recipient` int(11) NOT NULL,
  `validation` tinyint(1) NOT NULL,
  `validation_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id_message`,`id_report`),
  KEY `fk_message_has_school_report_school_report` (`id_report`),
  KEY `fk_message_has_school_report_message` (`id_message`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Contenu de la table `belong`
--


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

--
-- Structure de la table `config`
--

CREATE TABLE IF NOT EXISTS `config` (
  `rules` text CHARACTER SET latin1 NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Contenu de la table `config`
--


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

--
-- Structure de la table `connection`
--

CREATE TABLE IF NOT EXISTS `connection` (
  `id_connection` int(11) NOT NULL AUTO_INCREMENT,
  `date_connection` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `ip` varchar(15) DEFAULT NULL,
  `id_user` int(11) NOT NULL,
  PRIMARY KEY (`id_connection`,`id_user`),
  KEY `fk_connection_user` (`id_user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- Contenu de la table `connection`
--


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

--
-- Structure de la table `discipline`
--

CREATE TABLE IF NOT EXISTS `discipline` (
  `id_discipline` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id_discipline`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- Contenu de la table `discipline`
--


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

--
-- Structure de la table `level`
--

CREATE TABLE IF NOT EXISTS `level` (
  `id_level` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL,
  `id_teacher` int(11) NOT NULL,
  PRIMARY KEY (`id_level`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- Contenu de la table `level`
--


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

--
-- Structure de la table `member_of_level`
--

CREATE TABLE IF NOT EXISTS `member_of_level` (
  `id_level` int(11) NOT NULL,
  `id_user` int(11) NOT NULL,
  PRIMARY KEY (`id_level`,`id_user`),
  KEY `fk_member_of_level_level` (`id_user`),
  KEY `fk_member_of_level_user` (`id_user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Contenu de la table `member_of_level`
--


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

--
-- Structure de la table `message`
--

CREATE TABLE IF NOT EXISTS `message` (
  `id_message` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(50) DEFAULT NULL,
  `content` varchar(255) DEFAULT NULL,
  `transmitter` int(11) NOT NULL,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `id_type` int(11) NOT NULL,
  PRIMARY KEY (`id_message`,`id_type`),
  KEY `fk_message_type` (`id_type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- Contenu de la table `message`
--


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

--
-- Structure de la table `profile`
--

CREATE TABLE IF NOT EXISTS `profile` (
  `id_profile` tinyint(1) unsigned NOT NULL,
  `grade` varchar(35) DEFAULT NULL,
  `have_school_report` tinyint(1) NOT NULL,
  PRIMARY KEY (`id_profile`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Contenu de la table `profile`
--

INSERT INTO `profile` (`id_profile`, `grade`, `have_school_report`) VALUES
(10, 'Élève', 1),
(20, 'Responsable', 0),
(30, 'Enseignant', 0),
(40, 'Professeur principal', 0);

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

--
-- Structure de la table `responsible`
--

CREATE TABLE IF NOT EXISTS `responsible` (
  `id_student` int(11) NOT NULL,
  `id_responsible` int(11) NOT NULL,
  PRIMARY KEY (`id_student`,`id_responsible`),
  KEY `fk_responsible` (`id_responsible`),
  KEY `fk_student` (`id_student`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Contenu de la table `responsible`
--


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

--
-- Structure de la table `school_report`
--

CREATE TABLE IF NOT EXISTS `school_report` (
  `id_report` int(11) NOT NULL AUTO_INCREMENT,
  `status` tinyint(1) DEFAULT '0',
  `id_user` int(11) NOT NULL,
  PRIMARY KEY (`id_report`,`id_user`),
  KEY `fk_school_report_id_user` (`id_user`),
  KEY `fk_user` (`id_user`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

--
-- Contenu de la table `school_report`
--


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

--
-- Structure de la table `teacher`
--

CREATE TABLE IF NOT EXISTS `teacher` (
  `id_user` int(11) NOT NULL,
  `id_discipline` int(11) NOT NULL,
  PRIMARY KEY (`id_user`,`id_discipline`),
  KEY `fk_teacher_user` (`id_user`),
  KEY `fk_teacher_discipline` (`id_discipline`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Contenu de la table `teacher`
--


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

--
-- Structure de la table `type`
--

CREATE TABLE IF NOT EXISTS `type` (
  `id_type` int(11) NOT NULL AUTO_INCREMENT,
  `wording` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id_type`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
