-- Client: localhost
-- Généré le: Jeu 16 Avril 2015 à 17:06
-- Version du serveur: 5.5.24-log
-- Version de PHP: 5.2.9-2


--
-- Base de données: `mymedia`
--
-- CREATE DATABASE IF NOT EXISTS `mymedia` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
-- USE `mymedia`;

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

--
-- Structure de la table `acl`
--

CREATE TABLE IF NOT EXISTS `acl` (
  `ACL_PK` int(11) NOT NULL AUTO_INCREMENT,
  `ACL_KEY` varchar(120) NOT NULL,
  PRIMARY KEY (`ACL_PK`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=47 ;

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

--
-- Structure de la table `acteur`
--

CREATE TABLE IF NOT EXISTS `acteur` (
  `ACTR_PK` int(11) NOT NULL AUTO_INCREMENT,
  `ACTR_FIRSTNAME` int(11) NOT NULL,
  `ACTR_LASTNAME` int(11) NOT NULL,
  `ACTR_BIRTHDATE` date NOT NULL,
  `ACTR_DESCRIPTION` text,
  PRIMARY KEY (`ACTR_PK`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

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

--
-- Structure de la table `episode`
--

CREATE TABLE IF NOT EXISTS `episode` (
  `EPI_PK` int(11) NOT NULL AUTO_INCREMENT,
  `EPI_SAI_FK` int(11) NOT NULL,
  `EPI_TITLE_FR` varchar(200) DEFAULT NULL,
  `EPI_TITLE_OR` varchar(200) DEFAULT NULL,
  `EPI_SYNOPSIS` text,
  `EPI_DATE_FR` date DEFAULT NULL,
  `EPI_DATE_OR` date DEFAULT NULL,
  `EPI_AVAILABILITY` int(11) NOT NULL DEFAULT '0',
  `EPI_EPISTT_FK` int(11) DEFAULT NULL,
  PRIMARY KEY (`EPI_PK`),
  KEY `EPI_SAI_FK` (`EPI_SAI_FK`),
  KEY `EPI_EPISTT_FK` (`EPI_EPISTT_FK`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1540 ;

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

--
-- Structure de la table `episode_personnage`
--

CREATE TABLE IF NOT EXISTS `episode_personnage` (
  `EPIPRSG_EPI_FPK` int(11) NOT NULL,
  `EPIPRSG_PRSG_FPK` int(11) NOT NULL,
  PRIMARY KEY (`EPIPRSG_EPI_FPK`,`EPIPRSG_PRSG_FPK`),
  KEY `EPIPRSG_PRSG_FPK` (`EPIPRSG_PRSG_FPK`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Structure de la table `episode_state`
--

CREATE TABLE IF NOT EXISTS `episode_state` (
  `EPISTT_PK` int(11) NOT NULL AUTO_INCREMENT,
  `EPISTT_ID` varchar(120) NOT NULL,
  PRIMARY KEY (`EPISTT_PK`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

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

--
-- Structure de la table `guestbook`
--

CREATE TABLE IF NOT EXISTS `guestbook` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(32) NOT NULL DEFAULT 'noemail@test.com',
  `comment` text,
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

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

--
-- Structure de la table `personnage`
--

CREATE TABLE IF NOT EXISTS `personnage` (
  `PRSG_PK` int(11) NOT NULL AUTO_INCREMENT,
  `PRSG_ACTR_FK` int(11) DEFAULT NULL,
  `PRSG_FIRSTNAME` varchar(120) DEFAULT NULL,
  `PRSG_LASTNAME` varchar(120) DEFAULT NULL,
  `PRSG_BIRTHDATE` date DEFAULT NULL,
  `PRSG_DESCRIPTION` text,
  PRIMARY KEY (`PRSG_PK`),
  KEY `PRSG_ACTR_FK` (`PRSG_ACTR_FK`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

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

--
-- Structure de la table `profil`
--

CREATE TABLE IF NOT EXISTS `profil` (
  `PRF_PK` int(11) NOT NULL AUTO_INCREMENT,
  `PRF_NAME` varchar(120) NOT NULL,
  PRIMARY KEY (`PRF_PK`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ;

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

--
-- Structure de la table `profil_acl`
--

CREATE TABLE IF NOT EXISTS `profil_acl` (
  `PRFACL_PRF_FPK` int(11) NOT NULL,
  `PRFACL_ACL_FPK` int(11) NOT NULL,
  PRIMARY KEY (`PRFACL_PRF_FPK`,`PRFACL_ACL_FPK`),
  KEY `PRFACL_ACL_FPK` (`PRFACL_ACL_FPK`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Structure de la table `saison`
--

CREATE TABLE IF NOT EXISTS `saison` (
  `SAI_PK` int(11) NOT NULL AUTO_INCREMENT,
  `SAI_SER_FK` int(11) NOT NULL,
  `SAI_TITLE` varchar(200) NOT NULL,
  `SAI_SYNOPSIS` text,
  PRIMARY KEY (`SAI_PK`),
  KEY `SAI_SER_FK` (`SAI_SER_FK`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=84 ;

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

--
-- Structure de la table `serie`
--

CREATE TABLE IF NOT EXISTS `serie` (
  `SER_PK` int(11) NOT NULL AUTO_INCREMENT,
  `SER_TRIGRAM` varchar(5) NOT NULL,
  `SER_NAME` varchar(120) NOT NULL,
  `SER_SYNOPSIS` text,
  PRIMARY KEY (`SER_PK`),
  UNIQUE KEY `SER_TRIGRAM` (`SER_TRIGRAM`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT AUTO_INCREMENT=29 ;

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

--
-- Structure de la table `setting`
--

CREATE TABLE IF NOT EXISTS `setting` (
  `SET_PK` int(11) NOT NULL AUTO_INCREMENT,
  `SET_KEY` varchar(50) NOT NULL,
  `SET_VALUE` varchar(200) NOT NULL,
  `SET_DESCRIPTION` text NOT NULL,
  PRIMARY KEY (`SET_PK`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;

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

--
-- Structure de la table `utilisateur`
--

CREATE TABLE IF NOT EXISTS `utilisateur` (
  `UTI_PK` int(11) NOT NULL AUTO_INCREMENT,
  `UTI_LOGIN` varchar(120) NOT NULL,
  `UTI_FIRSTNAME` varchar(200) NOT NULL,
  `UTI_LASTNAME` varchar(200) NOT NULL,
  `UTI_PASSWORD` char(32) DEFAULT NULL,
  `UTI_UTISTT_FK` int(11) NOT NULL,
  `UTI_INSCRIPTION_DATE` date NOT NULL,
  `UTI_CONNECTION_DATE` date DEFAULT NULL,
  `UTI_DATE_TOKEN` date DEFAULT NULL,
  `UTI_TOKEN` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`UTI_PK`),
  UNIQUE KEY `UTI_LOGIN` (`UTI_LOGIN`),
  KEY `UTI_UTISTT_FK` (`UTI_UTISTT_FK`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;

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

--
-- Structure de la table `utilisateur_profil`
--

CREATE TABLE IF NOT EXISTS `utilisateur_profil` (
  `UTIPRF_UTI_FPK` int(11) NOT NULL,
  `UTIPRF_PRF_FPK` int(11) NOT NULL,
  PRIMARY KEY (`UTIPRF_UTI_FPK`,`UTIPRF_PRF_FPK`),
  KEY `UTIPRF_PRF_FPK` (`UTIPRF_PRF_FPK`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

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

--
-- Structure de la table `utilisateur_state`
--

CREATE TABLE IF NOT EXISTS `utilisateur_state` (
  `UTISTT_PK` int(11) NOT NULL AUTO_INCREMENT,
  `UTISTT_ID` varchar(120) NOT NULL,
  PRIMARY KEY (`UTISTT_PK`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

--
-- Contraintes pour les tables exportées
--

--
-- Contraintes pour la table `episode`
--
ALTER TABLE `episode`
  ADD CONSTRAINT `episode_ibfk_1` FOREIGN KEY (`EPI_SAI_FK`) REFERENCES `saison` (`SAI_PK`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `episode_ibfk_2` FOREIGN KEY (`EPI_EPISTT_FK`) REFERENCES `episode_state` (`EPISTT_PK`) ON DELETE SET NULL ON UPDATE SET NULL;

--
-- Contraintes pour la table `episode_personnage`
--
ALTER TABLE `episode_personnage`
  ADD CONSTRAINT `episode_personnage_ibfk_1` FOREIGN KEY (`EPIPRSG_EPI_FPK`) REFERENCES `episode` (`EPI_PK`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `episode_personnage_ibfk_2` FOREIGN KEY (`EPIPRSG_PRSG_FPK`) REFERENCES `personnage` (`PRSG_PK`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `personnage`
--
ALTER TABLE `personnage`
  ADD CONSTRAINT `personnage_ibfk_1` FOREIGN KEY (`PRSG_ACTR_FK`) REFERENCES `acteur` (`ACTR_PK`) ON DELETE SET NULL ON UPDATE SET NULL;

--
-- Contraintes pour la table `profil_acl`
--
ALTER TABLE `profil_acl`
  ADD CONSTRAINT `profil_acl_ibfk_1` FOREIGN KEY (`PRFACL_ACL_FPK`) REFERENCES `acl` (`ACL_PK`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `profil_acl_ibfk_2` FOREIGN KEY (`PRFACL_PRF_FPK`) REFERENCES `profil` (`PRF_PK`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `saison`
--
ALTER TABLE `saison`
  ADD CONSTRAINT `saison_ibfk_1` FOREIGN KEY (`SAI_SER_FK`) REFERENCES `serie` (`SER_PK`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Contraintes pour la table `utilisateur`
--
ALTER TABLE `utilisateur`
  ADD CONSTRAINT `utilisateur_ibfk_2` FOREIGN KEY (`UTI_UTISTT_FK`) REFERENCES `utilisateur_state` (`UTISTT_PK`);

--
-- Contraintes pour la table `utilisateur_profil`
--
ALTER TABLE `utilisateur_profil`
  ADD CONSTRAINT `utilisateur_profil_ibfk_1` FOREIGN KEY (`UTIPRF_UTI_FPK`) REFERENCES `utilisateur` (`UTI_PK`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `utilisateur_profil_ibfk_2` FOREIGN KEY (`UTIPRF_PRF_FPK`) REFERENCES `profil` (`PRF_PK`) ON DELETE CASCADE ON UPDATE CASCADE;
