create sequence hibernate_sequence start with 1 increment by 1;
create table Item (
id bigint not null,
itemValue varchar(255),
primary key (id)
);
create table Item_AUD (
id bigint not null,
REV integer not null,
REVTYPE tinyint,
itemValue varchar(255),
primary key (id, REV)
);
create table REVINFO (
REV integer generated by default as identity,
REVTSTMP bigint,
primary key (REV)
);
create table sub (
subValue varchar(255),
item_id bigint,
super_id bigint not null,
primary key (super_id)
);
create table sub_AUD (
super_id bigint not null,
REV integer not null,
subValue varchar(255),
item_id bigint,
primary key (super_id, REV)
);
create table super (
TYPE varchar(31) not null,
id bigint not null,
superValue varchar(255),
primary key (id)
);
create table super_AUD (
id bigint not null,
REV integer not null,
TYPE varchar(31) not null,
REVTYPE tinyint,
superValue varchar(255),
primary key (id, REV)
);
alter table Item_AUD
add constraint FKdq4ril8m8wgqsm4nkucyp1elc
foreign key (REV)
references REVINFO;
alter table sub
add constraint FK6d02b2m0uwftttcv3gaosl13y
foreign key (item_id)
references Item;
alter table sub
add constraint FKkf2nkxga8isavqh61y29w6qqe
foreign key (super_id)
references super;
alter table sub_AUD
add constraint FKakfxrtykamxt3pm127omcyyem
foreign key (super_id, REV)
references super_AUD;
alter table super_AUD
add constraint FKd6cg2g5arv5igy08g07a8gy56
foreign key (REV)
references REVINFO;