ALTER TABLE RECEPADQUALI ADD
	CONSTRAINT FKPLA01024PRATO FOREIGN KEY (CDFILAUXPRAT, CDPRATO)
		REFERENCES PRATO (CDFILAUXPRAT, CDPRATO)
/
CREATE INDEX FKPLA01024PRATO ON RECEPADQUALI (CDFILAUXPRAT, CDPRATO)
/
ALTER TABLE RECEPADQUALI ADD
	CONSTRAINT FKPLA01025PADRAOQUALIDADE FOREIGN KEY (NRPADRAOQUALIDADE)
		REFERENCES PADRAOQUALIDADE (NRPADRAOQUALIDADE)
/
CREATE INDEX FKPLA01025PADRAOQUALIDADE ON RECEPADQUALI (NRPADRAOQUALIDADE)
/
ALTER TABLE RECEPADQUALI ADD
	CONSTRAINT FKPLA01026PRODUTO FOREIGN KEY (CDPRODUTO)
		REFERENCES PRODUTO (CDPRODUTO)
/
CREATE INDEX FKPLA01026PRODUTO ON RECEPADQUALI (CDPRODUTO)
/
ALTER TABLE RECEPADQUALI ADD
	CONSTRAINT FKPLA01027UNIDMEDIDA FOREIGN KEY (SGUNIDADE)
		REFERENCES UNIDMEDIDA (SGUNIDADE)
/
CREATE INDEX FKPLA01027UNIDMEDIDA ON RECEPADQUALI (SGUNIDADE)
/
CREATE TABLE PRATPADQUALI (
	NRPRATPADQUALI			NUMBER 														NOT NULL,
	CDFILAUXPRAT			VARCHAR2(4)													NOT NULL,
	CDPRATO					VARCHAR2(10)												NOT NULL,
	NRPADRAOQUALIDADE		NUMBER														NOT NULL,
	NRCORPRIPADQ			FLOAT														NULL,
	QTPADRAOPADQ 			FLOAT 														NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_PRATPADQUALI 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_PRATPADQUALI PRIMARY KEY (NRPRATPADQUALI),
	CONSTRAINT UN_PRATPADQUALI UNIQUE (CDFILAUXPRAT, CDPRATO, NRPADRAOQUALIDADE)
)
/
ALTER TABLE PRATPADQUALI ADD
	CONSTRAINT FKPLA01028PRATO FOREIGN KEY (CDFILAUXPRAT, CDPRATO)
		REFERENCES PRATO (CDFILAUXPRAT, CDPRATO)
/
CREATE INDEX FKPLA01028PRATO ON PRATPADQUALI (CDFILAUXPRAT, CDPRATO)
/
ALTER TABLE PRATPADQUALI ADD
	CONSTRAINT FKPLA01029PADRAOQUALIDADE FOREIGN KEY (NRPADRAOQUALIDADE)
		REFERENCES PADRAOQUALIDADE (NRPADRAOQUALIDADE)
/
CREATE INDEX FKPLA01029PADRAOQUALIDADE ON PRATPADQUALI (NRPADRAOQUALIDADE)
/
CREATE TABLE PREPPRAPADQUALI (
	NRPREPPRAPADQUALI		NUMBER 														NOT NULL,
	CDFILAUXPRAT			VARCHAR2(4)													NOT NULL,
	CDPRATO					VARCHAR2(10)												NOT NULL,
	NRPADRAOQUALIDADE		NUMBER														NOT NULL,
	NRPREPPADQ				VARCHAR2(2)													NULL,
	IDPREPPADQ 				VARCHAR2(1)		DEFAULT '2'									NULL
		CONSTRAINT CKC_IDPREPPADQ CHECK (IDPREPPADQ IN ('1', '2')),
	TXPREPPADQ				CLOB														NULL,
	NMPREPPADQ				VARCHAR2(50)												NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_PREPPRAPADQUALI 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_PREPPRAPADQUALI PRIMARY KEY (NRPREPPRAPADQUALI),
	CONSTRAINT UN_PREPPRAPADQUALI UNIQUE (CDFILAUXPRAT, CDPRATO, NRPADRAOQUALIDADE, NRPREPPADQ)
)
/
ALTER TABLE PREPPRAPADQUALI ADD
	CONSTRAINT FKPLA01030PRATO FOREIGN KEY (CDFILAUXPRAT, CDPRATO)
		REFERENCES PRATO (CDFILAUXPRAT, CDPRATO)
/
CREATE INDEX FKPLA01030PRATO ON PREPPRAPADQUALI (CDFILAUXPRAT, CDPRATO)
/
ALTER TABLE PREPPRAPADQUALI ADD
	CONSTRAINT FKPLA01031PADRAOQUALIDADE FOREIGN KEY (NRPADRAOQUALIDADE)
		REFERENCES PADRAOQUALIDADE (NRPADRAOQUALIDADE)
/
CREATE INDEX FKPLA01031PADRAOQUALIDADE ON PREPPRAPADQUALI (NRPADRAOQUALIDADE)
/
CREATE TABLE CARDAPIOBASE (
	NRCARDAPIOBASE			NUMBER 														NOT NULL,
	CDCARDAPIOBASE			VARCHAR2(10)												NOT NULL,
	NRSERVICOPROPOSTA		NUMBER														NOT NULL,
	NRPADRAOQUALIDADE		NUMBER														NOT NULL,
	DTINIVIGENCIA			DATE														NOT NULL,
	DTFIMVIGENCIA			DATE														NOT NULL,
	IDCOMPLEMENTAR			VARCHAR2(1)		DEFAULT 'N'									NOT NULL
		CONSTRAINT CKC_IDCOMPLEMENTAR CHECK (IDCOMPLEMENTAR IN ('S', 'N')),
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_CARDAPIOBASE 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_CARDAPIOBASE PRIMARY KEY (NRCARDAPIOBASE),
	CONSTRAINT UN_CARDAPIOBASE UNIQUE (CDCARDAPIOBASE)
)
/
ALTER TABLE CARDAPIOBASE ADD
	CONSTRAINT FKPLA01032PADRAOQUALIDADE FOREIGN KEY (NRPADRAOQUALIDADE)
		REFERENCES PADRAOQUALIDADE (NRPADRAOQUALIDADE)
/
CREATE INDEX FKPLA01032PADRAOQUALIDADE ON CARDAPIOBASE (NRPADRAOQUALIDADE)
/
CREATE TABLE SEGMERCARDBASE (
	NRSEGMERCARDBASE		NUMBER 														NOT NULL,
	NRCARDAPIOBASE			NUMBER														NOT NULL,
	CDSEGMER				VARCHAR2(5)													NOT NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_SEGMERCARDBASE 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_SEGMERCARDBASE PRIMARY KEY (NRSEGMERCARDBASE),
	CONSTRAINT UN_SEGMERCARDBASE UNIQUE (NRCARDAPIOBASE, CDSEGMER)
)
/
ALTER TABLE SEGMERCARDBASE ADD
	CONSTRAINT FKPLA01033CARDAPIOBASE FOREIGN KEY (NRCARDAPIOBASE)
		REFERENCES CARDAPIOBASE (NRCARDAPIOBASE)
/
CREATE INDEX FKPLA01033CARDAPIOBASE ON SEGMERCARDBASE (NRCARDAPIOBASE)
/
ALTER TABLE SEGMERCARDBASE ADD
	CONSTRAINT FKPLA01034SEGMERCADO FOREIGN KEY (CDSEGMER)
		REFERENCES SEGMERCADO (CDSEGMER)
/
CREATE INDEX FKPLA01034SEGMERCADO ON SEGMERCARDBASE (CDSEGMER)
/
CREATE TABLE CARDCOMPLCARDBASE (
	NRCARDCOMPLCARDBASE		NUMBER 														NOT NULL,
	NRCARDAPIOBASE			NUMBER														NOT NULL,
	NRCARDAPIOBASECOMPL		NUMBER														NOT NULL,
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_CARDCOMPLCARDBASE 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_CARDCOMPLCARDBASE PRIMARY KEY (NRCARDCOMPLCARDBASE),
	CONSTRAINT UN_CARDCOMPLCARDBASE UNIQUE (NRCARDAPIOBASE, NRCARDAPIOBASECOMPL)
)
/
ALTER TABLE CARDCOMPLCARDBASE ADD
	CONSTRAINT FKPLA01035CARDAPIOBASE FOREIGN KEY (NRCARDAPIOBASE)
		REFERENCES CARDAPIOBASE (NRCARDAPIOBASE)
/
CREATE INDEX FKPLA01035CARDAPIOBASE ON CARDCOMPLCARDBASE (NRCARDAPIOBASE)
/
ALTER TABLE CARDCOMPLCARDBASE ADD
	CONSTRAINT FKPLA01036CARDAPIOBASE FOREIGN KEY (NRCARDAPIOBASECOMPL)
		REFERENCES CARDAPIOBASE (NRCARDAPIOBASE)
/
CREATE INDEX FKPLA01036CARDAPIOBASE ON CARDCOMPLCARDBASE (NRCARDAPIOBASECOMPL)
/
CREATE TABLE CONFIGCARDBASE (
	NRCONFIGCARDBASE		NUMBER 														NOT NULL,
	NRCARDAPIOBASE			NUMBER														NOT NULL,
	CDTIPOPRAT				VARCHAR2(2)													NOT NULL,
	DSCOMPLEMENTO			VARCHAR2(50)												NOT NULL,
	IDCLASSIFICACAO			VARCHAR2(30)												NOT NULL 
		CONSTRAINT CKC_IDCLASSIFICACAO_CNFIGCARDB CHECK (IDCLASSIFICACAO IN ('ALIMENTAR', 'LIMPEZA', 'DESCARTAVEL')),
	NRORDEM					NUMBER														NOT NULL,
	IDTEMPERATURA			VARCHAR2(30)												NULL 
		CONSTRAINT CKC_IDTEMPERATURA_CNFIGCARDB CHECK (IDTEMPERATURA IS NULL OR (IDTEMPERATURA IN ('FRIO', 'QUENTE'))),	
	NRORG 					NUMBER			DEFAULT SYS_CONTEXT('nrorg_ctx','nrorg') 	NOT NULL,
	IDATIVO 				VARCHAR2(1) 	DEFAULT 'S' 								NOT NULL
		CONSTRAINT CKC_IDATIVO_CONFIGCARDBASE 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_CONFIGCARDBASE PRIMARY KEY (NRCONFIGCARDBASE)
)
/
ALTER TABLE CONFIGCARDBASE ADD
	CONSTRAINT FKPLA01037TIPOPRAT FOREIGN KEY (CDTIPOPRAT)
		REFERENCES TIPOPRAT (CDTIPOPRAT)