SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; -- ----------------------------------------------------- -- Table `membres` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `membres` ( `id` INT NOT NULL AUTO_INCREMENT , `login` VARCHAR(20) NULL , `email` VARCHAR(150) NULL , `pass` VARCHAR(32) NULL , `date_inscription` DATETIME NULL , `ip_inscription` VARCHAR(16) NULL , `last_login` DATETIME NULL , `lvl` INT(1) NULL , `pays` VARCHAR(2) NULL , `etat` INT(1) NULL , PRIMARY KEY (`id`) ) ENGINE = InnoDB; CREATE UNIQUE INDEX `Login_unique` ON `membres` (`login` ASC) ; -- ----------------------------------------------------- -- Table `bureaux` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `bureaux` ( `id` INT NOT NULL AUTO_INCREMENT , `membres_id` INT NULL , `titre` VARCHAR(100) NULL , `description` TEXT NULL , `note` DOUBLE NULL , `classement` INT(11) NULL , `etat` INT(1) NULL , `date_ajout` DATETIME NULL , PRIMARY KEY (`id`) , CONSTRAINT `fk_bureaux_membres` FOREIGN KEY (`membres_id` ) REFERENCES `membres` (`id` )) ENGINE = InnoDB; CREATE INDEX `fk_bureaux_membres` ON `bureaux` (`membres_id` ASC) ; -- ----------------------------------------------------- -- Table `photos` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `photos` ( `id` INT NOT NULL AUTO_INCREMENT , `bureaux_id` INT NULL , `url` VARCHAR(250) NULL , `date_ajout` DATETIME NULL , `etat` INT(1) NULL , PRIMARY KEY (`id`) , CONSTRAINT `fk_photos_bureaux` FOREIGN KEY (`bureaux_id` ) REFERENCES `bureaux` (`id` )) ENGINE = InnoDB; CREATE INDEX `fk_photos_bureaux` ON `photos` (`bureaux_id` ASC) ; -- ----------------------------------------------------- -- Table `bureaux_photos` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `bureaux_photos` ( `id` INT NOT NULL AUTO_INCREMENT , `photos_id` INT NOT NULL , `bureaux_id` INT NOT NULL , `principale` INT(1) NULL DEFAULT 0 , PRIMARY KEY (`id`) , CONSTRAINT `fk_bureaux_photos_photos` FOREIGN KEY (`photos_id` ) REFERENCES `photos` (`id` ), CONSTRAINT `fk_bureaux_photos_bureaux` FOREIGN KEY (`bureaux_id` ) REFERENCES `bureaux` (`id` )) ENGINE = InnoDB; CREATE INDEX `fk_bureaux_photos_photos` ON `bureaux_photos` (`photos_id` ASC) ; CREATE INDEX `fk_bureaux_photos_bureaux` ON `bureaux_photos` (`bureaux_id` ASC) ; -- ----------------------------------------------------- -- Table `commentaires` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `commentaires` ( `id` INT NOT NULL AUTO_INCREMENT , `membres_id` INT NULL , `bureaux_id` INT NULL , `texte` TEXT NULL , `ip` VARCHAR(16) NULL , `date_ajout` DATETIME NULL , `etat` INT(1) NULL , PRIMARY KEY (`id`) , CONSTRAINT `fk_commentaires_membres` FOREIGN KEY (`membres_id` ) REFERENCES `membres` (`id` ), CONSTRAINT `fk_commentaires_bureaux` FOREIGN KEY (`bureaux_id` ) REFERENCES `bureaux` (`id` )) ENGINE = InnoDB; CREATE INDEX `fk_commentaires_membres` ON `commentaires` (`membres_id` ASC) ; CREATE INDEX `fk_commentaires_bureaux` ON `commentaires` (`bureaux_id` ASC) ; -- ----------------------------------------------------- -- Table `votes` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `votes` ( `id` INT NOT NULL AUTO_INCREMENT , `membres_id` INT NULL , `bureaux_id` INT NULL , `note` INT(2) NULL , PRIMARY KEY (`id`) , CONSTRAINT `fk_votes_membres` FOREIGN KEY (`membres_id` ) REFERENCES `membres` (`id` ), CONSTRAINT `fk_votes_bureaux` FOREIGN KEY (`bureaux_id` ) REFERENCES `bureaux` (`id` )) ENGINE = InnoDB; CREATE INDEX `fk_votes_membres` ON `votes` (`membres_id` ASC) ; CREATE INDEX `fk_votes_bureaux` ON `votes` (`bureaux_id` ASC) ; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;