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 39 40 41 42 43 44 45 46 47 48
|
Create table Etablissements
(id_etablissement integer,
nom_MM VARCHAR(255),
PRIMARY KEY (id_etablissement))
Create table Succursales
( id_succursal integer,
nom_succ VARCHAR(255),
id_etablissement integer,
PRIMARY KEY (id_succursal),
CONSTRAINT FK_succursales FOREIGN KEY (id_etablissement)
REFERENCES Etablissements(id_etablissement)
)
Create table Service
(id_service integer,
désignation_service VARCHAR(255),
PRIMARY KEY (id_service)
)
Create table Actif
(id_service integer,
id_etablissement integer,
id_succursal integer,
)
INSERT INTO Etablissements(id_etablissement, nom_MM) VALUES (1, 'etablissement_a')
INSERT INTO Etablissements(id_etablissement, nom_MM) VALUES (2, 'etablissement_b')
INSERT INTO Succursales(id_succursal, nom_succ, id_etablissement) VALUES (1, 'succursal_x', 1)
INSERT INTO Succursales(id_succursal, nom_succ, id_etablissement) VALUES (2, 'succursal_y', 1)
INSERT INTO Succursales(id_succursal, nom_succ, id_etablissement) VALUES (3, 'succursal_z', 1)
INSERT INTO Service(id_service, désignation_service) VALUES (1, 'Crédit')
INSERT INTO Service(id_service, désignation_service) VALUES (2, 'Epargne')
INSERT INTO Service(id_service, désignation_service) VALUES (3, 'Assurance')
INSERT INTO Actif(id_service, id_etablissement, id_succursal) VALUES (1, 1, NULL) --'etablissement_a'
INSERT INTO Actif(id_service, id_etablissement, id_succursal) VALUES (2, 1, NULL) --'etablissement_a'
INSERT INTO Actif(id_service, id_etablissement, id_succursal) VALUES (1, NULL, 1) --'succursal_x'
INSERT INTO Actif(id_service, id_etablissement, id_succursal) VALUES (2, NULL, 1) --'succursal_x'
INSERT INTO Actif(id_service, id_etablissement, id_succursal) VALUES (1, NULL, 2) --'succursal_y'
INSERT INTO Actif(id_service, id_etablissement, id_succursal) VALUES (3, NULL, 2) --'succursal_y'
INSERT INTO Actif(id_service, id_etablissement, id_succursal) VALUES (3, NULL, 3) --'succursal_z' |
Partager