Database schema


    
-- ============================================================    
--   Table : ZONE    
-- ============================================================    
create table ZONE    
(    
    REF                 CHAR(2)            not null,    
    NAME                CHAR(40)           not null    
);    
    
    
-- ============================================================    
--   Table : STAT    
-- ============================================================    
create table STAT    
(    
    REF                 CHAR(3)            not null,    
    NAME                CHAR(40)           not null,    
    NUMB                INT                not null    
);    
    
    
-- ============================================================    
--   Table : SECTION    
-- ============================================================    
create table SECTION    
(    
    REF                 CHAR(2)            not null,    
    REF_ZONE            CHAR(2)            not null,    
    NAME                CHAR(40)           not null    
);    
    
    
-- ============================================================    
--   Table : OBJECT    
-- ============================================================    
create table OBJECT    
(    
    REF                 CHAR(10)              not null,    
    REF_SECTION         CHAR(2)               not null,    
    NAME                CHAR(30)              not null,    
    CREATE_DATE         CHAR(12)              not null,    
    NOTE                CHAR(100)    
);    
    
    
-- ============================================================    
--   Table : HISTORY    
-- ============================================================    
create table HISTORY    
(    
    REF_OBJECT          CHAR(10)              not null,    
    HORDER              INT                   not null,    
    REF_STAT            CHAR(3)               not null,    
    BEGIN_DATE          CHAR(12)              not null,    
    END_DATE            CHAR(12)                      ,    
    NOTE                CHAR(100)    
);    
    
    
-- ============================================================    
--   Index :    
-- ============================================================    
    
create unique index zone_ref_idx on ZONE( ref );    
create unique index stat_ref_idx on STAT( ref );    
create unique index section_ref_idx on SECTION( ref );    
create unique index object_ref_idx on OBJECT( ref );    
--create unique index history_ref_idx on HISTORY( ref_object, horder );    
create index history_ref_idx on HISTORY( ref_object, horder );    
    
-- ============================================================    
--   constraint : FOREIGN KEY    
-- ============================================================    
    
--alter table SECTION add constraint foreign key( REF_ZONE ) references ZONE( REF ) constraint REF_ZONE_LINK;    
--alter table OBJECT add constraint foreign key( REF_SECTION ) references SECTION( REF ) constraint REF_SECTION_LINK;    
--alter table HISTORY add constraint foreign key( REF_OBJECT ) references OBJECT( REF ) constraint REF_OBJECT_LINK;    
--alter table HISTORY add constraint foreign key( REF_STAT ) references STAT( REF ) constraint REF_STAT_LINK;