SET FOREIGN_KEY_CHECKS=0;

CREATE DATABASE `test`
    CHARACTER SET 'utf8'
    COLLATE 'utf8_general_ci';

USE `test`;

#
# Structure for the `t_matiere` table : 
#

CREATE TABLE `t_matiere` (
  `idMatiere` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `matiere` varchar(30) NOT NULL,
  PRIMARY KEY (`idMatiere`),
  UNIQUE KEY `matiere` (`matiere`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 PACK_KEYS=0;

#
# Structure for the `t_ville` table : 
#

CREATE TABLE `t_ville` (
  `idVille` int(11) unsigned zerofill NOT NULL AUTO_INCREMENT,
  `ville` varchar(30) NOT NULL,
  PRIMARY KEY (`idVille`),
  UNIQUE KEY `ville` (`ville`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 PACK_KEYS=0;

#
# Structure for the `t_session` table : 
#

CREATE TABLE `t_session` (
  `idSession` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `date_` date NOT NULL,
  `idVille` int(11) unsigned NOT NULL,
  PRIMARY KEY (`idSession`),
  UNIQUE KEY `t_session_idx1` (`date_`,`idVille`),
  KEY `t_session_fk1` (`idVille`),
  KEY `date_` (`date_`),
  CONSTRAINT `t_session_fk1` FOREIGN KEY (`idVille`) REFERENCES `t_ville` (`idVille`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 PACK_KEYS=0;

#
# Structure for the `t_session_matiere` table : 
#

CREATE TABLE `t_session_matiere` (
  `idSessionMatiere` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `idSession` int(11) unsigned NOT NULL,
  `idMatiere` int(11) unsigned NOT NULL,
  `nbInscrit` int(11) unsigned NOT NULL,
  PRIMARY KEY (`idSessionMatiere`),
  UNIQUE KEY `t_session_matiere_idx1` (`idSession`,`idMatiere`),
  KEY `idSession` (`idSession`),
  KEY `idMatiere` (`idMatiere`),
  CONSTRAINT `t_session_matiere_fk1` FOREIGN KEY (`idSession`) REFERENCES `t_session` (`idSession`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `t_session_matiere_fk2` FOREIGN KEY (`idMatiere`) REFERENCES `t_matiere` (`idMatiere`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8 PACK_KEYS=0;

#
# Data for the `t_matiere` table  (LIMIT -492,500)
#

INSERT INTO `t_matiere` (`idMatiere`, `matiere`) VALUES 
  (1,'MATHEMATIQUES'),
  (2,'PHYSIQUE'),
  (3,'BIOLOGIE'),
  (4,'ANGLAIS'),
  (5,'HISTOIRE'),
  (6,'GEOGRAPHIE'),
  (7,'CHIMIE');
COMMIT;

#
# Data for the `t_ville` table  (LIMIT -495,500)
#

INSERT INTO `t_ville` (`idVille`, `ville`) VALUES 
  (00000000001,'PARIS'),
  (00000000002,'MARSEILLE'),
  (00000000003,'BORDEAUX'),
  (00000000004,'NANTES');
COMMIT;

#
# Data for the `t_session` table  (LIMIT -485,500)
#

INSERT INTO `t_session` (`idSession`, `date_`, `idVille`) VALUES 
  (1,'2011-09-05',1),
  (2,'2011-06-24',1),
  (5,'2011-06-24',2),
  (7,'2011-06-24',3),
  (8,'2011-06-24',4),
  (9,'2011-01-05',1),
  (10,'2011-01-05',2),
  (11,'2010-09-10',1),
  (12,'2010-09-10',2),
  (13,'2010-09-10',3),
  (14,'2010-09-10',4),
  (15,'2010-05-15',1),
  (16,'2010-05-15',3),
  (17,'2010-05-15',4);
COMMIT;

#
# Data for the `t_session_matiere` table  (LIMIT -467,500)
#

INSERT INTO `t_session_matiere` (`idSessionMatiere`, `idSession`, `idMatiere`, `nbInscrit`) VALUES 
  (1,1,1,545),
  (2,1,2,625),
  (3,1,3,500),
  (4,1,4,489),
  (5,1,5,145),
  (6,1,6,174),
  (7,1,7,329),
  (8,7,1,659),
  (9,7,2,159),
  (10,5,1,458),
  (11,5,2,684),
  (12,5,7,374),
  (13,8,4,286),
  (14,8,5,396),
  (15,8,6,287),
  (16,2,1,683),
  (17,2,2,657),
  (18,2,3,485),
  (19,2,4,398),
  (20,2,5,589),
  (21,2,6,412),
  (22,2,7,555),
  (23,12,4,249),
  (24,12,5,376),
  (25,12,6,488),
  (26,17,1,1000),
  (27,17,2,999),
  (28,17,3,998),
  (29,17,4,997),
  (30,17,5,996),
  (31,17,6,995),
  (32,17,7,994);
COMMIT;



/*!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 */;