-- Base de données : `gestisoft`

-- Table `client`
CREATE TABLE `client` (
  `idCli` int(11) NOT NULL AUTO_INCREMENT,
  `nomCli` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `prenomCli` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `mailCli` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `telCli` int(11) NOT NULL,
  `villeCli` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `rueCli` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `cpCli` int(11) NOT NULL,
  `prospect` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`idCli`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

-- Table `facture`
CREATE TABLE `facture` (
  `idFacture` int(11) NOT NULL AUTO_INCREMENT,
  `dateFact` date NOT NULL,
  `idCli` int(11) NOT NULL,
  PRIMARY KEY (`idFacture`),
  KEY `idCli` (`idCli`),
  FOREIGN KEY (`idCli`) REFERENCES `client` (`idCli`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

-- Table `ligne_facture`
CREATE TABLE `ligne_facture` (
  `idLigne` int(11) NOT NULL AUTO_INCREMENT,
  `qte` int(11) NOT NULL,
  `idFacture` int(11) NOT NULL,
  `idProduit` int(11) NOT NULL,
  PRIMARY KEY (`idLigne`),
  KEY `idFacture` (`idFacture`),
  KEY `idProduit` (`idProduit`),
  FOREIGN KEY (`idFacture`) REFERENCES `facture` (`idFacture`) ON DELETE CASCADE,
  FOREIGN KEY (`idProduit`) REFERENCES `produit` (`idProduit`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

-- Table `produit`
CREATE TABLE `produit` (
  `idProduit` int(11) NOT NULL AUTO_INCREMENT,
  `typeProduit` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `prixProduit` int(11) NOT NULL,
  `nomProduit` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `pathImg` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `descProduit` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`idProduit`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

-- Table `rdv`
CREATE TABLE `rdv` (
  `idRdv` int(11) NOT NULL AUTO_INCREMENT,
  `dateRdv` date NOT NULL,
  `idEmploye` int(11) NOT NULL,
  `idClient` int(11) NOT NULL,
  PRIMARY KEY (`idRdv`),
  KEY `idEmploye` (`idEmploye`),
  KEY `idClient` (`idClient`),
  FOREIGN KEY (`idEmploye`) REFERENCES `users` (`idEmp`) ON DELETE CASCADE,
  FOREIGN KEY (`idClient`) REFERENCES `client` (`idCli`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
