100 lines
2.4 KiB
SQL
100 lines
2.4 KiB
SQL
# This is a fix for InnoDB in MySQL >= 4.1.x
|
|
# It "suspends judgement" for fkey relationships until are tables are set.
|
|
SET FOREIGN_KEY_CHECKS = 0;
|
|
|
|
-- ---------------------------------------------------------------------
|
|
-- secteur
|
|
-- ---------------------------------------------------------------------
|
|
DROP TABLE IF EXISTS `lps_secteur`;
|
|
|
|
CREATE TABLE `lps_secteur`
|
|
(
|
|
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
|
`nom` VARCHAR(50) NOT NULL
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB;
|
|
|
|
-- ---------------------------------------------------------------------
|
|
-- secteur_commune
|
|
-- ---------------------------------------------------------------------
|
|
DROP TABLE IF EXISTS `lps_secteur_commune`;
|
|
|
|
CREATE TABLE `lps_secteur_commune`
|
|
(
|
|
`id_secteur` INTEGER NOT NULL,
|
|
`zipcode` VARCHAR(10) NOT NULL
|
|
PRIMARY KEY (`id_secteur`,`zipcode`)
|
|
CONSTRAINT `fk_id_secteur`
|
|
FOREIGN KEY (`id_secteur`)
|
|
REFERENCES `lps_secteur` (`id`)
|
|
ON UPDATE RESTRICT
|
|
ON DELETE CASCADE,
|
|
CONSTRAINT `fk_zipcode`
|
|
FOREIGN KEY (`zipcode`)
|
|
REFERENCES `address` (`zipcode`)
|
|
ON UPDATE RESTRICT
|
|
ON DELETE CASCADE
|
|
) ENGINE=InnoDB;
|
|
|
|
-- ---------------------------------------------------------------------
|
|
-- secteur_horaires
|
|
-- ---------------------------------------------------------------------
|
|
DROP TABLE IF EXISTS `lps_secteur_horaires`;
|
|
|
|
CREATE TABLE `lps_secteur_horaires`
|
|
(
|
|
`id_secteur` INTEGER NOT NULL,
|
|
`jour` TINYINT NOT NULL,
|
|
`heure_debut` TIME NOT NULL,
|
|
`heure_fin` TIME NOT NULL
|
|
PRIMARY KEY (`id_secteur`,`jour`)
|
|
) ENGINE=InnoDB;
|
|
|
|
|
|
|
|
|
|
-- ---------------------------------------------------------------------
|
|
-- Insertion des données
|
|
-- ---------------------------------------------------------------------
|
|
INSERT INTO `secteur`(`id`,`nom`) VALUES
|
|
(1, 'Capso'),
|
|
(2, 'Pays de Lumbres'),
|
|
(3, 'Haut des Flanders'),
|
|
(4, 'Flandres intérieur')
|
|
);
|
|
|
|
|
|
INSERT INTO `secteur_commune`(`id_secteur`,`zipcode`) VALUES
|
|
(1,'62120'),
|
|
(1,'62129'),
|
|
(1,'62219'),
|
|
(1,'62500'),
|
|
(1,'62510'),
|
|
(1,'62570'),
|
|
(1,'62575'),
|
|
(1,'62910'),
|
|
(2,'62010'),
|
|
(2,'62024'),
|
|
(2,'62088'),
|
|
(2,'62229'),
|
|
(2,'62292'),
|
|
(2,'62309'),
|
|
(2,'62504'),
|
|
(2,'62534'),
|
|
(2,'62613'),
|
|
(2,'62656'),
|
|
(2,'62674'),
|
|
(2,'62702'),
|
|
(2,'62788'),
|
|
(2,'62794'),
|
|
(2,'62803'),
|
|
(2,'62882'),
|
|
(2,'62897'),
|
|
(2,'62898'),
|
|
(2,'62905')
|
|
);
|
|
|
|
|
|
# This restores the fkey checks, after having unset them earlier
|
|
SET FOREIGN_KEY_CHECKS = 1;
|