/* ---------------------------------------------------- */
/*  Generated by Enterprise Architect Version 16.1 		*/
/*  Created On : 24-Jun-2024 2:13:12 PM 				*/
/*  DBMS       : Oracle 						*/
/* ---------------------------------------------------- */

/* Drop Tables */

begin
	EXECUTE IMMEDIATE 'DROP TABLE   "Article" CASCADE CONSTRAINTS';
	EXCEPTION WHEN OTHERS THEN NULL;
end;
/

begin
	EXECUTE IMMEDIATE 'DROP TABLE   "LienDeNomenclature" CASCADE CONSTRAINTS';
	EXCEPTION WHEN OTHERS THEN NULL;
end;
/

/* Create Tables */

CREATE TABLE  "Article"
(
	"Reference" VARCHAR2(50) NULL,
	"Designation" VARCHAR2(50) NULL,
	"TypeFabricationAchat" VARCHAR2(50) NULL,
	"UniteAchatStock" VARCHAR2(50) NULL,
	"DelaiEnSemaine" NUMBER(8,2) NULL,
	"LotDeReapprovisionnement" NUMBER(8,2) NULL,
	"StockMini" NUMBER(8,2) NULL,
	"StockMaxi" NUMBER(8,2) NULL,
	"PrixStandard" FLOAT(126) NULL,
	"Inventaire" NUMBER(8,2) NULL,
	"ArticleID" NUMBER(8,2) NOT NULL
)
;

CREATE TABLE  "LienDeNomenclature"
(
	"QuantiteDeComposition" FLOAT(126) NULL,
	"LienDeNomenclatureID" NUMBER(8,2) NOT NULL,
	"ArticleID" NUMBER(8,2) NULL
)
;

/* Create Primary Keys, Indexes, Uniques, Checks, Triggers */

ALTER TABLE  "Article" 
 ADD CONSTRAINT "PK_Article"
	PRIMARY KEY ("ArticleID") 
 USING INDEX
;

ALTER TABLE  "LienDeNomenclature" 
 ADD CONSTRAINT "PK_LienDeNomenclature"
	PRIMARY KEY ("LienDeNomenclatureID") 
 USING INDEX
;

/* Create Foreign Key Constraints */

ALTER TABLE  "LienDeNomenclature" 
 ADD CONSTRAINT "FK_Lien de nomenclature_Article"
	FOREIGN KEY ("ArticleID") REFERENCES  "Article" ("ArticleID")
;
