Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mal placé #1

Open
sixdouglas opened this issue Nov 14, 2020 · 0 comments
Open

Mal placé #1

sixdouglas opened this issue Nov 14, 2020 · 0 comments

Comments

@sixdouglas
Copy link

Ces lignes devraient être mises dans un fichier schema.sql

CREATE TABLE IF NOT EXISTS marque
(
id_marque INT NOT NULL,
nom VARCHAR(250) NOT NULL,
PRIMARY KEY(id_marque)
);
CREATE TABLE IF NOT EXISTS voiture
(
id_voiture INT NOT NULL,
id_marque INT NOT NULL,
id_client INT NOT NULL,
modele VARCHAR(250) NOT NULL,
PRIMARY KEY(id_voiture)
);
CREATE TABLE IF NOT EXISTS concessionaire
(
id_concessionaire INT NOT NULL,
nom VARCHAR(250) NOT NULL,
PRIMARY KEY(id_concessionaire)
);
CREATE TABLE IF NOT EXISTS adresse
(
id_adresse INT NOT NULL,
libelle VARCHAR(250) NOT NULL,
id_concessionaire INT NOT NULL,
PRIMARY KEY(id_adresse)
);
CREATE TABLE IF NOT EXISTS client
(
id_client INT NOT NULL,
nom VARCHAR(250) NOT NULL,
PRIMARY KEY(id_client)
);
CREATE TABLE IF NOT EXISTS mar_co
(
id_marque INT NOT NULL,
id_concessionaire INT NOT NULL,
PRIMARY KEY(id_marque, id_concessionaire)
);
ALTER TABLE voiture
ADD FOREIGN KEY (id_marque)
REFERENCES marque(id_marque)
ON DELETE CASCADE
ON UPDATE CASCADE
;
ALTER TABLE adresse
ADD FOREIGN KEY (id_concessionaire)
REFERENCES concessionaire(id_concessionaire)
ON DELETE CASCADE
ON UPDATE CASCADE
;
ALTER TABLE voiture
ADD FOREIGN KEY (id_client)
REFERENCES client(id_client)
ON DELETE CASCADE
ON UPDATE CASCADE
;
ALTER TABLE mar_co
ADD FOREIGN KEY (id_marque)
REFERENCES marque(id_marque)
ON DELETE CASCADE
ON UPDATE CASCADE
;
ALTER TABLE mar_co
ADD FOREIGN KEY (id_concessionaire)
REFERENCES concessionaire(id_concessionaire)
ON DELETE CASCADE
ON UPDATE CASCADE
;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant