create sequence res_id_seq INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;
create sequence ver_id_seq INCREMENT BY 1 NO MAXVALUE NO MINVALUE CACHE 1;

create domain res_type as varchar(8) constraint res_type_check check (VALUE in ('lexique', 'corpus', 'code', 'document', 'dossier', 'autre'));

create table ressources (
    id int default nextval('res_id_seq') not null primary key,
    type res_type not null,
    nom varchar(1023) unique not null,
    description varchar(1023) not null,
    contact varchar(1023) not null,
    usage varchar(1023) null,
    investissement varchar(1023) null,
    commentaire varchar(1023) null,

    champ1 varchar(1023) null,
    champ2 varchar(1023) null,
    champ3 varchar(1023) null,
    champ4 varchar(1023) null
);

create table versions (
    verid int default nextval('ver_id_seq') not null primary key,
    ressource int not null references ressources(id),
    version varchar(1023) not null,
    localisation varchar(1023) not null,
    format varchar(1023) null,
    disque varchar(1023) null,
    commentaire varchar(1023) null
);
