1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| CREATE TABLE DP_département(
DP_ident INT AUTO_INCREMENT,
DP_numero CHAR(3) NOT NULL,
DP_nom VARCHAR(50) NOT NULL,
PRIMARY KEY(DP_ident),
UNIQUE(DP_numero)
);
CREATE TABLE CO_commune(
DP_ident INT,
CO_ident SMALLINT,
CO_insee CHAR(5) NOT NULL,
CO_nom VARCHAR(50) NOT NULL,
PRIMARY KEY(DP_ident, CO_ident),
FOREIGN KEY(DP_ident) REFERENCES DP_département(DP_ident)
);
CREATE TABLE AD_adresse(
AD_ident INT AUTO_INCREMENT,
AD_ligne1 VARCHAR(38),
AD_ligne2 VARCHAR(38),
AD_ligne3 VARCHAR(50),
AD_ligne4 VARCHAR(50),
AD_ligne5 VARCHAR(50),
DP_ident INT NOT NULL,
CO_ident SMALLINT NOT NULL,
PRIMARY KEY(AD_ident),
FOREIGN KEY(DP_ident, CO_ident) REFERENCES CO_commune(DP_ident, CO_ident)
);
CREATE TABLE BI_bien(
BI_ident INT AUTO_INCREMENT,
BI_carrez DECIMAL(5,2) NOT NULL,
BI_nb_piece SMALLINT NOT NULL,
AD_ident INT NOT NULL,
PRIMARY KEY(BI_ident),
FOREIGN KEY(AD_ident) REFERENCES AD_adresse(AD_ident)
); |
Partager