CREATE TABLE avb_hdi.avb_passenger (
	passen_id int8 GENERATED ALWAYS AS identity NOT NULL,
	passen_first_name varchar(150) NOT NULL,
	passen_second_name varchar(150) NOT NULL,
	passen_last_name varchar(150) NOT NULL,
	passen_phone_number varchar(150) NOT NULL,
	passen_email_address varchar(150) NOT NULL,
	passen_city varchar(150) NOT NULL,
	passen_other_details varchar(150) NOT NULL
);

CREATE TABLE avb_hdi.avb_airport (
	airp_id int8 GENERATED ALWAYS AS identity NOT NULL,
	airp_airport_name varchar(150) NOT NULL,
	airp_location varchar(150) NOT NULL,
	airp_other_details varchar(150) NOT NULL
);

CREATE TABLE avb_hdi.avb_proxy (
	prox_id int8 GENERATED ALWAYS AS identity NOT NULL,
	prox_name varchar(150) NOT NULL,
	prox_details varchar(150) NOT NULL
);

CREATE TABLE avb_hdi.avb_airport_aud (
	airp_id int8 GENERATED ALWAYS AS identity NOT NULL,
	airp_airport_name varchar(150) NOT NULL,
	airp_location varchar(150) NOT NULL,
	airp_other_details varchar(150) NOT null,
	rev int4 NOT NULL,
	revtype int4 NULL
);

CREATE TABLE avb_hdi.avb_reservation (
	reser_id int8 GENERATED ALWAYS AS identity NOT NULL,
	reser_travel_type_class varchar(150) NOT NULL,
	reser_number_in_party int8 NOT NULL,
	prox_id int8 NULL,
	passen_id int8 NULL
);

CREATE TABLE avb_hdi.avb_flight (
	flig_id int8 GENERATED ALWAYS AS identity NOT NULL,
	flig_airline varchar(150) NOT NULL,
	flig_airplane varchar(150) NOT NULL,
	flig_departure_date date NOT null,
	flig_arrival_date date NOT null,
	flig_departure_time varchar(150) NOT null,
	flig_arrival_time varchar(150) NOT null,
	origin_airp_id int8 not null,
	destination_airp_id int8 not null
);

CREATE TABLE avb_hdi.avb_leg (
	leg_id int8 GENERATED ALWAYS AS identity NOT NULL,
	leg_departure_date date NOT null,
	leg_arrival_date date NOT null,
	leg_departure_time varchar(150) NOT null,
	leg_arrival_time varchar(150) NOT null,
	origin_airp_id int8 not null,
	destination_airp_id int8 not null,
	flight_flig_id int8 not null
);

CREATE TABLE avb_hdi.avb_cost (
	cost_id int8 GENERATED ALWAYS AS identity NOT NULL,
	cost_airline varchar(150) NOT NULL,
	cost_to_date varchar(150) NOT null,
	cost_from_date varchar(150) NOT null,
	flight_flig_id int8 not null,
	cost_amount int8 not null
);

--  Concepto de configuracion (vuelos,reservas,aereopuertos,pasajeros,agentes)
INSERT INTO iam_program (PROGRAM_ID,VERSION,IDENT,DESCRP)
VALUES (31,1,'vuelos','Conceptos de vuelos');

INSERT INTO iam_allowed_applications (AAPP_ID,APPLICATION_ID,PROGRAM_ID)
VALUES (31,1,31);

INSERT INTO iam_option (OPTION_ID,VERSION,PROGRAM_ID,CONTROL_ID)
VALUES (140,1,31,5);
INSERT INTO iam_option (OPTION_ID,VERSION,PROGRAM_ID,CONTROL_ID)
VALUES (141,1,31,6);
INSERT INTO iam_option (OPTION_ID,VERSION,PROGRAM_ID,CONTROL_ID)
VALUES (142,1,31,7);
INSERT INTO iam_option (OPTION_ID,VERSION,PROGRAM_ID,CONTROL_ID)
VALUES (143,1,31,8);

INSERT INTO iam_access (ACCESS_ID, ROLE_ID, APPLICATION_ID, VERSION, PROGRAM_ID) VALUES (46, 1, 1, 1, 31);

INSERT INTO iam_access_DETAIL (ACCEDET_ID, OPTION_ID, VERSION, ACCESS_ID) VALUES (190, 140, 1, 46);
INSERT INTO iam_access_DETAIL (ACCEDET_ID, OPTION_ID, VERSION, ACCESS_ID) VALUES (191, 141, 1, 46);
INSERT INTO iam_access_DETAIL (ACCEDET_ID, OPTION_ID, VERSION, ACCESS_ID) VALUES (192, 142, 1, 46);
INSERT INTO iam_access_DETAIL (ACCEDET_ID, OPTION_ID, VERSION, ACCESS_ID) VALUES (193, 143, 1, 46);



