--HFREADERCONFIGURATION table---
CREATE SEQUENCE SEQ_HFREADERCONFIGURATION
START WITH 1
INCREMENT BY 1;  

CREATE TABLE HFREADERCONFIGURATION
(
  HFREADERCONFIGURATION_ID         NUMBER NOT NULL,
  WORKSTATION_ID                   NUMBER NOT NULL,
  READERID                         VARCHAR2(100) NULL,
  USERNAME                         VARCHAR2(50)  NULL,
  PASSWORD                         VARCHAR2(50)  NULL,
  SENSOR                           VARCHAR2(1) DEFAULT 'N' NOT NULL CONSTRAINT YN_VALIDATIONFIELD261 CHECK (SENSOR IN ('Y','N')),
  SYSTEMUSER_ID                    NUMBER NOT NULL,
  TIMESTAMP                        DATE NOT NULL
);

ALTER TABLE HFREADERCONFIGURATION
  ADD CONSTRAINT XPKHFREADERCONFIGURATION PRIMARY KEY (HFREADERCONFIGURATION_ID);
  
CREATE INDEX XIF1WORKSTATION ON HFREADERCONFIGURATION (WORKSTATION_ID ASC);

ALTER TABLE HFREADERCONFIGURATION
  ADD CONSTRAINT HFREADERCONFIGURATION_WS_ID FOREIGN KEY (WORKSTATION_ID)
  REFERENCES WORKSTATION (WORKSTATION_ID) ON DELETE CASCADE;
  
---WORKSTATION table---

ALTER TABLE WORKSTATION
  DROP CONSTRAINT SOCKETPROTOCOL_VALID1_1;
ALTER TABLE WORKSTATION
  ADD CONSTRAINT SOCKETPROTOCOL_VALID1_1
  CHECK (SOCKETPROTOCOL IN (0, 1, 2, 3, 4, 5, 6, 7));
  
COMMENT ON COLUMN WORKSTATION.SOCKETPROTOCOL IS '0 = Not applicable 
1 = Standard EPC + CR/LF 
2 = Datamars 
3 = TagSys-L400 EPC + CR/LF 
4 = TagSys u-Door 
5 = TAGSYSSTXNG 
6 = TCP Sick 
7 = TagPilot';
