--
-- ER/Studio 7.1 SQL Code Generation
-- Company :      Berkeley Seismological Laboratory
-- Project :      NCEDC/TriNet Hardware Tracking
-- Author :       Stephane Zuzlewski
--
-- Date Created : Tuesday, February 20, 2007 11:12:22
-- Target DBMS : Oracle 9i
--

DROP TABLE Datalogger CASCADE CONSTRAINTS
;
DROP TABLE Datalogger_Board CASCADE CONSTRAINTS
;
DROP TABLE Datalogger_Module CASCADE CONSTRAINTS
;
DROP TABLE Filamp CASCADE CONSTRAINTS
;
DROP TABLE Filamp_PChannel CASCADE CONSTRAINTS
;
DROP TABLE Filter CASCADE CONSTRAINTS
;
DROP TABLE Filter_FIR CASCADE CONSTRAINTS
;
DROP TABLE Filter_FIR_Data CASCADE CONSTRAINTS
;
DROP TABLE Filter_Sequence CASCADE CONSTRAINTS
;
DROP TABLE Filter_Sequence_Data CASCADE CONSTRAINTS
;
DROP TABLE Response CASCADE CONSTRAINTS
;
DROP TABLE Response_HP CASCADE CONSTRAINTS
;
DROP TABLE Response_LP CASCADE CONSTRAINTS
;
DROP TABLE Response_PN CASCADE CONSTRAINTS
;
DROP TABLE Response_PN_Data CASCADE CONSTRAINTS
;
DROP TABLE Response_PZ CASCADE CONSTRAINTS
;
DROP TABLE Sensor CASCADE CONSTRAINTS
;
DROP TABLE Sensor_Component CASCADE CONSTRAINTS
;
DROP TABLE Station CASCADE CONSTRAINTS
;
DROP TABLE Station_Datalogger CASCADE CONSTRAINTS
;
DROP TABLE Station_Datalogger_LChannel CASCADE CONSTRAINTS
;
DROP TABLE Station_Datalogger_PChannel CASCADE CONSTRAINTS
;
DROP TABLE Station_Digitizer CASCADE CONSTRAINTS
;
DROP TABLE Station_Digitizer_PChannel CASCADE CONSTRAINTS
;
DROP TABLE Station_Filamp CASCADE CONSTRAINTS
;
DROP TABLE Station_Filamp_PChannel CASCADE CONSTRAINTS
;
DROP TABLE Station_Sensor CASCADE CONSTRAINTS
;
DROP TABLE Station_Sensor_Component CASCADE CONSTRAINTS
;
-- 
-- SEQUENCE: dataseq 
--

DROP SEQUENCE dataseq
;

CREATE SEQUENCE DATASEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: filampseq 
--

DROP SEQUENCE filampseq
;

CREATE SEQUENCE FILAMPSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: filterseq 
--

DROP SEQUENCE filterseq
;

CREATE SEQUENCE FILTERSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: firseq 
--

DROP SEQUENCE firseq
;

CREATE SEQUENCE FIRSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: hpseq 
--

DROP SEQUENCE hpseq
;

CREATE SEQUENCE HPSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: lpseq 
--

DROP SEQUENCE lpseq
;

CREATE SEQUENCE LPSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: pnseq 
--

DROP SEQUENCE pnseq
;

CREATE SEQUENCE PNSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: pzseq 
--

DROP SEQUENCE pzseq
;

CREATE SEQUENCE PZSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: respseq 
--

DROP SEQUENCE respseq
;

CREATE SEQUENCE RESPSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: sensorseq 
--

DROP SEQUENCE sensorseq
;

CREATE SEQUENCE SENSORSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- SEQUENCE: seqfilseq 
--

DROP SEQUENCE seqfilseq
;

CREATE SEQUENCE SEQFILSEQ
    START WITH 1
    INCREMENT BY 1
    NOMINVALUE
    NOMAXVALUE
    CACHE 20
    ORDER
;

-- 
-- TABLE: Datalogger 
--

CREATE TABLE Datalogger(
    data_id        NUMBER(8, 0)    NOT NULL,
    data_type      VARCHAR2(80),
    serial_nb      VARCHAR2(80),
    firmware_nb    VARCHAR2(80),
    software       VARCHAR2(80),
    software_nb    VARCHAR2(80),
    ondate         DATE            NOT NULL,
    offdate        DATE,
    nb_board       NUMBER(8, 0),
    word_32        NUMBER(8, 0)    NOT NULL,
    word_16        NUMBER(8, 0)    NOT NULL,
    lddate         DATE            DEFAULT (SYSDATE),
    CONSTRAINT Da00 PRIMARY KEY (data_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Datalogger_Board 
--

CREATE TABLE Datalogger_Board(
    data_id        NUMBER(8, 0)    NOT NULL,
    board_nb       NUMBER(8, 0)    NOT NULL,
    serial_nb      VARCHAR2(80),
    nb_module      NUMBER(8, 0)    NOT NULL,
    firmware_nb    VARCHAR2(80),
    lddate         DATE            DEFAULT (SYSDATE),
    CONSTRAINT DaB00 PRIMARY KEY (data_id, board_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Datalogger_Module 
--

CREATE TABLE Datalogger_Module(
    data_id        NUMBER(8, 0)        NOT NULL,
    board_nb       NUMBER(8, 0)        NOT NULL,
    module_nb      NUMBER(8, 0)        NOT NULL,
    serial_nb      VARCHAR2(80),
    firmware_nb    VARCHAR2(80),
    sensitivity    DOUBLE PRECISION,
    lddate         DATE                DEFAULT (SYSDATE),
    CONSTRAINT DaM00 PRIMARY KEY (data_id, board_nb, module_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Filamp 
--

CREATE TABLE Filamp(
    filamp_id      NUMBER(8, 0)    NOT NULL,
    name           VARCHAR2(80),
    serial_nb      VARCHAR2(80),
    ondate         DATE            NOT NULL,
    offdate        DATE,
    nb_pchannel    NUMBER(8, 0)    NOT NULL,
    lddate         DATE            DEFAULT (SYSDATE),
    CONSTRAINT Filamp00 PRIMARY KEY (filamp_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Filamp_PChannel 
--

CREATE TABLE Filamp_PChannel(
    filamp_id      NUMBER(8, 0)        NOT NULL,
    pchannel_nb    NUMBER(8, 0)        NOT NULL,
    gain           DOUBLE PRECISION,
    frequency      DOUBLE PRECISION,
    seqresp_id     NUMBER(8, 0),
    lddate         DATE                DEFAULT (SYSDATE),
    CONSTRAINT FiP00 PRIMARY KEY (filamp_id, pchannel_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Filter 
--

CREATE TABLE Filter(
    filter_id      NUMBER(8, 0)        NOT NULL,
    gain           DOUBLE PRECISION,
    frequency      DOUBLE PRECISION,
    in_sp_rate     DOUBLE PRECISION,
    out_sp_rate    DOUBLE PRECISION,
    offset         NUMBER(8, 0),
    delay          DOUBLE PRECISION,
    correction     DOUBLE PRECISION    NOT NULL,
    seqresp_id     NUMBER(8, 0),
    lddate         DATE                DEFAULT (SYSDATE),
    CONSTRAINT Fi00 PRIMARY KEY (filter_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Filter_FIR 
--

CREATE TABLE Filter_FIR(
    fir_id      NUMBER(8, 0)        NOT NULL,
    name        VARCHAR2(80),
    symmetry    VARCHAR2(1)         NOT NULL,
    gain        DOUBLE PRECISION,
    lddate      DATE                DEFAULT (SYSDATE),
    CONSTRAINT FFIR00 PRIMARY KEY (fir_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Filter_FIR_Data 
--

CREATE TABLE Filter_FIR_Data(
    fir_id         NUMBER(8, 0)        NOT NULL,
    coeff_nb       NUMBER(8, 0)        NOT NULL,
    type           VARCHAR2(1)         NOT NULL,
    coefficient    DOUBLE PRECISION    NOT NULL,
    error          DOUBLE PRECISION,
    CONSTRAINT FFD00 PRIMARY KEY (fir_id, coeff_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Filter_Sequence 
--

CREATE TABLE Filter_Sequence(
    seqfil_id    NUMBER(8, 0)        NOT NULL,
    name         VARCHAR2(32)        NOT NULL,
    nb_filter    NUMBER(8, 0)        NOT NULL,
    gain         DOUBLE PRECISION,
    frequency    DOUBLE PRECISION,
    lddate       DATE                DEFAULT (SYSDATE),
    CONSTRAINT FiS00 PRIMARY KEY (seqfil_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Filter_Sequence_Data 
--

CREATE TABLE Filter_Sequence_Data(
    seqfil_id    NUMBER(8, 0)    NOT NULL,
    filter_nb    NUMBER(8, 0)    NOT NULL,
    filter_id    NUMBER(8, 0)    NOT NULL,
    CONSTRAINT FiSeD00 PRIMARY KEY (seqfil_id, filter_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Response 
--

CREATE TABLE Response(
    seqresp_id    NUMBER(8, 0)    NOT NULL,
    resp_nb       NUMBER(8, 0)    NOT NULL,
    resp_type     VARCHAR2(1)     NOT NULL,
    resp_id       NUMBER(8, 0)    NOT NULL,
    unit_in       NUMBER(8, 0)    NOT NULL,
    unit_out      NUMBER(8, 0)    NOT NULL,
    r_type        VARCHAR2(1),
    lddate        DATE            DEFAULT (SYSDATE),
    CONSTRAINT Re00 PRIMARY KEY (seqresp_id, resp_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Response_HP 
--

CREATE TABLE Response_HP(
    hp_id            NUMBER(8, 0)        NOT NULL,
    filter_type      VARCHAR2(2)         NOT NULL,
    nb_pole          NUMBER(8, 0)        NOT NULL,
    corner_freq      DOUBLE PRECISION    NOT NULL,
    damping_value    DOUBLE PRECISION    NOT NULL,
    lddate           DATE                DEFAULT (SYSDATE),
    CONSTRAINT RHP00 PRIMARY KEY (hp_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Response_LP 
--

CREATE TABLE Response_LP(
    lp_id            NUMBER(8, 0)        NOT NULL,
    filter_type      VARCHAR2(2),
    nb_pole          NUMBER(8, 0),
    corner_freq      DOUBLE PRECISION    NOT NULL,
    damping_value    DOUBLE PRECISION    NOT NULL,
    lddate           DATE                DEFAULT (SYSDATE),
    CONSTRAINT RLP00 PRIMARY KEY (lp_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Response_PN 
--

CREATE TABLE Response_PN(
    pn_id          NUMBER(8, 0)        NOT NULL,
    name           VARCHAR2(80),
    poly_type      VARCHAR2(1)         NOT NULL,
    lower_bound    DOUBLE PRECISION,
    upper_bound    DOUBLE PRECISION,
    max_error      DOUBLE PRECISION,
    nb_coeff       NUMBER(8, 0),
    lddate         DATE                DEFAULT (SYSDATE),
    CONSTRAINT RPN00 PRIMARY KEY (pn_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Response_PN_Data 
--

CREATE TABLE Response_PN_Data(
    pn_id       NUMBER(8, 0)        NOT NULL,
    pn_nb       NUMBER(8, 0)        NOT NULL,
    pn_value    DOUBLE PRECISION    NOT NULL,
    CONSTRAINT RPND00 PRIMARY KEY (pn_id, pn_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Response_PZ 
--

CREATE TABLE Response_PZ(
    pz_id      NUMBER(8, 0)        NOT NULL,
    pz_nb      NUMBER(8, 0)        NOT NULL,
    type       VARCHAR2(1)         NOT NULL,
    r_value    DOUBLE PRECISION    NOT NULL,
    r_error    DOUBLE PRECISION,
    i_value    DOUBLE PRECISION    NOT NULL,
    i_error    DOUBLE PRECISION,
    lddate     DATE                DEFAULT (SYSDATE),
    CONSTRAINT RPZ00 PRIMARY KEY (pz_id, pz_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Sensor 
--

CREATE TABLE Sensor(
    sensor_id       NUMBER(8, 0)    NOT NULL,
    name            VARCHAR2(80),
    serial_nb       VARCHAR2(80),
    ondate          DATE            NOT NULL,
    offdate         DATE,
    nb_component    NUMBER(8, 0)    NOT NULL,
    lddate          DATE            DEFAULT (SYSDATE),
    CONSTRAINT Sensor00 PRIMARY KEY (sensor_id)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Sensor_Component 
--

CREATE TABLE Sensor_Component(
    sensor_id         NUMBER(8, 0)        NOT NULL,
    component_nb      NUMBER(8, 0)        NOT NULL,
    channel_comp      VARCHAR2(2),
    component_type    VARCHAR2(1),
    sensitivity       DOUBLE PRECISION    NOT NULL,
    frequency         DOUBLE PRECISION,
    seqresp_id        NUMBER(8, 0),
    lddate            DATE                DEFAULT (SYSDATE),
    CONSTRAINT SeC00 PRIMARY KEY (sensor_id, component_nb)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station 
--

CREATE TABLE Station(
    sta          VARCHAR2(6)         NOT NULL,
    net          VARCHAR2(8)         NOT NULL,
    lat          DOUBLE PRECISION,
    lon          DOUBLE PRECISION,
    elev         DOUBLE PRECISION,
    staname      VARCHAR2(50),
    nb_sensor    NUMBER(8, 0),
    nb_filamp    NUMBER(8, 0),
    nb_digi      NUMBER(8, 0)        NOT NULL,
    nb_data      NUMBER(8, 0)        NOT NULL,
    datumhor     VARCHAR2(8),
    datumver     VARCHAR2(8),
    ondate       DATE                NOT NULL,
    offdate      DATE,
    lddate       DATE                DEFAULT (SYSDATE),
    CONSTRAINT St00 PRIMARY KEY (sta, net, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Datalogger 
--

CREATE TABLE Station_Datalogger(
    sta            VARCHAR2(6)     NOT NULL,
    net            VARCHAR2(8)     NOT NULL,
    data_nb        NUMBER(8, 0)    NOT NULL,
    ondate         DATE            NOT NULL,
    data_id        NUMBER(8, 0)    NOT NULL,
    nb_pchannel    NUMBER(8, 0)    NOT NULL,
    offdate        DATE,
    lddate         DATE            DEFAULT (SYSDATE),
    CONSTRAINT StDa00 PRIMARY KEY (sta, net, data_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Datalogger_LChannel 
--

CREATE TABLE Station_Datalogger_LChannel(
    sta            VARCHAR2(6)         NOT NULL,
    net            VARCHAR2(8)         NOT NULL,
    data_nb        NUMBER(8, 0)        NOT NULL,
    pchannel_nb    NUMBER(8, 0)        NOT NULL,
    lchannel_nb    NUMBER(8, 0)        NOT NULL,
    ondate         DATE                NOT NULL,
    seqfil_id      NUMBER(8, 0),
    seedchan       VARCHAR2(3),
    channel        VARCHAR2(8),
    channelsrc     VARCHAR2(8),
    location       VARCHAR2(2),
    rgain          DOUBLE PRECISION,
    rfrequency     DOUBLE PRECISION,
    samprate       DOUBLE PRECISION    NOT NULL,
    clock_drift    DOUBLE PRECISION,
    flags          VARCHAR2(27),
    data_format    VARCHAR2(80)        NOT NULL,
    comp_type      NUMBER(8, 0)        NOT NULL,
    unit_signal    NUMBER(8, 0)        NOT NULL,
    unit_calib     NUMBER(8, 0)        NOT NULL,
    block_size     NUMBER(8, 0)        NOT NULL,
    offdate        DATE,
    remark         VARCHAR2(30),
    lddate         DATE                DEFAULT (SYSDATE),
    CONSTRAINT StDaL00 PRIMARY KEY (sta, net, data_nb, pchannel_nb, lchannel_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Datalogger_PChannel 
--

CREATE TABLE Station_Datalogger_PChannel(
    sta             VARCHAR2(6)     NOT NULL,
    net             VARCHAR2(8)     NOT NULL,
    data_nb         NUMBER(8, 0)    NOT NULL,
    pchannel_nb     NUMBER(8, 0)    NOT NULL,
    ondate          DATE            NOT NULL,
    board_type      VARCHAR2(1)     NOT NULL,
    channel_type    VARCHAR2(1)     NOT NULL,
    seed_io         VARCHAR2(2)     NOT NULL,
    nb_lchannel     NUMBER(8, 0)    NOT NULL,
    offdate         DATE,
    lddate          DATE            DEFAULT (SYSDATE),
    CONSTRAINT StDaP00 PRIMARY KEY (sta, net, data_nb, pchannel_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Digitizer 
--

CREATE TABLE Station_Digitizer(
    sta                VARCHAR2(6)     NOT NULL,
    net                VARCHAR2(8)     NOT NULL,
    digi_nb            NUMBER(8, 0)    NOT NULL,
    ondate             DATE            NOT NULL,
    serial_nb          VARCHAR2(80)    NOT NULL,
    nb_pri_pchannel    NUMBER(8, 0)    NOT NULL,
    nb_aux_pchannel    NUMBER(8, 0)    NOT NULL,
    offdate            DATE,
    lddate             DATE            DEFAULT (SYSDATE),
    CONSTRAINT StDi00 PRIMARY KEY (sta, net, digi_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Digitizer_PChannel 
--

CREATE TABLE Station_Digitizer_PChannel(
    sta              VARCHAR2(6)     NOT NULL,
    net              VARCHAR2(8)     NOT NULL,
    digi_nb          NUMBER(8, 0)    NOT NULL,
    pchannel_nb      NUMBER(8, 0)    NOT NULL,
    ondate           DATE            NOT NULL,
    data_nb          NUMBER(8, 0)    NOT NULL,
    data_pchannel    NUMBER(8, 0)    NOT NULL,
    digi_type        VARCHAR2(3)     NOT NULL,
    digi_polarity    VARCHAR2(1)     NOT NULL,
    digi_channel     NUMBER(8, 0)    NOT NULL,
    offdate          DATE,
    lddate           DATE            DEFAULT (SYSDATE),
    CONSTRAINT StDiP00 PRIMARY KEY (sta, net, digi_nb, pchannel_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Filamp 
--

CREATE TABLE Station_Filamp(
    sta            VARCHAR2(6)     NOT NULL,
    net            VARCHAR2(8)     NOT NULL,
    filamp_nb      NUMBER(8, 0)    NOT NULL,
    ondate         DATE            NOT NULL,
    filamp_id      NUMBER(8, 0)    NOT NULL,
    nb_pchannel    NUMBER(8, 0)    NOT NULL,
    offdate        DATE,
    lddate         DATE            DEFAULT (SYSDATE),
    CONSTRAINT StFi00 PRIMARY KEY (sta, net, filamp_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Filamp_PChannel 
--

CREATE TABLE Station_Filamp_PChannel(
    sta                   VARCHAR2(6)     NOT NULL,
    net                   VARCHAR2(8)     NOT NULL,
    filamp_nb             NUMBER(8, 0)    NOT NULL,
    pchannel_nb           NUMBER(8, 0)    NOT NULL,
    ondate                DATE            NOT NULL,
    next_hard_type        VARCHAR2(1)     NOT NULL,
    next_hard_nb          NUMBER(8, 0)    NOT NULL,
    next_hard_pchannel    NUMBER(8, 0)    NOT NULL,
    offdate               DATE,
    lddate                DATE            DEFAULT (SYSDATE),
    CONSTRAINT StFiP00 PRIMARY KEY (sta, net, filamp_nb, pchannel_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Sensor 
--

CREATE TABLE Station_Sensor(
    sta             VARCHAR2(6)         NOT NULL,
    net             VARCHAR2(8)         NOT NULL,
    sensor_nb       NUMBER(8, 0)        NOT NULL,
    ondate          DATE                NOT NULL,
    sensor_id       NUMBER(8, 0)        NOT NULL,
    lat             DOUBLE PRECISION,
    lon             DOUBLE PRECISION,
    elev            DOUBLE PRECISION,
    edepth          DOUBLE PRECISION,
    nb_component    NUMBER(8, 0)        NOT NULL,
    datumhor        VARCHAR2(8),
    datumver        VARCHAR2(8),
    offdate         DATE,
    lddate          DATE                DEFAULT (SYSDATE),
    CONSTRAINT StSe00 PRIMARY KEY (sta, net, sensor_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Station_Sensor_Component 
--

CREATE TABLE Station_Sensor_Component(
    sta                   VARCHAR2(6)         NOT NULL,
    net                   VARCHAR2(8)         NOT NULL,
    sensor_nb             NUMBER(8, 0)        NOT NULL,
    component_nb          NUMBER(8, 0)        NOT NULL,
    ondate                DATE                NOT NULL,
    next_hard_type        VARCHAR2(1)         NOT NULL,
    next_hard_nb          NUMBER(8, 0)        NOT NULL,
    next_hard_pchannel    NUMBER(8, 0)        NOT NULL,
    azimuth               DOUBLE PRECISION,
    dip                   DOUBLE PRECISION,
    offdate               DATE,
    lddate                DATE                DEFAULT (SYSDATE),
    CONSTRAINT StSeC00 PRIMARY KEY (sta, net, sensor_nb, component_nb, ondate)
)
TABLESPACE HT_DATA
;



-- 
-- TABLE: Datalogger_Board 
--

ALTER TABLE Datalogger_Board ADD CONSTRAINT Dat_Boa_Dat 
    FOREIGN KEY (data_id)
    REFERENCES Datalogger(data_id)
;


-- 
-- TABLE: Datalogger_Module 
--

ALTER TABLE Datalogger_Module ADD CONSTRAINT Dat_Mod_Dat_Boa 
    FOREIGN KEY (data_id, board_nb)
    REFERENCES Datalogger_Board(data_id, board_nb)
;


-- 
-- TABLE: Filamp_PChannel 
--

ALTER TABLE Filamp_PChannel ADD CONSTRAINT Fil_PCh_Fil 
    FOREIGN KEY (filamp_id)
    REFERENCES Filamp(filamp_id)
;


-- 
-- TABLE: Filter_FIR_Data 
--

ALTER TABLE Filter_FIR_Data ADD CONSTRAINT Fil_FIR_Dat_Fil_FIR 
    FOREIGN KEY (fir_id)
    REFERENCES Filter_FIR(fir_id)
;


-- 
-- TABLE: Filter_Sequence_Data 
--

ALTER TABLE Filter_Sequence_Data ADD CONSTRAINT Fil_Seq_Dat_Fil 
    FOREIGN KEY (filter_id)
    REFERENCES Filter(filter_id)
;

ALTER TABLE Filter_Sequence_Data ADD CONSTRAINT Fil_Seq_Dat_Fil_Seq 
    FOREIGN KEY (seqfil_id)
    REFERENCES Filter_Sequence(seqfil_id)
;


-- 
-- TABLE: Response 
--

ALTER TABLE Response ADD CONSTRAINT Res_Fil_FIR 
    FOREIGN KEY (resp_id)
    REFERENCES Filter_FIR(fir_id)
;

ALTER TABLE Response ADD CONSTRAINT Res_Res_HP 
    FOREIGN KEY (resp_id)
    REFERENCES Response_HP(hp_id)
;

ALTER TABLE Response ADD CONSTRAINT Res_Res_LP 
    FOREIGN KEY (resp_id)
    REFERENCES Response_LP(lp_id)
;

ALTER TABLE Response ADD CONSTRAINT Res_Res_PN 
    FOREIGN KEY (resp_id)
    REFERENCES Response_PN(pn_id)
;


-- 
-- TABLE: Response_PN_Data 
--

ALTER TABLE Response_PN_Data ADD CONSTRAINT Res_PN_Dat_Res_PN 
    FOREIGN KEY (pn_id)
    REFERENCES Response_PN(pn_id)
;


-- 
-- TABLE: Sensor_Component 
--

ALTER TABLE Sensor_Component ADD CONSTRAINT Sen_Com_Sen 
    FOREIGN KEY (sensor_id)
    REFERENCES Sensor(sensor_id)
;


-- 
-- TABLE: Station_Datalogger 
--

ALTER TABLE Station_Datalogger ADD CONSTRAINT Sta_Dat_Dat 
    FOREIGN KEY (data_id)
    REFERENCES Datalogger(data_id)
;

ALTER TABLE Station_Datalogger ADD CONSTRAINT Sta_Dat_Sta 
    FOREIGN KEY (sta, net, ondate)
    REFERENCES Station(sta, net, ondate)
;


-- 
-- TABLE: Station_Datalogger_LChannel 
--

ALTER TABLE Station_Datalogger_LChannel ADD CONSTRAINT Sta_Dat_LCh_Fil_Seq 
    FOREIGN KEY (seqfil_id)
    REFERENCES Filter_Sequence(seqfil_id)
;

ALTER TABLE Station_Datalogger_LChannel ADD CONSTRAINT Sta_Dat_LCh_Sta_Dat_PCh 
    FOREIGN KEY (sta, net, data_nb, pchannel_nb, ondate)
    REFERENCES Station_Datalogger_PChannel(sta, net, data_nb, pchannel_nb, ondate)
;


-- 
-- TABLE: Station_Datalogger_PChannel 
--

ALTER TABLE Station_Datalogger_PChannel ADD CONSTRAINT Sta_Dat_PCh_Sta_Dat 
    FOREIGN KEY (sta, net, data_nb, ondate)
    REFERENCES Station_Datalogger(sta, net, data_nb, ondate)
;


-- 
-- TABLE: Station_Digitizer 
--

ALTER TABLE Station_Digitizer ADD CONSTRAINT Sta_Dig_Sta 
    FOREIGN KEY (sta, net, ondate)
    REFERENCES Station(sta, net, ondate)
;


-- 
-- TABLE: Station_Digitizer_PChannel 
--

ALTER TABLE Station_Digitizer_PChannel ADD CONSTRAINT Sta_Dig_PCh_Sta_Dig 
    FOREIGN KEY (sta, net, digi_nb, ondate)
    REFERENCES Station_Digitizer(sta, net, digi_nb, ondate)
;


-- 
-- TABLE: Station_Filamp 
--

ALTER TABLE Station_Filamp ADD CONSTRAINT Sta_Fil_Fil 
    FOREIGN KEY (filamp_id)
    REFERENCES Filamp(filamp_id)
;

ALTER TABLE Station_Filamp ADD CONSTRAINT Sta_Fil_Sta 
    FOREIGN KEY (sta, net, ondate)
    REFERENCES Station(sta, net, ondate)
;


-- 
-- TABLE: Station_Filamp_PChannel 
--

ALTER TABLE Station_Filamp_PChannel ADD CONSTRAINT Sta_Fil_PCh_Sta_Fil 
    FOREIGN KEY (sta, net, filamp_nb, ondate)
    REFERENCES Station_Filamp(sta, net, filamp_nb, ondate)
;


-- 
-- TABLE: Station_Sensor 
--

ALTER TABLE Station_Sensor ADD CONSTRAINT Sta_Sen_Sen 
    FOREIGN KEY (sensor_id)
    REFERENCES Sensor(sensor_id)
;

ALTER TABLE Station_Sensor ADD CONSTRAINT Sta_Sen_Sta 
    FOREIGN KEY (sta, net, ondate)
    REFERENCES Station(sta, net, ondate)
;


-- 
-- TABLE: Station_Sensor_Component 
--

ALTER TABLE Station_Sensor_Component ADD CONSTRAINT Sta_Sen_Com_Sta_Sen 
    FOREIGN KEY (sta, net, sensor_nb, ondate)
    REFERENCES Station_Sensor(sta, net, sensor_nb, ondate)
;


