Remove MACRO_DRAFT table

This commit is contained in:
flyingscorpio@clevo 2022-07-07 18:22:14 +02:00
parent b7141411b4
commit 8f9fff8990
4 changed files with 29 additions and 32 deletions

View file

@ -9,8 +9,5 @@ import_csv_macro_table: import_csv_macro_table.mysql
split_into_tables: split_into_tables.mysql
mysql -u efrei -pefrei -D bdd_project < split_into_tables.mysql
fk_tables: fk_tables.mysql
mysql -u efrei -pefrei -D bdd_project < fk_tables.mysql
clean:
echo 'DROP DATABASE bdd_project' | sudo mysql

View file

@ -1,28 +0,0 @@
-- ------------------- --
-- MANY TO MANY TABLES --
-- ------------------- --
CREATE TABLE Bien_Nature (
Bien_id INT NOT NULL,
Nature_id INT NOT NULL,
CONSTRAINT Bien_Nature_pk PRIMARY KEY (Bien_id, Nature_id),
CONSTRAINT Bien_Nature_fk FOREIGN KEY (Nature_id) REFERENCES Nature(id),
CONSTRAINT Nature_Bien_fk FOREIGN KEY (Bien_id) REFERENCES Bien(id)
);
INSERT INTO Bien_Nature (Bien_id, Nature_id)
SELECT DISTINCT Bien_id, Nature_id
FROM MACRO_DRAFT ORDER BY id;
--
CREATE TABLE Bien_Type_local (
Type_local_id INT NOT NULL ,
Bien_id INT NOT NULL,
CONSTRAINT Bien_Type_local_pk PRIMARY KEY (Type_local_id, Bien_id),
CONSTRAINT Bien_Type_local_fk FOREIGN KEY (Type_local_id) REFERENCES Type_local(id),
CONSTRAINT Type_local_Bien_fk FOREIGN KEY (Bien_id) REFERENCES Bien(id)
);
INSERT INTO Bien_Type_local (Type_local_id, Bien_id)
SELECT DISTINCT Type_local_id, Bien_id
FROM MACRO_DRAFT ORDER BY id;
-- vim: foldmethod=indent

View file

@ -232,4 +232,33 @@ SET MACRO_DRAFT.Mutation_id = Mutation.id;
# Suppression de la colonne temporaire
ALTER TABLE Mutation DROP INDEX Temp_idx, DROP COLUMN Temp_concat;
-- ------------------- --
-- MANY TO MANY TABLES --
-- ------------------- --
CREATE TABLE Bien_Nature (
Bien_id INT NOT NULL,
Nature_id INT NOT NULL,
CONSTRAINT Bien_Nature_pk PRIMARY KEY (Bien_id, Nature_id),
CONSTRAINT Bien_Nature_fk FOREIGN KEY (Nature_id) REFERENCES Nature(id),
CONSTRAINT Nature_Bien_fk FOREIGN KEY (Bien_id) REFERENCES Bien(id)
);
INSERT INTO Bien_Nature (Bien_id, Nature_id)
SELECT DISTINCT Bien_id, Nature_id
FROM MACRO_DRAFT ORDER BY id;
--
CREATE TABLE Bien_Type_local (
Type_local_id INT NOT NULL ,
Bien_id INT NOT NULL,
CONSTRAINT Bien_Type_local_pk PRIMARY KEY (Type_local_id, Bien_id),
CONSTRAINT Bien_Type_local_fk FOREIGN KEY (Type_local_id) REFERENCES Type_local(id),
CONSTRAINT Type_local_Bien_fk FOREIGN KEY (Bien_id) REFERENCES Bien(id)
);
INSERT INTO Bien_Type_local (Type_local_id, Bien_id)
SELECT DISTINCT Type_local_id, Bien_id
FROM MACRO_DRAFT ORDER BY id;
DROP TABLE MACRO_DRAFT;
-- vim: foldmethod=indent

View file

@ -3,4 +3,3 @@ user = efrei
password = efrei
host = localhost
database = bdd_project
table = DVF2021