CREATE TABLE TBCURRICULO (
    ID INTEGER NOT NULL,
    DATA DATE,
    NOME VARCHAR(100),
    DATA_NASCIMENTO DATE,
    OBJETIVO VARCHAR(50), 
    ENDERECO_LOGRADOURO VARCHAR(100),
	ENDERECO_BAIRRO VARCHAR(30),
	ENDERECO_CEP VARCHAR(8),
	ENDERECO_CIDADE VARCHAR(30),
	ENDERECO_UF CHAR(2),
    FONE_1 VARCHAR(25),
	FONE_2 VARCHAR(25),
	EMAIL VARCHAR(100),
	DOCUMENTO_CPF VARCHAR(11),
	DOCUMENTO_RG VARCHAR(20),
	ESCOLARIDADE_ID INT,
    DATA_ATUALIZACAO DATE
);

ALTER TABLE TBCURRICULO
ADD CONSTRAINT PK_TBCURRICULO
PRIMARY KEY (ID);

CREATE SEQUENCE GTBCURRICULO;

CREATE TRIGGER TBCURRICULO_B01I FOR TBCURRICULO
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GTBCURRICULO,1);
END;



--TBCURRICULO_EXPERIENCIA-----------------------------------------------


CREATE TABLE TBCURRICULO_EXPERIENCIA (
    ID INTEGER NOT NULL,
    EMPRESA VARCHAR(100) NOT NULL,
    CARGO_ID INT,
    DATA_INICIAL DATE, 
    DATA_FINAL DATE, 
    SITUACAO CHAR(1),
    DATA_ATUALIZACAO DATE,
    CURRICULO_ID INTEGER NOT NULL
);

ALTER TABLE TBCURRICULO_EXPERIENCIA
ADD CONSTRAINT PK_TBCURRICULO_EXPERIENCIA
PRIMARY KEY (ID);

CREATE SEQUENCE GTBCURRICULO_EXPERIENCIA;

CREATE TRIGGER TTBCURRICULO_EXPERIENCIA_B01I FOR TBCURRICULO_EXPERIENCIA
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GTBCURRICULO_EXPERIENCIA,1);
END;


--TBCURRICULO_FORMACAO----------------------------------------------------------------------

CREATE TABLE TBCURRICULO_FORMACAO (
    ID INTEGER NOT NULL,
    TIPO_CURSO CHAR(1),
    CURSO VARCHAR(50),
    INSTITUICAO VARCHAR(100),
    DATA_INICIAL DATE, 
    DATA_FINAL DATE, 
    SITUACAO CHAR(1),
    DATA_ATUALIZACAO DATE,
    CURRICULO_ID INTEGER NOT NULL
);

ALTER TABLE TBCURRICULO_FORMACAO
ADD CONSTRAINT PK_TBCURRICULO_FORMACAO
PRIMARY KEY (ID);

CREATE SEQUENCE GTBCURRICULO_FORMACAO

CREATE TRIGGER TTBCURRICULO_FORMACAO_B01I FOR TBCURRICULO_FORMACAO
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GTBCURRICULO_FORMACAO,1);
END;


--TBCURRICULO_QUALIFICACAO----------------------------------------------------------------------

CREATE TABLE TBCURRICULO_QUALIFICACAO (
    ID INTEGER NOT NULL,
    CONHECIMENTO VARCHAR(100),
    CURRICULO_ID INTEGER NOT NULL
);

ALTER TABLE TBCURRICULO_QUALIFICACAO
ADD CONSTRAINT PK_TBCURRICULO_QUALIFICACAO
PRIMARY KEY (ID);

CREATE SEQUENCE GTBCURRICULO_QUALIFICACAO;

CREATE TRIGGER TTBCURRICULO_QUALIFICACAO_B01I FOR TBCURRICULO_QUALIFICACAO
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GTBCURRICULO_QUALIFICACAO,1);
END;


--TBCURRICULO_EXPERIENCIA_DETALHE--------------------------------------------------------------

CREATE TABLE TBCURRICULO_EXPERIENCIA_DETALHE (
    ID INTEGER NOT NULL,
    ATIVIDADES VARCHAR(100),
    CURRICULO_EXPERIENCIA_ID INTEGER NOT NULL
);

ALTER TABLE TBCURRICULO_EXPERIENCIA_DETALHE
ADD CONSTRAINT PK_TBCURRICULO_EXP_DETALHE
PRIMARY KEY (ID);

CREATE SEQUENCE GTBCURRICULO_EXPERIENCIA_DETALHE;

CREATE TRIGGER TTBCURRICULO_EXPERIENCIA_DETALHE_B01I FOR TBCURRICULO_EXPERIENCIA_DETALHE
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GTBCURRICULO_EXPERIENCIA_DETALHE,1);
END;


--TBCURRICULO_FORMACAO_DETALHE----------------------------------------------------------------

CREATE TABLE TBCURRICULO_FORMACAO_DETALHE (
    ID INTEGER NOT NULL,
    DISCIPLINA VARCHAR(100),
    CURRICULO_EXPERIENCIA_ID INTEGER NOT NULL
);

ALTER TABLE TBCURRICULO_FORMACAO_DETALHE
ADD CONSTRAINT PK_TBCURRICULO_FORMA_DETALHE
PRIMARY KEY (ID);


CREATE SEQUENCE GTBCURRICULO_FORMA_DETALHE;

CREATE TRIGGER TTBCURRICULO_EXPERIENCIA_DETALHE_B01I FOR TBCURRICULO_FORMACAO_DETALHE
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
  IF (NEW.ID IS NULL) THEN
    NEW.ID = GEN_ID(GTBCURRICULO_FORMA_DETALHE,1);
END;































