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
| CREATE TABLE client (
IdClient SERIAL,
IdEmploye INT,
Types VARCHAR(40),
Pseudo VARCHAR(50) NOT NULL,
MotDePasse VARCHAR(50) NOT NULL,
CptIntermediaire INT,
CptHonoraires INT,
PRIMARY KEY(IdClient),
FOREIGN KEY(IdEmploye) REFERENCES employe);
CREATE TABLE personne(
IdPersonne SERIAL,
IdEntreprise INT NULL UNIQUE,
IdVille INT UNIQUE,
IdCoordonne INT UNIQUE,
IdClient INT NULL UNIQUE,
IdAvocat INT NULL UNIQUE,
IdDebiteur INT NULL UNIQUE,
Nom VARCHAR(40),
Prenom VARCHAR(40),
Titre VARCHAR(20),
Adresse VARCHAR(70),
Email VARCHAR(60),
TelFixe VARCHAR(11),
TelMobile VARCHAR(11),
Fax VARCHAR(11),
PRIMARY KEY(IdPersonne),
FOREIGN KEY(IdEntreprise) REFERENCES entreprise,
FOREIGN KEY(IdVille) REFERENCES ville,
FOREIGN KEY(Idavocat) REFERENCES avocat,
FOREIGN KEY(IdCoordonne) REFERENCES coordonne ON DELETE CASCADE,
FOREIGN KEY(IdClient) REFERENCES client ON DELETE CASCADE,
FOREIGN KEY(IdDebiteur) REFERENCES debiteur ON DELETE CASCADE);
SELECT *
FROM personne INNER JOIN avocat ON personne.idavocat = avocat.idavocat; |
Partager