CREATE TABLE rich700_trb3lookup_data ( 
  vers_id         NUMBER(8)    NOT NULL
                               CONSTRAINT rich700_trb3lookup_vers_fk1
                               REFERENCES rich700_trb3lookup_vers (vers_id)
                               ON DELETE CASCADE,
  trbnet_address  NUMBER(5)    NOT NULL,
  channel_id      NUMBER(3)    ,
  pmt_id         NUMBER(5)    NOT NULL
                               CONSTRAINT rich700_trb3lookup_data_fk2
                               REFERENCES rich700_pmt (pmt_id),
  pmt_pixel     number(2)   NOT NULL
                              CONSTRAINT rich700_trb3lookup_data_fk3
                               REFERENCES rich700_pmt_pixel (pixel),
  CONSTRAINT rich700_trb3lookup_data_pk PRIMARY KEY (vers_id,pmt_id, pmt_pixel)
    USING INDEX  PCTFREE 2 STORAGE (INITIAL 32K NEXT 16K PCTINCREASE 0),
  CONSTRAINT rich700_trb3lookup_data_unq UNIQUE (vers_id,trbnet_address,channel_id)
    USING INDEX  PCTFREE 2 STORAGE (INITIAL 64K NEXT 64K PCTINCREASE 0),
  CONSTRAINT rich700_trb3lookup_data_check1 check ( trbnet_address between 4608 and 5632 ),
  CONSTRAINT rich700_trb3lookup_data_check2 check ( channel_id between 0 and 127 ))
PCTUSED 95 PCTFREE 2 STORAGE (INITIAL 64K  NEXT 64K PCTINCREASE 0);

COMMENT ON TABLE  rich700_trb3lookup_data IS 'Lookup table used by the TRB3 unpacker of the RICH700 detector';
COMMENT ON COLUMN rich700_trb3lookup_data.vers_id IS 'Identifier for the version of the parameter set, references rich700_trb3lookup_vers.vers_id';
COMMENT ON COLUMN rich700_trb3lookup_data.trbnet_address IS 'Trbnet address (0x1200..0x1600) PRELIMINARY';
COMMENT ON COLUMN rich700_trb3lookup_data.channel_id IS 'Dirich TDC channel id (0..31)';
COMMENT ON COLUMN rich700_trb3lookup_data.pmt_id IS 'Identifier for the rich700 pmt, references rich700_pmt.pmt_id';
COMMENT ON COLUMN rich700_trb3lookup_data.pmt_pixel IS 'Identifier for the pixel number on the single pmt';
