-- phpMyAdmin SQL Dump
-- version 4.4.13.1deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Apr 10, 2016 at 12:22 PM
-- Server version: 5.6.28-0ubuntu0.15.10.1
-- PHP Version: 5.6.11-1ubuntu3.1

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

--
-- Database: `socioview`
--

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

--
-- Table structure for table `Categories`
--

CREATE TABLE IF NOT EXISTS `Categories` (
  `idCategorie` int(11) NOT NULL,
  `intitule` varchar(32) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `Categories`
--

INSERT INTO `Categories` (`idCategorie`, `intitule`) VALUES
(1, '_CALL'),
(2, '_SMS'),
(3, '_FACEBOOK'),
(4, '_MESSENGER');

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

--
-- Table structure for table `Etudes`
--

CREATE TABLE IF NOT EXISTS `Etudes` (
  `idEtude` int(11) NOT NULL,
  `intitule` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `Etude_Personnes`
--

CREATE TABLE IF NOT EXISTS `Etude_Personnes` (
  `idEtude` int(11) NOT NULL DEFAULT '0',
  `idPersonne` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `Personnes`
--

CREATE TABLE IF NOT EXISTS `Personnes` (
  `idPersonne` int(11) NOT NULL,
  `pseudo` varchar(255) DEFAULT NULL,
  `nom` varchar(255) DEFAULT NULL,
  `prenom` varchar(255) DEFAULT NULL,
  `id_facebook` int(11) DEFAULT NULL,
  `telephone` int(11) DEFAULT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `Personnes`
--

INSERT INTO `Personnes` (`idPersonne`, `pseudo`, `nom`, `prenom`, `id_facebook`, `telephone`) VALUES
(1, 'Jeannot', '', 'Jean', NULL, NULL);

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

--
-- Table structure for table `Questions`
--

CREATE TABLE IF NOT EXISTS `Questions` (
  `idQuestion` int(11) NOT NULL,
  `intitule` text NOT NULL,
  `qualification` varchar(255) NOT NULL,
  `ihmType` int(11) NOT NULL,
  `idEtude` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `Relations`
--

CREATE TABLE IF NOT EXISTS `Relations` (
  `idPersonneA` int(11) NOT NULL,
  `idPersonneB` int(11) NOT NULL,
  `idCategorie` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `ReponsesAttendues`
--

CREATE TABLE IF NOT EXISTS `ReponsesAttendues` (
  `idReponseAttendue` int(11) NOT NULL,
  `intitule` varchar(255) NOT NULL,
  `idQuestion` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

--
-- Table structure for table `ReponsesUtilisateurs`
--

CREATE TABLE IF NOT EXISTS `ReponsesUtilisateurs` (
  `idReponseUtilisateur` int(11) NOT NULL,
  `intitule` varchar(255) NOT NULL,
  `idQuestion` int(11) NOT NULL,
  `idUtilisateur` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `Categories`
--
ALTER TABLE `Categories`
  ADD PRIMARY KEY (`idCategorie`),
  ADD UNIQUE KEY `uindex_Catégories_idCatégorie` (`idCategorie`);

--
-- Indexes for table `Etudes`
--
ALTER TABLE `Etudes`
  ADD PRIMARY KEY (`idEtude`),
  ADD UNIQUE KEY `uindex_Etudes_idEtude` (`idEtude`);

--
-- Indexes for table `Etude_Personnes`
--
ALTER TABLE `Etude_Personnes`
  ADD PRIMARY KEY (`idEtude`,`idPersonne`),
  ADD KEY `index_EP_idPersonne` (`idPersonne`);

--
-- Indexes for table `Personnes`
--
ALTER TABLE `Personnes`
  ADD PRIMARY KEY (`idPersonne`),
  ADD UNIQUE KEY `uindex_Personnes_idPersonne` (`idPersonne`);

--
-- Indexes for table `Questions`
--
ALTER TABLE `Questions`
  ADD PRIMARY KEY (`idQuestion`),
  ADD UNIQUE KEY `uindex_Questions_idQuestion` (`idQuestion`),
  ADD KEY `index_Question_idEtude` (`idEtude`);

--
-- Indexes for table `Relations`
--
ALTER TABLE `Relations`
  ADD PRIMARY KEY (`idPersonneA`,`idPersonneB`),
  ADD KEY `index_Relations_idCategorie` (`idCategorie`),
  ADD KEY `index_Relations_idUtilsateurB` (`idPersonneB`);

--
-- Indexes for table `ReponsesAttendues`
--
ALTER TABLE `ReponsesAttendues`
  ADD PRIMARY KEY (`idReponseAttendue`),
  ADD UNIQUE KEY `uindex_ReponsesAttendues_idReponseAttendue` (`idReponseAttendue`),
  ADD KEY `index_ReponsesAttendues_idQuestion` (`idQuestion`);

--
-- Indexes for table `ReponsesUtilisateurs`
--
ALTER TABLE `ReponsesUtilisateurs`
  ADD PRIMARY KEY (`idReponseUtilisateur`),
  ADD UNIQUE KEY `uindex_ReponsesUtilisateurs_idReponseUtilisateur` (`idReponseUtilisateur`),
  ADD KEY `index_ReponsesUtilisateurs` (`idQuestion`),
  ADD KEY `index_ReponsesUtilisateurs_idPersonne` (`idUtilisateur`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `Categories`
--
ALTER TABLE `Categories`
  MODIFY `idCategorie` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `Etudes`
--
ALTER TABLE `Etudes`
  MODIFY `idEtude` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `Personnes`
--
ALTER TABLE `Personnes`
  MODIFY `idPersonne` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT for table `Questions`
--
ALTER TABLE `Questions`
  MODIFY `idQuestion` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `ReponsesAttendues`
--
ALTER TABLE `ReponsesAttendues`
  MODIFY `idReponseAttendue` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `ReponsesUtilisateurs`
--
ALTER TABLE `ReponsesUtilisateurs`
  MODIFY `idReponseUtilisateur` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--

--
-- Constraints for table `Etude_Personnes`
--
ALTER TABLE `Etude_Personnes`
  ADD CONSTRAINT `fk_EP_idEtude` FOREIGN KEY (`idEtude`) REFERENCES `Etudes` (`idEtude`),
  ADD CONSTRAINT `fk_EP_idPersonne` FOREIGN KEY (`idPersonne`) REFERENCES `Personnes` (`idPersonne`);

--
-- Constraints for table `Questions`
--
ALTER TABLE `Questions`
  ADD CONSTRAINT `uindex_Question_idEtude` FOREIGN KEY (`idEtude`) REFERENCES `Etudes` (`idEtude`);

--
-- Constraints for table `Relations`
--
ALTER TABLE `Relations`
  ADD CONSTRAINT `fk_Relations_idCategorie` FOREIGN KEY (`idCategorie`) REFERENCES `Categories` (`idCategorie`),
  ADD CONSTRAINT `fk_Relations_idUtilsateurA` FOREIGN KEY (`idPersonneA`) REFERENCES `Personnes` (`idPersonne`),
  ADD CONSTRAINT `fk_Relations_idUtilsateurB` FOREIGN KEY (`idPersonneB`) REFERENCES `Personnes` (`idPersonne`);

--
-- Constraints for table `ReponsesAttendues`
--
ALTER TABLE `ReponsesAttendues`
  ADD CONSTRAINT `fk_ReponsesAttendues_idQuestion` FOREIGN KEY (`idQuestion`) REFERENCES `Questions` (`idQuestion`);

--
-- Constraints for table `ReponsesUtilisateurs`
--
ALTER TABLE `ReponsesUtilisateurs`
  ADD CONSTRAINT `fk_ReponsesUtilisateurs` FOREIGN KEY (`idQuestion`) REFERENCES `Questions` (`idQuestion`),
  ADD CONSTRAINT `fk_ReponsesUtilisateurs_idPersonne` FOREIGN KEY (`idUtilisateur`) REFERENCES `Personnes` (`idPersonne`);

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