CREATE INDEX FKPLA01065GRAMATURACARDBASE ON ITEMGRAMCARDBASE (NRGRAMATURACARDBASE)
/
ALTER TABLE ITEMGRAMCARDBASE ADD
	CONSTRAINT FKPLA01066SUBGRUPPROD FOREIGN KEY (CDGRUPPROD, CDSUBGRPROD)
		REFERENCES SUBGRUPPROD (CDGRUPPROD, CDSUBGRPROD)
/
CREATE INDEX FKPLA01066SUBGRUPPROD ON ITEMGRAMCARDBASE (CDGRUPPROD, CDSUBGRPROD)
/
ALTER TABLE ITEMGRAMCARDBASE ADD
	CONSTRAINT FKPLA01067PRODUTO FOREIGN KEY (CDPRODUTO)
		REFERENCES PRODUTO (CDPRODUTO)
/
CREATE INDEX FKPLA01067PRODUTO ON ITEMGRAMCARDBASE (CDPRODUTO)
/
ALTER TABLE ITEMGRAMCARDBASE ADD
	CONSTRAINT FKPLA01068PORCIONAMENTO FOREIGN KEY (NRPORCIONAMENTO)
		REFERENCES PORCIONAMENTO (NRPORCIONAMENTO)
/
CREATE INDEX FKPLA01068PORCIONAMENTO ON ITEMGRAMCARDBASE (NRPORCIONAMENTO)
/
CREATE TABLE PARTSEGCARDBASE (
	NRPARTSEGCARDBASE		NUMBER 														NOT NULL,
	NRCARDAPIOBASE			NUMBER														NOT NULL,
	CDPARTSEGCARDBASE		VARCHAR2(5)													NOT NULL,
	NRATIVCLISEGMER			NUMBER														NOT NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_PARTSEGCARDBASE CHECK (IDATIVO IN ('S', 'N')),
	DTINCLUSAO 				DATE 														NULL,
	DTULTATU 				DATE 														NULL,
	NRORGINCLUSAO 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NULL,
	CDOPERINCLUSAO 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	NRORGULTATU 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')	NULL,
	CDOPERULTATU 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	CONSTRAINT PK_PARTSEGCARDBASE PRIMARY KEY (NRPARTSEGCARDBASE),
	CONSTRAINT UN_PARTSEGCARDBASE UNIQUE (NRCARDAPIOBASE, CDPARTSEGCARDBASE, NRATIVCLISEGMER)
)
/
ALTER TABLE PARTSEGCARDBASE ADD
	CONSTRAINT FKPLA01069CARDAPIOBASE FOREIGN KEY (NRCARDAPIOBASE)
		REFERENCES CARDAPIOBASE (NRCARDAPIOBASE)
/
CREATE INDEX FKPLA01069CARDAPIOBASE ON PARTSEGCARDBASE (NRCARDAPIOBASE)
/
ALTER TABLE PARTSEGCARDBASE ADD
	CONSTRAINT FKPLA01070ATIVCLISEGMER FOREIGN KEY (NRATIVCLISEGMER)
		REFERENCES ATIVCLISEGMER (NRATIVCLISEGMER)
/
CREATE INDEX FKPLA01070ATIVCLISEGMER ON PARTSEGCARDBASE (NRATIVCLISEGMER)
/
CREATE TABLE ITPARTSEGCARDBASE (
	NRITPARTSEGCARDBASE		NUMBER 														NOT NULL,
	NRPARTSEGCARDBASE		NUMBER 														NOT NULL,
	NRCONFIGCARDBASE		NUMBER 														NOT NULL,
	VRPERCENTUAL			FLOAT														NOT NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_ITPARTSEGCARDBASE CHECK (IDATIVO IN ('S', 'N')),
	DTINCLUSAO 				DATE 														NULL,
	DTULTATU 				DATE 														NULL,
	NRORGINCLUSAO 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NULL,
	CDOPERINCLUSAO 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	NRORGULTATU 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')	NULL,
	CDOPERULTATU 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	CONSTRAINT PK_ITPARTSEGCARDBASE PRIMARY KEY (NRITPARTSEGCARDBASE),
	CONSTRAINT UN_ITPARTSEGCARDBASE UNIQUE (NRPARTSEGCARDBASE, NRCONFIGCARDBASE)
)
/
ALTER TABLE ITPARTSEGCARDBASE ADD
	CONSTRAINT FKPLA01071PARTSEGCARDBASE FOREIGN KEY (NRPARTSEGCARDBASE)
		REFERENCES PARTSEGCARDBASE (NRPARTSEGCARDBASE)
/
CREATE INDEX FKPLA01071PARTSEGCARDBASE ON ITPARTSEGCARDBASE (NRPARTSEGCARDBASE)
/
ALTER TABLE ITPARTSEGCARDBASE ADD
	CONSTRAINT FKPLA01072CONFIGCARDBASE FOREIGN KEY (NRCONFIGCARDBASE)
		REFERENCES CONFIGCARDBASE (NRCONFIGCARDBASE)
/
CREATE INDEX FKPLA01072CONFIGCARDBASE ON ITPARTSEGCARDBASE (NRCONFIGCARDBASE)
/
CREATE TABLE AMOSTRACARDBASE (
	NRAMOSTRACARDBASE		NUMBER 														NOT NULL,
	NRCARDAPIOBASE			NUMBER 														NOT NULL,
	NRCONFIGCARDBASEQ		NUMBER 														NULL,
	NRCONFIGCARDBASEF		NUMBER 														NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_AMOSTRACARDBASE CHECK (IDATIVO IN ('S', 'N')),
	DTINCLUSAO 				DATE 														NULL,
	DTULTATU 				DATE 														NULL,
	NRORGINCLUSAO 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NULL,
	CDOPERINCLUSAO 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	NRORGULTATU 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')	NULL,
	CDOPERULTATU 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	CONSTRAINT PK_AMOSTRACARDBASE PRIMARY KEY (NRAMOSTRACARDBASE),
	CONSTRAINT UN_AMOSTRACARDBASE UNIQUE (NRCARDAPIOBASE)
)
/
ALTER TABLE AMOSTRACARDBASE ADD
	CONSTRAINT FKPLA01073CARDAPIOBASE FOREIGN KEY (NRCARDAPIOBASE)
		REFERENCES CARDAPIOBASE (NRCARDAPIOBASE)
/
ALTER TABLE AMOSTRACARDBASE ADD
	CONSTRAINT FKPLA01074CONFIGCARDBASE FOREIGN KEY (NRCONFIGCARDBASEQ)
		REFERENCES CONFIGCARDBASE (NRCONFIGCARDBASE)
/
CREATE INDEX FKPLA01074CONFIGCARDBASE ON AMOSTRACARDBASE (NRCONFIGCARDBASEQ)
/
ALTER TABLE AMOSTRACARDBASE ADD
	CONSTRAINT FKPLA01075CONFIGCARDBASE FOREIGN KEY (NRCONFIGCARDBASEF)
		REFERENCES CONFIGCARDBASE (NRCONFIGCARDBASE)
/
CREATE INDEX FKPLA01075CONFIGCARDBASE ON AMOSTRACARDBASE (NRCONFIGCARDBASEF)
/
CREATE TABLE DESCARTCARDBASE (
	NRDESCARTCARDBASE		NUMBER 														NOT NULL,
	NRCARDAPIOBASE			NUMBER 														NOT NULL,
	NRCONFIGCARDBASE		NUMBER 														NOT NULL,
	IDFORMACALCULO			VARCHAR2(30)												NOT NULL
		CONSTRAINT CKC_IDFORMACALCULO CHECK (IDFORMACALCULO IN ('FIXA', 'PERCAPITA')),
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_DESCARTCARDBASE CHECK (IDATIVO IN ('S', 'N')),
	DTINCLUSAO 				DATE 														NULL,
	DTULTATU 				DATE 														NULL,
	NRORGINCLUSAO 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NULL,
	CDOPERINCLUSAO 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	NRORGULTATU 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')	NULL,
	CDOPERULTATU 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	CONSTRAINT PK_DESCARTCARDBASE PRIMARY KEY (NRDESCARTCARDBASE),
	CONSTRAINT UN_DESCARTCARDBASE UNIQUE (NRCARDAPIOBASE, NRCONFIGCARDBASE)
)
/
ALTER TABLE DESCARTCARDBASE ADD
	CONSTRAINT FKPLA01076CARDAPIOBASE FOREIGN KEY (NRCARDAPIOBASE)
		REFERENCES CARDAPIOBASE (NRCARDAPIOBASE)
/
CREATE INDEX FKPLA01076CARDAPIOBASE ON DESCARTCARDBASE (NRCARDAPIOBASE)
/
ALTER TABLE DESCARTCARDBASE ADD
	CONSTRAINT FKPLA01077CONFIGCARDBASE FOREIGN KEY (NRCONFIGCARDBASE)
		REFERENCES CONFIGCARDBASE (NRCONFIGCARDBASE)
/
CREATE INDEX FKPLA01077CONFIGCARDBASE ON DESCARTCARDBASE (NRCONFIGCARDBASE)
/
CREATE TABLE LIMPEZACARDBASE (
	NRLIMPEZACARDBASE		NUMBER 														NOT NULL,
	NRCARDAPIOBASE			NUMBER 														NOT NULL,
	NRCONFIGCARDBASE		NUMBER 														NOT NULL,
	QTINICIAL				FLOAT														NOT NULL,
	QTFINAL					FLOAT														NOT NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_LIMPEZACARDBASE CHECK (IDATIVO IN ('S', 'N')),
	DTINCLUSAO 				DATE 														NULL,
	DTULTATU 				DATE 														NULL,
	NRORGINCLUSAO 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NULL,
	CDOPERINCLUSAO 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	NRORGULTATU 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')	NULL,
	CDOPERULTATU 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	CONSTRAINT PK_LIMPEZACARDBASE PRIMARY KEY (NRLIMPEZACARDBASE),
	CONSTRAINT UN_LIMPEZACARDBASE UNIQUE (NRCARDAPIOBASE, NRCONFIGCARDBASE)
)
/
ALTER TABLE LIMPEZACARDBASE ADD
	CONSTRAINT FKPLA01078CARDAPIOBASE FOREIGN KEY (NRCARDAPIOBASE)
		REFERENCES CARDAPIOBASE (NRCARDAPIOBASE)
/
CREATE INDEX FKPLA01078CARDAPIOBASE ON LIMPEZACARDBASE (NRCARDAPIOBASE)
/
ALTER TABLE LIMPEZACARDBASE ADD
	CONSTRAINT FKPLA01079CONFIGCARDBASE FOREIGN KEY (NRCONFIGCARDBASE)
		REFERENCES CONFIGCARDBASE (NRCONFIGCARDBASE)
/
CREATE INDEX FKPLA01079CONFIGCARDBASE ON LIMPEZACARDBASE (NRCONFIGCARDBASE)
/
CREATE TABLE CARDAPIOTRAB (
    NRCARDAPIOTRAB 			NUMBER														NOT NULL,
	CDREGIAO				VARCHAR2(3)													NULL,
	DTCUSTO					DATE														NOT NULL,
    CDTIPOCUSTO				VARCHAR2(3)													NOT NULL,
	IDORIGEM				VARCHAR2(30)												NOT NULL
		CONSTRAINT CKC_IDORIGEM_CARDAPIOTRAB CHECK (IDORIGEM IN ('CALCULOGN', 'PLANEJAMENTO', 'SIMULADOR')),
    NRCARDAPIOBASE			NUMBER 														NULL,
	VRPEACRESCUSTO			FLOAT														NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_CARDAPIOTRAB CHECK (IDATIVO IN ('S', 'N')),
	DTINCLUSAO 				DATE 														NULL,
	DTULTATU 				DATE 														NULL,
	NRORGINCLUSAO 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NULL,
	CDOPERINCLUSAO 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	NRORGULTATU 			NUMBER 			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg')	NULL,
	CDOPERULTATU 			VARCHAR2(12) 	DEFAULT '1' 								NULL,
	CONSTRAINT PK_CARDAPIOTRAB PRIMARY KEY (NRCARDAPIOTRAB)
)
/
ALTER TABLE CARDAPIOTRAB ADD
	CONSTRAINT FKPLA01081REGIAO FOREIGN KEY (CDREGIAO)
		REFERENCES REGIAO (CDREGIAO)
/
CREATE INDEX FKPLA01081REGIAO ON CARDAPIOTRAB (CDREGIAO)
/
ALTER TABLE CARDAPIOTRAB ADD
	CONSTRAINT FKPLA01082TIPOCUSTO FOREIGN KEY (CDTIPOCUSTO)
		REFERENCES TIPOCUSTO (CDTIPOCUSTO)
/
CREATE INDEX FKPLA01082TIPOCUSTO ON CARDAPIOTRAB (CDTIPOCUSTO)