--
-- Selected TOC Entries:
--
DROP INDEX "empresa_razao_razao_social_key";
DROP VIEW "pessoa_usuario_nome_pais";
DROP TABLE "pga_layout";
DROP TABLE "venda";
DROP TABLE "compra_produto";
DROP TABLE "compra";
DROP TABLE "email";
DROP TABLE "usuario";
DROP TABLE "cep";
DROP TABLE "pais";
DROP TABLE "venda_produto";
DROP TABLE "produto_catprod";
DROP TABLE "catproduto";
DROP TABLE "produto";
DROP TABLE "pessoa_empresa";
DROP TABLE "empresa_razao";
DROP TABLE "empresa_catempresa";
DROP TABLE "catempresa";
DROP TABLE "empresa";
DROP TABLE "pessoa_catpessoa";
DROP TABLE "catpessoa";
DROP TABLE "pessoa";
DROP TABLE "pga_schema";
DROP TABLE "pga_reports";
DROP TABLE "pga_scripts";
DROP TABLE "pga_forms";
DROP TABLE "pga_queries";
--
-- TOC Entry ID 2 (OID 29100)
--
-- Name: pga_queries Type: TABLE Owner: postgres
--

CREATE TABLE "pga_queries" (
	"queryname" character varying(64),
	"querytype" character(1),
	"querycommand" text,
	"querytables" text,
	"querylinks" text,
	"queryresults" text,
	"querycomments" text
);

--
-- TOC Entry ID 3 (OID 29100)
--
-- Name: pga_queries Type: ACL Owner: 
--

REVOKE ALL on "pga_queries" from PUBLIC;
GRANT ALL on "pga_queries" to PUBLIC;
GRANT ALL on "pga_queries" to "postgres";

--
-- TOC Entry ID 4 (OID 29105)
--
-- Name: pga_forms Type: TABLE Owner: postgres
--

CREATE TABLE "pga_forms" (
	"formname" character varying(64),
	"formsource" text
);

--
-- TOC Entry ID 5 (OID 29105)
--
-- Name: pga_forms Type: ACL Owner: 
--

REVOKE ALL on "pga_forms" from PUBLIC;
GRANT ALL on "pga_forms" to PUBLIC;
GRANT ALL on "pga_forms" to "postgres";

--
-- TOC Entry ID 6 (OID 29110)
--
-- Name: pga_scripts Type: TABLE Owner: postgres
--

CREATE TABLE "pga_scripts" (
	"scriptname" character varying(64),
	"scriptsource" text
);

--
-- TOC Entry ID 7 (OID 29110)
--
-- Name: pga_scripts Type: ACL Owner: 
--

REVOKE ALL on "pga_scripts" from PUBLIC;
GRANT ALL on "pga_scripts" to PUBLIC;
GRANT ALL on "pga_scripts" to "postgres";

--
-- TOC Entry ID 8 (OID 29115)
--
-- Name: pga_reports Type: TABLE Owner: postgres
--

CREATE TABLE "pga_reports" (
	"reportname" character varying(64),
	"reportsource" text,
	"reportbody" text,
	"reportprocs" text,
	"reportoptions" text
);

--
-- TOC Entry ID 9 (OID 29115)
--
-- Name: pga_reports Type: ACL Owner: 
--

REVOKE ALL on "pga_reports" from PUBLIC;
GRANT ALL on "pga_reports" to PUBLIC;
GRANT ALL on "pga_reports" to "postgres";

--
-- TOC Entry ID 10 (OID 29120)
--
-- Name: pga_schema Type: TABLE Owner: postgres
--

CREATE TABLE "pga_schema" (
	"schemaname" character varying(64),
	"schematables" text,
	"schemalinks" text
);

--
-- TOC Entry ID 11 (OID 29120)
--
-- Name: pga_schema Type: ACL Owner: 
--

REVOKE ALL on "pga_schema" from PUBLIC;
GRANT ALL on "pga_schema" to PUBLIC;
GRANT ALL on "pga_schema" to "postgres";

--
-- TOC Entry ID 12 (OID 29918)
--
-- Name: pessoa Type: TABLE Owner: ivens
--

CREATE TABLE "pessoa" (
	"rg" character varying(9) NOT NULL,
	"nome" character varying(100) NOT NULL,
	Constraint "pessoa_pkey" Primary Key ("rg")
);

--
-- TOC Entry ID 13 (OID 29921)
--
-- Name: catpessoa Type: TABLE Owner: ivens
--

CREATE TABLE "catpessoa" (
	"categoria" character varying(30) NOT NULL,
	"desconto" numeric(6,3) DEFAULT '0.0',
	Constraint "catpessoa_pkey" Primary Key ("categoria")
);

--
-- TOC Entry ID 14 (OID 29924)
--
-- Name: pessoa_catpessoa Type: TABLE Owner: ivens
--

CREATE TABLE "pessoa_catpessoa" (
	"rg" character varying(9) NOT NULL,
	"categoria" character varying(30) NOT NULL,
	Constraint "pessoa_catpessoa_pkey" Primary Key ("rg", "categoria")
);

--
-- TOC Entry ID 15 (OID 29927)
--
-- Name: empresa Type: TABLE Owner: ivens
--

CREATE TABLE "empresa" (
	"cnpj" integer NOT NULL,
	"nome_fantasia" character varying(100) NOT NULL,
	"home_page" character varying(200),
	Constraint "empresa_pkey" Primary Key ("cnpj")
);

--
-- TOC Entry ID 16 (OID 29930)
--
-- Name: catempresa Type: TABLE Owner: ivens
--

CREATE TABLE "catempresa" (
	"categoria" character varying(30) NOT NULL,
	"desconto" numeric(6,3),
	Constraint "catempresa_pkey" Primary Key ("categoria")
);

--
-- TOC Entry ID 17 (OID 29933)
--
-- Name: empresa_catempresa Type: TABLE Owner: ivens
--

CREATE TABLE "empresa_catempresa" (
	"cnpj" integer NOT NULL,
	"categoria" character varying(30) NOT NULL,
	Constraint "empresa_catempresa_pkey" Primary Key ("cnpj", "categoria")
);

--
-- TOC Entry ID 18 (OID 29936)
--
-- Name: empresa_razao Type: TABLE Owner: ivens
--

CREATE TABLE "empresa_razao" (
	"cnpj" integer NOT NULL,
	"razao_social" character varying(100),
	Constraint "empresa_razao_pkey" Primary Key ("cnpj")
);

--
-- TOC Entry ID 19 (OID 29939)
--
-- Name: pessoa_empresa Type: TABLE Owner: ivens
--

CREATE TABLE "pessoa_empresa" (
	"rg" character varying(9) NOT NULL,
	"cnpj" integer NOT NULL,
	Constraint "pessoa_empresa_pkey" Primary Key ("rg", "cnpj")
);

--
-- TOC Entry ID 20 (OID 29942)
--
-- Name: produto Type: TABLE Owner: ivens
--

CREATE TABLE "produto" (
	"codigo" integer NOT NULL,
	"nome" character varying(100) NOT NULL,
	"descricao" character varying(200),
	"figura" character varying(200),
	"preco" numeric(12,2),
	"desconto" numeric(6,3),
	"estoque" numeric(20,5) DEFAULT '0.0',
	Constraint "produto_pkey" Primary Key ("codigo")
);

--
-- TOC Entry ID 21 (OID 29945)
--
-- Name: catproduto Type: TABLE Owner: ivens
--

CREATE TABLE "catproduto" (
	"categoria" character varying(30) NOT NULL,
	"desconto" numeric(6,3),
	Constraint "catproduto_pkey" Primary Key ("categoria")
);

--
-- TOC Entry ID 22 (OID 29948)
--
-- Name: produto_catprod Type: TABLE Owner: ivens
--

CREATE TABLE "produto_catprod" (
	"produto" integer NOT NULL,
	"categoria" character varying(30) NOT NULL,
	Constraint "produto_catprod_pkey" Primary Key ("produto", "categoria")
);

--
-- TOC Entry ID 23 (OID 29951)
--
-- Name: venda_produto Type: TABLE Owner: ivens
--

CREATE TABLE "venda_produto" (
	"venda" integer NOT NULL,
	"produto" integer NOT NULL,
	"quantidade" numeric(20,5),
	"preco" numeric(12,2),
	"desconto" numeric(6,3),
	Constraint "venda_produto_pkey" Primary Key ("venda", "produto")
);

--
-- TOC Entry ID 24 (OID 29954)
--
-- Name: pais Type: TABLE Owner: ivens
--

CREATE TABLE "pais" (
	"codigo" character(3) NOT NULL,
	"nome" character varying(100) NOT NULL,
	Constraint "pais_pkey" Primary Key ("codigo")
);

--
-- TOC Entry ID 25 (OID 29957)
--
-- Name: cep Type: TABLE Owner: ivens
--

CREATE TABLE "cep" (
	"cep" character varying(8) NOT NULL,
	"pais" character(3) NOT NULL,
	"cidade" character varying(100) NOT NULL,
	"estado" character varying(100) NOT NULL,
	Constraint "cep_pkey" Primary Key ("cep", "pais")
);

--
-- TOC Entry ID 26 (OID 29960)
--
-- Name: usuario Type: TABLE Owner: ivens
--

CREATE TABLE "usuario" (
	"login" character varying(20) NOT NULL,
	"senha" character varying(20) NOT NULL,
	"endereco" character varying(200) NOT NULL,
	"pais" character(3) NOT NULL,
	"cep" character varying(8) NOT NULL,
	"telefone" character varying(20) NOT NULL,
	"cnpj" integer,
	"rg" character varying(9),
	"tipo" integer NOT NULL,
	Constraint "usuario_pkey" Primary Key ("login")
);

--
-- TOC Entry ID 27 (OID 29963)
--
-- Name: email Type: TABLE Owner: ivens
--

CREATE TABLE "email" (
	"login" character varying(20) NOT NULL,
	"email" character varying(200),
	Constraint "email_pkey" Primary Key ("login")
);

--
-- TOC Entry ID 28 (OID 29966)
--
-- Name: compra Type: TABLE Owner: ivens
--

CREATE TABLE "compra" (
	"codigo" integer NOT NULL,
	"fornecedor" character varying(20) NOT NULL,
	"receptor" character varying(20) NOT NULL,
	"data" timestamp with time zone,
	Constraint "compra_pkey" Primary Key ("codigo")
);

--
-- TOC Entry ID 29 (OID 29969)
--
-- Name: compra_produto Type: TABLE Owner: ivens
--

CREATE TABLE "compra_produto" (
	"compra" integer NOT NULL,
	"produto" integer NOT NULL,
	"quantidade" numeric(20,5),
	"preco" numeric(12,2),
	Constraint "compra_produto_pkey" Primary Key ("compra", "produto")
);

--
-- TOC Entry ID 30 (OID 29972)
--
-- Name: venda Type: TABLE Owner: ivens
--

CREATE TABLE "venda" (
	"codigo" integer NOT NULL,
	"cliente" character varying(20) NOT NULL,
	"vendedor" character varying(20) NOT NULL,
	"data" timestamp with time zone,
	"desconto" numeric(6,3) DEFAULT '0.0',
	Constraint "venda_pkey" Primary Key ("codigo")
);

--
-- TOC Entry ID 31 (OID 29975)
--
-- Name: pga_layout Type: TABLE Owner: ivens
--

CREATE TABLE "pga_layout" (
	"tablename" character varying(64),
	"nrcols" smallint,
	"colnames" text,
	"colwidth" text
);

--
-- TOC Entry ID 32 (OID 29975)
--
-- Name: pga_layout Type: ACL Owner: 
--

REVOKE ALL on "pga_layout" from PUBLIC;
GRANT ALL on "pga_layout" to PUBLIC;
GRANT ALL on "pga_layout" to "ivens";

--
-- TOC Entry ID 33 (OID 29982)
--
-- Name: pessoa_usuario_nome_pais Type: VIEW Owner: ivens
--

CREATE VIEW "pessoa_usuario_nome_pais" as SELECT usuario.login, pessoa.nome, pessoa.rg, pais.nome AS pais FROM pessoa, usuario, pais WHERE ((usuario.rg = pessoa.rg) AND (pais.codigo = usuario.pais));

--
-- Data for TOC Entry ID 35 (OID 29100)
--
-- Name: pga_queries Type: TABLE DATA Owner: postgres
--


--
-- Data for TOC Entry ID 36 (OID 29105)
--
-- Name: pga_forms Type: TABLE DATA Owner: postgres
--


--
-- Data for TOC Entry ID 37 (OID 29110)
--
-- Name: pga_scripts Type: TABLE DATA Owner: postgres
--


--
-- Data for TOC Entry ID 38 (OID 29115)
--
-- Name: pga_reports Type: TABLE DATA Owner: postgres
--


--
-- Data for TOC Entry ID 39 (OID 29120)
--
-- Name: pga_schema Type: TABLE DATA Owner: postgres
--


--
-- Data for TOC Entry ID 40 (OID 29918)
--
-- Name: pessoa Type: TABLE DATA Owner: ivens
--


INSERT INTO "pessoa" ("rg","nome") VALUES ('275133692','Ivens Prates Telles Alves');
INSERT INTO "pessoa" ("rg","nome") VALUES ('696969696','Gustavo S. Barbieri');
INSERT INTO "pessoa" ("rg","nome") VALUES ('515151515','Rafael Dantas de Castro');
--
-- Data for TOC Entry ID 41 (OID 29921)
--
-- Name: catpessoa Type: TABLE DATA Owner: ivens
--


INSERT INTO "catpessoa" ("categoria","desconto") VALUES ('Cliente Preferencial','10.000');
INSERT INTO "catpessoa" ("categoria","desconto") VALUES ('Cliente na lista negra','0.000');
INSERT INTO "catpessoa" ("categoria","desconto") VALUES ('Gerente','0.000');
INSERT INTO "catpessoa" ("categoria","desconto") VALUES ('Vendedor','0.000');
--
-- Data for TOC Entry ID 42 (OID 29924)
--
-- Name: pessoa_catpessoa Type: TABLE DATA Owner: ivens
--


INSERT INTO "pessoa_catpessoa" ("rg","categoria") VALUES ('275133692','Cliente Preferencial');
INSERT INTO "pessoa_catpessoa" ("rg","categoria") VALUES ('696969696','Cliente na lista negra');
INSERT INTO "pessoa_catpessoa" ("rg","categoria") VALUES ('515151515','Cliente Preferencial');
--
-- Data for TOC Entry ID 43 (OID 29927)
--
-- Name: empresa Type: TABLE DATA Owner: ivens
--


INSERT INTO "empresa" ("cnpj","nome_fantasia","home_page") VALUES (1234567890,'CONPEC Jr.','www.conpec.com.br');
INSERT INTO "empresa" ("cnpj","nome_fantasia","home_page") VALUES (987654321,'SeiLah Corps','www.seilah.com.br');
--
-- Data for TOC Entry ID 44 (OID 29930)
--
-- Name: catempresa Type: TABLE DATA Owner: ivens
--


INSERT INTO "catempresa" ("categoria","desconto") VALUES ('Cliente Preferencial','10.000');
INSERT INTO "catempresa" ("categoria","desconto") VALUES ('Cliente na lista negra','0.000');
--
-- Data for TOC Entry ID 45 (OID 29933)
--
-- Name: empresa_catempresa Type: TABLE DATA Owner: ivens
--


INSERT INTO "empresa_catempresa" ("cnpj","categoria") VALUES (1234567890,'Cliente na lista negra');
INSERT INTO "empresa_catempresa" ("cnpj","categoria") VALUES (987654321,'Cliente Preferencial');
--
-- Data for TOC Entry ID 46 (OID 29936)
--
-- Name: empresa_razao Type: TABLE DATA Owner: ivens
--


INSERT INTO "empresa_razao" ("cnpj","razao_social") VALUES (1234567890,'CONPEC - Consultoria, Projetos e Estudos em Computacao');
INSERT INTO "empresa_razao" ("cnpj","razao_social") VALUES (987654321,'SeiLah Corporacao');
--
-- Data for TOC Entry ID 47 (OID 29939)
--
-- Name: pessoa_empresa Type: TABLE DATA Owner: ivens
--


INSERT INTO "pessoa_empresa" ("rg","cnpj") VALUES ('275133692',1234567890);
INSERT INTO "pessoa_empresa" ("rg","cnpj") VALUES ('696969696',987654321);
INSERT INTO "pessoa_empresa" ("rg","cnpj") VALUES ('515151515',987654321);
--
-- Data for TOC Entry ID 48 (OID 29942)
--
-- Name: produto Type: TABLE DATA Owner: ivens
--


INSERT INTO "produto" ("codigo","nome","descricao","figura","preco","desconto","estoque") VALUES (2,'Requeijao Pocos de Caldas','Laticinio','REQUEIJAO.JPG','3.50','25.000','200.00000');
INSERT INTO "produto" ("codigo","nome","descricao","figura","preco","desconto","estoque") VALUES (1,'Sucrilhos','Cereal Matinal','CORN.JPG','10.00','0.000','50.00000');
INSERT INTO "produto" ("codigo","nome","descricao","figura","preco","desconto","estoque") VALUES (3,'Miojo','Macarrao Instantaneo','MIOJAO.JPG','0.60','10.000','500.00000');
INSERT INTO "produto" ("codigo","nome","descricao","figura","preco","desconto","estoque") VALUES (4,'Catchup','Tomate Estragado','catchup.jpg','2.00','5.000','75.00000');
--
-- Data for TOC Entry ID 49 (OID 29945)
--
-- Name: catproduto Type: TABLE DATA Owner: ivens
--


INSERT INTO "catproduto" ("categoria","desconto") VALUES ('Laticinios','25.000');
INSERT INTO "catproduto" ("categoria","desconto") VALUES ('Macarrao','0.000');
INSERT INTO "catproduto" ("categoria","desconto") VALUES ('Outros','0.000');
--
-- Data for TOC Entry ID 50 (OID 29948)
--
-- Name: produto_catprod Type: TABLE DATA Owner: ivens
--


INSERT INTO "produto_catprod" ("produto","categoria") VALUES (2,'Laticinios');
INSERT INTO "produto_catprod" ("produto","categoria") VALUES (3,'Macarrao');
INSERT INTO "produto_catprod" ("produto","categoria") VALUES (1,'Outros');
INSERT INTO "produto_catprod" ("produto","categoria") VALUES (4,'Outros');
--
-- Data for TOC Entry ID 51 (OID 29951)
--
-- Name: venda_produto Type: TABLE DATA Owner: ivens
--


INSERT INTO "venda_produto" ("venda","produto","quantidade","preco","desconto") VALUES (1,2,'10.00000','3.00','17.000');
INSERT INTO "venda_produto" ("venda","produto","quantidade","preco","desconto") VALUES (2,3,'20.00000','0.30','50.000');
--
-- Data for TOC Entry ID 52 (OID 29954)
--
-- Name: pais Type: TABLE DATA Owner: ivens
--


INSERT INTO "pais" ("codigo","nome") VALUES ('BRA','Brasil');
INSERT INTO "pais" ("codigo","nome") VALUES ('ARG','Argentina');
INSERT INTO "pais" ("codigo","nome") VALUES ('JAP','Japao');
--
-- Data for TOC Entry ID 53 (OID 29957)
--
-- Name: cep Type: TABLE DATA Owner: ivens
--


INSERT INTO "cep" ("cep","pais","cidade","estado") VALUES ('13073090','BRA','Campinas','Sao Paulo');
INSERT INTO "cep" ("cep","pais","cidade","estado") VALUES ('14096480','BRA','Ribeirao Preto','Sao Paulo');
INSERT INTO "cep" ("cep","pais","cidade","estado") VALUES ('99999999','JAP','Tokyo','Tokyo');
--
-- Data for TOC Entry ID 54 (OID 29960)
--
-- Name: usuario Type: TABLE DATA Owner: ivens
--


INSERT INTO "usuario" ("login","senha","endereco","pais","cep","telefone","cnpj","rg","tipo") VALUES ('ivens','blabla','Rua Votorantim no100 Bl1 Apto 112','BRA','13073090','(19) 32429695',NULL,'275133692',0);
INSERT INTO "usuario" ("login","senha","endereco","pais","cep","telefone","cnpj","rg","tipo") VALUES ('gustavo','bloblo','Rua Votorantim no100 Bl1 Apto112','BRA','13073090','(19) 32429695',NULL,'696969696',0);
INSERT INTO "usuario" ("login","senha","endereco","pais","cep","telefone","cnpj","rg","tipo") VALUES ('CONPEC','conpec','Rua Albert Einstein no 400','BRA','14096480','(19) 37883842',1234567890,NULL,1);
INSERT INTO "usuario" ("login","senha","endereco","pais","cep","telefone","cnpj","rg","tipo") VALUES ('SeiLah','lahsei','Rua Seilah no69','JAP','99999999','(69) 69696969',987654321,NULL,1);
INSERT INTO "usuario" ("login","senha","endereco","pais","cep","telefone","cnpj","rg","tipo") VALUES ('rafael','rafa','Rua XYX','BRA','14096480','(19) 1234-5678',NULL,'515151515',0);
--
-- Data for TOC Entry ID 55 (OID 29963)
--
-- Name: email Type: TABLE DATA Owner: ivens
--


INSERT INTO "email" ("login","email") VALUES ('SeiLah','seilah@seilah.com');
INSERT INTO "email" ("login","email") VALUES ('ivens','ivens.alves@ic.unicamp.br');
INSERT INTO "email" ("login","email") VALUES ('gustavo','gustavo.barbieri@ic.unicamp.br');
INSERT INTO "email" ("login","email") VALUES ('CONPEC','conpec@ic.unicamp.br');
--
-- Data for TOC Entry ID 56 (OID 29966)
--
-- Name: compra Type: TABLE DATA Owner: ivens
--


INSERT INTO "compra" ("codigo","fornecedor","receptor","data") VALUES (1,'SeiLah','ivens','2003-01-06 00:00:00-02');
INSERT INTO "compra" ("codigo","fornecedor","receptor","data") VALUES (2,'CONPEC','gustavo','2003-02-06 00:00:00-02');
--
-- Data for TOC Entry ID 57 (OID 29969)
--
-- Name: compra_produto Type: TABLE DATA Owner: ivens
--


INSERT INTO "compra_produto" ("compra","produto","quantidade","preco") VALUES (1,2,'4.00000','3.50');
INSERT INTO "compra_produto" ("compra","produto","quantidade","preco") VALUES (2,3,'20.00000','0.50');
--
-- Data for TOC Entry ID 58 (OID 29972)
--
-- Name: venda Type: TABLE DATA Owner: ivens
--


INSERT INTO "venda" ("codigo","cliente","vendedor","data","desconto") VALUES (1,'CONPEC','ivens','2003-01-06 00:00:00-02','0.000');
INSERT INTO "venda" ("codigo","cliente","vendedor","data","desconto") VALUES (2,'SeiLah','gustavo','2003-02-06 00:00:00-02','0.000');
--
-- Data for TOC Entry ID 59 (OID 29975)
--
-- Name: pga_layout Type: TABLE DATA Owner: ivens
--


INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('usuario',9,'login senha endereco pais cep telefone cnpj rg tipo','150 150 150 150 150 150 150 150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('pais',2,'codigo nome','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('cep',4,'cep pais cidade estado','150 150 150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('pessoa',2,'rg nome','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('catproduto',2,'categoria desconto','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('catpessoa',2,'categoria desconto','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('pessoa_catpessoa',2,'rg categoria','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('empresa',3,'cnpj nome_fantasia home_page','150 150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('catempresa',2,'categoria desconto','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('empresa_razao',2,'cnpj razao_social','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('pessoa_empresa',2,'rg cnpj','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('email',2,'login email','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('produto',7,'codigo nome descricao figura preco desconto estoque','150 150 150 150 150 150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('produto_catprod',2,'produto categoria','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('empresa_catempresa',2,'cnpj categoria','150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('compra',4,'codigo fornecedor receptor data','150 150 150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('compra_produto',4,'compra produto quantidade preco','150 150 150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('venda',5,'codigo cliente vendedor data desconto','150 150 150 150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('venda_produto',5,'venda produto quantidade preco desconto','150 150 150 150 150');
INSERT INTO "pga_layout" ("tablename","nrcols","colnames","colwidth") VALUES ('pessoa_usuario_nome_pais',4,'login nome rg nome','150 150 150 150');
--
-- TOC Entry ID 34 (OID 30058)
--
-- Name: "empresa_razao_razao_social_key" Type: INDEX Owner: ivens
--

CREATE UNIQUE INDEX empresa_razao_razao_social_key ON empresa_razao USING btree (razao_social);

--
-- TOC Entry ID 68 (OID 30060)
--
-- Name: "RI_ConstraintTrigger_30059" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "pessoa_catpessoa"  FROM "pessoa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'pessoa_catpessoa', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 60 (OID 30062)
--
-- Name: "RI_ConstraintTrigger_30061" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "pessoa"  FROM "pessoa_catpessoa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'pessoa_catpessoa', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 61 (OID 30064)
--
-- Name: "RI_ConstraintTrigger_30063" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "pessoa"  FROM "pessoa_catpessoa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'pessoa_catpessoa', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 69 (OID 30066)
--
-- Name: "RI_ConstraintTrigger_30065" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "pessoa_catpessoa"  FROM "catpessoa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'pessoa_catpessoa', 'catpessoa', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 66 (OID 30068)
--
-- Name: "RI_ConstraintTrigger_30067" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "catpessoa"  FROM "pessoa_catpessoa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'pessoa_catpessoa', 'catpessoa', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 67 (OID 30070)
--
-- Name: "RI_ConstraintTrigger_30069" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "catpessoa"  FROM "pessoa_catpessoa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'pessoa_catpessoa', 'catpessoa', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 80 (OID 30072)
--
-- Name: "RI_ConstraintTrigger_30071" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "empresa_catempresa"  FROM "empresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'empresa_catempresa', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 70 (OID 30074)
--
-- Name: "RI_ConstraintTrigger_30073" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "empresa"  FROM "empresa_catempresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'empresa_catempresa', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 71 (OID 30076)
--
-- Name: "RI_ConstraintTrigger_30075" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "empresa"  FROM "empresa_catempresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'empresa_catempresa', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 81 (OID 30078)
--
-- Name: "RI_ConstraintTrigger_30077" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "empresa_catempresa"  FROM "catempresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'empresa_catempresa', 'catempresa', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 78 (OID 30080)
--
-- Name: "RI_ConstraintTrigger_30079" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "catempresa"  FROM "empresa_catempresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'empresa_catempresa', 'catempresa', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 79 (OID 30082)
--
-- Name: "RI_ConstraintTrigger_30081" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "catempresa"  FROM "empresa_catempresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'empresa_catempresa', 'catempresa', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 82 (OID 30084)
--
-- Name: "RI_ConstraintTrigger_30083" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "empresa_razao"  FROM "empresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'empresa_razao', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 72 (OID 30086)
--
-- Name: "RI_ConstraintTrigger_30085" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "empresa"  FROM "empresa_razao" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'empresa_razao', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 73 (OID 30088)
--
-- Name: "RI_ConstraintTrigger_30087" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "empresa"  FROM "empresa_razao" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'empresa_razao', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 83 (OID 30090)
--
-- Name: "RI_ConstraintTrigger_30089" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "pessoa_empresa"  FROM "pessoa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'pessoa_empresa', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 62 (OID 30092)
--
-- Name: "RI_ConstraintTrigger_30091" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "pessoa"  FROM "pessoa_empresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'pessoa_empresa', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 63 (OID 30094)
--
-- Name: "RI_ConstraintTrigger_30093" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "pessoa"  FROM "pessoa_empresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'pessoa_empresa', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 84 (OID 30096)
--
-- Name: "RI_ConstraintTrigger_30095" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "pessoa_empresa"  FROM "empresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'pessoa_empresa', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 74 (OID 30098)
--
-- Name: "RI_ConstraintTrigger_30097" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "empresa"  FROM "pessoa_empresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'pessoa_empresa', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 75 (OID 30100)
--
-- Name: "RI_ConstraintTrigger_30099" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "empresa"  FROM "pessoa_empresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'pessoa_empresa', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 93 (OID 30102)
--
-- Name: "RI_ConstraintTrigger_30101" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "produto_catprod"  FROM "produto" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'produto_catprod', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 85 (OID 30104)
--
-- Name: "RI_ConstraintTrigger_30103" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "produto"  FROM "produto_catprod" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'produto_catprod', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 86 (OID 30106)
--
-- Name: "RI_ConstraintTrigger_30105" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "produto"  FROM "produto_catprod" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'produto_catprod', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 94 (OID 30108)
--
-- Name: "RI_ConstraintTrigger_30107" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "produto_catprod"  FROM "catproduto" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'produto_catprod', 'catproduto', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 91 (OID 30110)
--
-- Name: "RI_ConstraintTrigger_30109" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "catproduto"  FROM "produto_catprod" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'produto_catprod', 'catproduto', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 92 (OID 30112)
--
-- Name: "RI_ConstraintTrigger_30111" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "catproduto"  FROM "produto_catprod" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'produto_catprod', 'catproduto', 'UNSPECIFIED', 'categoria', 'categoria');

--
-- TOC Entry ID 95 (OID 30114)
--
-- Name: "RI_ConstraintTrigger_30113" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "venda_produto"  FROM "produto" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'venda_produto', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 87 (OID 30116)
--
-- Name: "RI_ConstraintTrigger_30115" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "produto"  FROM "venda_produto" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'venda_produto', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 88 (OID 30118)
--
-- Name: "RI_ConstraintTrigger_30117" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "produto"  FROM "venda_produto" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'venda_produto', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 98 (OID 30120)
--
-- Name: "RI_ConstraintTrigger_30119" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "cep"  FROM "pais" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'cep', 'pais', 'UNSPECIFIED', 'pais', 'codigo');

--
-- TOC Entry ID 96 (OID 30122)
--
-- Name: "RI_ConstraintTrigger_30121" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "pais"  FROM "cep" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'cep', 'pais', 'UNSPECIFIED', 'pais', 'codigo');

--
-- TOC Entry ID 97 (OID 30124)
--
-- Name: "RI_ConstraintTrigger_30123" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "pais"  FROM "cep" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'cep', 'pais', 'UNSPECIFIED', 'pais', 'codigo');

--
-- TOC Entry ID 101 (OID 30126)
--
-- Name: "RI_ConstraintTrigger_30125" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "usuario"  FROM "pessoa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'usuario', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 64 (OID 30128)
--
-- Name: "RI_ConstraintTrigger_30127" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "pessoa"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'usuario', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 65 (OID 30130)
--
-- Name: "RI_ConstraintTrigger_30129" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "pessoa"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'usuario', 'pessoa', 'UNSPECIFIED', 'rg', 'rg');

--
-- TOC Entry ID 102 (OID 30132)
--
-- Name: "RI_ConstraintTrigger_30131" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "usuario"  FROM "empresa" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'usuario', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 76 (OID 30134)
--
-- Name: "RI_ConstraintTrigger_30133" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "empresa"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'usuario', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 77 (OID 30136)
--
-- Name: "RI_ConstraintTrigger_30135" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "empresa"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'usuario', 'empresa', 'UNSPECIFIED', 'cnpj', 'cnpj');

--
-- TOC Entry ID 103 (OID 30138)
--
-- Name: "RI_ConstraintTrigger_30137" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "usuario"  FROM "cep" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'usuario', 'cep', 'UNSPECIFIED', 'cep', 'cep', 'pais', 'pais');

--
-- TOC Entry ID 99 (OID 30140)
--
-- Name: "RI_ConstraintTrigger_30139" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "cep"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'usuario', 'cep', 'UNSPECIFIED', 'cep', 'cep', 'pais', 'pais');

--
-- TOC Entry ID 100 (OID 30142)
--
-- Name: "RI_ConstraintTrigger_30141" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "cep"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'usuario', 'cep', 'UNSPECIFIED', 'cep', 'cep', 'pais', 'pais');

--
-- TOC Entry ID 114 (OID 30144)
--
-- Name: "RI_ConstraintTrigger_30143" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "email"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'email', 'usuario', 'UNSPECIFIED', 'login', 'login');

--
-- TOC Entry ID 104 (OID 30146)
--
-- Name: "RI_ConstraintTrigger_30145" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "usuario"  FROM "email" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'email', 'usuario', 'UNSPECIFIED', 'login', 'login');

--
-- TOC Entry ID 105 (OID 30148)
--
-- Name: "RI_ConstraintTrigger_30147" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "usuario"  FROM "email" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'email', 'usuario', 'UNSPECIFIED', 'login', 'login');

--
-- TOC Entry ID 115 (OID 30150)
--
-- Name: "RI_ConstraintTrigger_30149" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "compra"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'compra', 'usuario', 'UNSPECIFIED', 'fornecedor', 'login');

--
-- TOC Entry ID 106 (OID 30152)
--
-- Name: "RI_ConstraintTrigger_30151" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "usuario"  FROM "compra" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'compra', 'usuario', 'UNSPECIFIED', 'fornecedor', 'login');

--
-- TOC Entry ID 107 (OID 30154)
--
-- Name: "RI_ConstraintTrigger_30153" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "usuario"  FROM "compra" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'compra', 'usuario', 'UNSPECIFIED', 'fornecedor', 'login');

--
-- TOC Entry ID 116 (OID 30156)
--
-- Name: "RI_ConstraintTrigger_30155" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "compra"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'compra', 'usuario', 'UNSPECIFIED', 'receptor', 'login');

--
-- TOC Entry ID 108 (OID 30158)
--
-- Name: "RI_ConstraintTrigger_30157" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "usuario"  FROM "compra" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'compra', 'usuario', 'UNSPECIFIED', 'receptor', 'login');

--
-- TOC Entry ID 109 (OID 30160)
--
-- Name: "RI_ConstraintTrigger_30159" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "usuario"  FROM "compra" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'compra', 'usuario', 'UNSPECIFIED', 'receptor', 'login');

--
-- TOC Entry ID 117 (OID 30162)
--
-- Name: "RI_ConstraintTrigger_30161" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "compra_produto"  FROM "produto" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'compra_produto', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 89 (OID 30164)
--
-- Name: "RI_ConstraintTrigger_30163" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "produto"  FROM "compra_produto" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'compra_produto', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 90 (OID 30166)
--
-- Name: "RI_ConstraintTrigger_30165" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "produto"  FROM "compra_produto" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'compra_produto', 'produto', 'UNSPECIFIED', 'produto', 'codigo');

--
-- TOC Entry ID 118 (OID 30168)
--
-- Name: "RI_ConstraintTrigger_30167" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "venda"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'venda', 'usuario', 'UNSPECIFIED', 'cliente', 'login');

--
-- TOC Entry ID 110 (OID 30170)
--
-- Name: "RI_ConstraintTrigger_30169" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "usuario"  FROM "venda" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'venda', 'usuario', 'UNSPECIFIED', 'cliente', 'login');

--
-- TOC Entry ID 111 (OID 30172)
--
-- Name: "RI_ConstraintTrigger_30171" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "usuario"  FROM "venda" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'venda', 'usuario', 'UNSPECIFIED', 'cliente', 'login');

--
-- TOC Entry ID 119 (OID 30174)
--
-- Name: "RI_ConstraintTrigger_30173" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER INSERT OR UPDATE ON "venda"  FROM "usuario" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'venda', 'usuario', 'UNSPECIFIED', 'vendedor', 'login');

--
-- TOC Entry ID 112 (OID 30176)
--
-- Name: "RI_ConstraintTrigger_30175" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "usuario"  FROM "venda" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'venda', 'usuario', 'UNSPECIFIED', 'vendedor', 'login');

--
-- TOC Entry ID 113 (OID 30178)
--
-- Name: "RI_ConstraintTrigger_30177" Type: TRIGGER Owner: ivens
--

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "usuario"  FROM "venda" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'venda', 'usuario', 'UNSPECIFIED', 'vendedor', 'login');

