-- ABS-7437

--------------------- UNIQUEITEMBUFFERINFO ---------------------
CREATE SEQUENCE SEQ_UNIQUEITEMBUFFERINFO
START WITH 1
INCREMENT BY 1;

CREATE TABLE UNIQUEITEMBUFFERINFO
( UNIQUEITEMBUFFERINFO_ID    NUMBER NOT NULL,
  UNIQUEITEM_ID              NUMBER NOT NULL,
  PLANT_ID                   NUMBER NOT NULL,
  BUSINESSUNIT_ID            NUMBER NOT NULL,
  LASTSCANDATE               DATE NOT NULL,
  LASTSCANTIMESTAMP          DATE NOT NULL,
  INSCANTIMESTAMP            DATE NOT NULL,
  IDCODE                     VARCHAR2(24) NOT NULL,
  RELATEDCUSTOMER_LINK_ID    NUMBER,
  PRODUCT_LINK_ID            NUMBER NOT NULL,
  SIZEDEFINITION_LINK_ID     NUMBER NOT NULL,
  PRODUCTIONPROCESSBUFFER_ID NUMBER,
  PREVPRODPROCESSBUFFER_ID   NUMBER,
  BATCHNUMBER                VARCHAR2(15),
  LASTSCANSTATION            VARCHAR2(15) NOT NULL,
  SYSTEMUSER_ID              NUMBER NOT NULL,
  TIMESTAMP                  DATE NOT NULL
);

ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT XPKUNIQUEITEMBUFFERINFO PRIMARY KEY (UNIQUEITEMBUFFERINFO_ID);

CREATE UNIQUE INDEX XAK1UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (UNIQUEITEM_ID ASC);
  
CREATE INDEX XIE1UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PLANT_ID ASC, LASTSCANDATE ASC);
CREATE INDEX XIE2UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PRODUCTIONPROCESSBUFFER_ID ASC, LASTSCANTIMESTAMP ASC);
CREATE INDEX XIE3UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (UNIQUEITEM_ID ASC, LASTSCANTIMESTAMP ASC);
CREATE INDEX XIE4UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PRODUCTIONPROCESSBUFFER_ID ASC, RELATEDCUSTOMER_LINK_ID ASC);
CREATE INDEX XIE5UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PRODUCTIONPROCESSBUFFER_ID ASC, PRODUCT_LINK_ID ASC);
CREATE INDEX XIE6UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PRODUCTIONPROCESSBUFFER_ID ASC, BATCHNUMBER ASC);

CREATE INDEX XIF1UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (BUSINESSUNIT_ID ASC);
CREATE INDEX XIF2UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PLANT_ID ASC);
CREATE INDEX XIF3UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (RELATEDCUSTOMER_LINK_ID ASC);
CREATE INDEX XIF4UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PRODUCT_LINK_ID ASC);
CREATE INDEX XIF5UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (SIZEDEFINITION_LINK_ID ASC);
CREATE INDEX XIF6UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PRODUCTIONPROCESSBUFFER_ID ASC);
CREATE INDEX XIF7UNIQUEITEMBUFFERINFO ON UNIQUEITEMBUFFERINFO (PREVPRODPROCESSBUFFER_ID ASC);

ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT UNIQUEITEMBUFFERINFO_UI FOREIGN KEY (UNIQUEITEM_ID)
  REFERENCES UNIQUEITEM (UNIQUEITEM_ID) ON DELETE CASCADE;
ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT UNIQUEITEMBUFFERINFO_BU FOREIGN KEY (BUSINESSUNIT_ID)
  REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);
ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT UNIQUEITEMBUFFERINFO_PLANT FOREIGN KEY (PLANT_ID)
  REFERENCES PLANT (PLANT_ID);
ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT UNIQUEITEMBUFFERINFO_CUST FOREIGN KEY (RELATEDCUSTOMER_LINK_ID)
  REFERENCES CUSTOMER_LINK (CUSTOMER_LINK_ID);
ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT UNIQUEITEMBUFFERINFO_PROD FOREIGN KEY (PRODUCT_LINK_ID)
  REFERENCES PRODUCT_LINK (PRODUCT_LINK_ID);
ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT UNIQUEITEMBUFFERINFO_SIZE FOREIGN KEY (SIZEDEFINITION_LINK_ID)
  REFERENCES SIZEDEFINITION_LINK (SIZEDEFINITION_LINK_ID);
ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT UNIQUEITEMBUFFERINFO_PROC FOREIGN KEY (PRODUCTIONPROCESSBUFFER_ID)
  REFERENCES PRODUCTIONPROCESSBUFFER (PRODUCTIONPROCESSBUFFER_ID);
ALTER TABLE UNIQUEITEMBUFFERINFO
  ADD CONSTRAINT UNIQUEITEMBUFFERINFO_PREVPROC FOREIGN KEY (PREVPRODPROCESSBUFFER_ID)
  REFERENCES PRODUCTIONPROCESSBUFFER (PRODUCTIONPROCESSBUFFER_ID);

--------------------- PRODUCTIONPROCESSSCANAGGR ---------------------
CREATE SEQUENCE SEQ_PRODUCTIONPROCESSSCANAGGR
START WITH 1
INCREMENT BY 1;

CREATE TABLE PRODUCTIONPROCESSSCANAGGR
( PRODUCTIONPROCESSSCANAGGR_ID NUMBER NOT NULL,
  BUSINESSUNIT_ID              NUMBER NOT NULL,
  SCANDATE                     DATE NOT NULL,
  RELATEDCUSTOMER_LINK_ID      NUMBER,
  PRODUCT_LINK_ID              NUMBER NOT NULL,
  SIZEDEFINITION_LINK_ID       NUMBER NOT NULL,
  TOPRODPROCESSBUFFER_ID       NUMBER,
  FROMPRODPROCESSBUFFER_ID     NUMBER,
  BATCHNUMBER                  VARCHAR2(15),
  SCANSTATION                  VARCHAR2(12) NOT NULL,
  NUMBEROFSCANS                NUMBER NOT NULL,
  TOTALMINUTESINPREVBUFFER     NUMBER NOT NULL,
  TOTALMINUTESSINCEINSCAN      NUMBER NOT NULL,
  SYSTEMUSER_ID                NUMBER NOT NULL,
  TIMESTAMP                    DATE NOT NULL
);

ALTER TABLE PRODUCTIONPROCESSSCANAGGR
  ADD CONSTRAINT XPKPRODUCTIONPROCESSSCANAGGR PRIMARY KEY (PRODUCTIONPROCESSSCANAGGR_ID);
  
CREATE UNIQUE INDEX XAK1PRODUCTIONPROCESSSCANAGGR ON PRODUCTIONPROCESSSCANAGGR (BUSINESSUNIT_ID ASC, SCANDATE ASC, NVL(RELATEDCUSTOMER_LINK_ID,-1) ASC, PRODUCT_LINK_ID ASC, SIZEDEFINITION_LINK_ID ASC, NVL(TOPRODPROCESSBUFFER_ID,-1) ASC, NVL(FROMPRODPROCESSBUFFER_ID,-1) ASC, NVL(BATCHNUMBER,-1) ASC, SCANSTATION ASC);

CREATE INDEX XIE1PRODUCTIONPROCESSSCANAGGR ON PRODUCTIONPROCESSSCANAGGR (TIMESTAMP ASC);

CREATE INDEX XIF1PRODUCTIONPROCESSSCANAGGR ON PRODUCTIONPROCESSSCANAGGR (BUSINESSUNIT_ID ASC);
CREATE INDEX XIF2PRODUCTIONPROCESSSCANAGGR ON PRODUCTIONPROCESSSCANAGGR (RELATEDCUSTOMER_LINK_ID ASC);
CREATE INDEX XIF3PRODUCTIONPROCESSSCANAGGR ON PRODUCTIONPROCESSSCANAGGR (FROMPRODPROCESSBUFFER_ID ASC);
CREATE INDEX XIF4PRODUCTIONPROCESSSCANAGGR ON PRODUCTIONPROCESSSCANAGGR (PRODUCT_LINK_ID ASC);
CREATE INDEX XIF5PRODUCTIONPROCESSSCANAGGR ON PRODUCTIONPROCESSSCANAGGR (SIZEDEFINITION_LINK_ID ASC);
CREATE INDEX XIF6PRODUCTIONPROCESSSCANAGGR ON PRODUCTIONPROCESSSCANAGGR (TOPRODPROCESSBUFFER_ID ASC);

ALTER TABLE PRODUCTIONPROCESSSCANAGGR
  ADD CONSTRAINT PRODUCTIONPROCESSSCANAGGR_BU FOREIGN KEY (BUSINESSUNIT_ID)
  REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);

ALTER TABLE PRODUCTIONPROCESSSCANAGGR
  ADD CONSTRAINT PRODUCTIONPROCESSSCANAGGRCUST FOREIGN KEY (RELATEDCUSTOMER_LINK_ID)
  REFERENCES CUSTOMER_LINK (CUSTOMER_LINK_ID);

ALTER TABLE PRODUCTIONPROCESSSCANAGGR
  ADD CONSTRAINT PRODUCTIONPROCESSSCANAGGRFPPB FOREIGN KEY (FROMPRODPROCESSBUFFER_ID)
  REFERENCES PRODUCTIONPROCESSBUFFER (PRODUCTIONPROCESSBUFFER_ID);

ALTER TABLE PRODUCTIONPROCESSSCANAGGR
  ADD CONSTRAINT PRODUCTIONPROCESSSCANAGGRPROD FOREIGN KEY (PRODUCT_LINK_ID)
  REFERENCES PRODUCT_LINK (PRODUCT_LINK_ID);

ALTER TABLE PRODUCTIONPROCESSSCANAGGR
  ADD CONSTRAINT PRODUCTIONPROCESSSCANAGGRSIZE FOREIGN KEY (SIZEDEFINITION_LINK_ID)
  REFERENCES SIZEDEFINITION_LINK (SIZEDEFINITION_LINK_ID);

ALTER TABLE PRODUCTIONPROCESSSCANAGGR
  ADD CONSTRAINT PRODUCTIONPROCESSSCANAGGRTPPB FOREIGN KEY (TOPRODPROCESSBUFFER_ID)
  REFERENCES PRODUCTIONPROCESSBUFFER (PRODUCTIONPROCESSBUFFER_ID);
  
ALTER TABLE PRODUCTIONPROCESSSCANAGGR
  ADD CONSTRAINT PRODUCTIONPROCESSSCANAGGR_VAL CHECK ((TOPRODPROCESSBUFFER_ID IS NULL  AND FROMPRODPROCESSBUFFER_ID IS NOT NULL) OR (FROMPRODPROCESSBUFFER_ID IS NULL AND TOPRODPROCESSBUFFER_ID IS NOT NULL) OR (FROMPRODPROCESSBUFFER_ID IS NOT NULL AND TOPRODPROCESSBUFFER_ID IS NOT NULL));

--------------------- PRODUCTIONPROCESSSCAN ---------------------
CREATE SEQUENCE SEQ_PRODUCTIONPROCESSSCAN
START WITH 1
INCREMENT BY 1;

CREATE TABLE PRODUCTIONPROCESSSCAN
( PRODUCTIONPROCESSSCAN_ID NUMBER NOT NULL,
  PLANT_ID                 NUMBER NOT NULL,
  BUSINESSUNIT_ID          NUMBER NOT NULL,
  SCANDATE                 DATE NOT NULL,
  SCANTIMESTAMP            DATE NOT NULL,
  UNIQUEITEM_LINK_ID       NUMBER NOT NULL,
  UNIQUEITEMBUFFERINFO_ID  NUMBER,
  IDCODE                   VARCHAR2(24) NOT NULL,
  RELATEDCUSTOMER_LINK_ID  NUMBER,
  PRODUCT_LINK_ID          NUMBER NOT NULL,
  SIZEDEFINITION_LINK_ID   NUMBER NOT NULL,
  TOPRODPROCESSBUFFER_ID   NUMBER,
  FROMPRODPROCESSBUFFER_ID NUMBER,
  MINUTESINPREVIOUSBUFFER  NUMBER NOT NULL,
  MINUTESSINCEINSCAN       NUMBER NOT NULL,
  BATCHNUMBER              VARCHAR2(15),
  SCANSTATION              VARCHAR2(12) NOT NULL,
  SYSTEMUSER_ID            NUMBER NOT NULL,
  TIMESTAMP                DATE NOT NULL
);

ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT XPKPRODUCTIONPROCESSSCAN PRIMARY KEY (PRODUCTIONPROCESSSCAN_ID);

CREATE UNIQUE INDEX XAK1PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (BUSINESSUNIT_ID ASC, IDCODE ASC, SCANTIMESTAMP ASC);

CREATE INDEX XIE1PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (PLANT_ID ASC, SCANDATE ASC);
CREATE INDEX XIE2PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (TOPRODPROCESSBUFFER_ID ASC, SCANTIMESTAMP ASC);
CREATE INDEX XIE3PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (UNIQUEITEM_LINK_ID ASC, SCANTIMESTAMP ASC);
CREATE INDEX XIE4PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (UNIQUEITEMBUFFERINFO_ID ASC, SCANTIMESTAMP ASC);
CREATE INDEX XIE5PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (FROMPRODPROCESSBUFFER_ID ASC, SCANTIMESTAMP ASC);

CREATE INDEX XIF1PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (BUSINESSUNIT_ID ASC);
CREATE INDEX XIF2PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (RELATEDCUSTOMER_LINK_ID ASC);
CREATE INDEX XIF3PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (PLANT_ID ASC);
CREATE INDEX XIF4PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (TOPRODPROCESSBUFFER_ID ASC);
CREATE INDEX XIF5PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (FROMPRODPROCESSBUFFER_ID ASC);
CREATE INDEX XIF6PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (PRODUCT_LINK_ID ASC);
CREATE INDEX XIF7PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (SIZEDEFINITION_LINK_ID ASC);
CREATE INDEX XIF8PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (UNIQUEITEMBUFFERINFO_ID ASC);
CREATE INDEX XIF9PRODUCTIONPROCESSSCAN ON PRODUCTIONPROCESSSCAN (UNIQUEITEM_LINK_ID ASC);

ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_BU_ID FOREIGN KEY (BUSINESSUNIT_ID)
  REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);
ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_CU_ID FOREIGN KEY (RELATEDCUSTOMER_LINK_ID)
  REFERENCES CUSTOMER_LINK (CUSTOMER_LINK_ID);
ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_PL_ID FOREIGN KEY (PLANT_ID)
  REFERENCES PLANT (PLANT_ID);
ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_PPB_ID FOREIGN KEY (TOPRODPROCESSBUFFER_ID)
  REFERENCES PRODUCTIONPROCESSBUFFER (PRODUCTIONPROCESSBUFFER_ID);
ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_PRPPB_ID FOREIGN KEY (FROMPRODPROCESSBUFFER_ID)
  REFERENCES PRODUCTIONPROCESSBUFFER (PRODUCTIONPROCESSBUFFER_ID);
ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_PR_ID FOREIGN KEY (PRODUCT_LINK_ID)
  REFERENCES PRODUCT_LINK (PRODUCT_LINK_ID);
ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_SZ_ID FOREIGN KEY (SIZEDEFINITION_LINK_ID)
  REFERENCES SIZEDEFINITION_LINK (SIZEDEFINITION_LINK_ID);
ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_UIBI_ID FOREIGN KEY (UNIQUEITEMBUFFERINFO_ID)
  REFERENCES UNIQUEITEMBUFFERINFO (UNIQUEITEMBUFFERINFO_ID) ON DELETE SET NULL;
ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_UI_ID FOREIGN KEY (UNIQUEITEM_LINK_ID)
  REFERENCES UNIQUEITEM_LINK (UNIQUEITEM_LINK_ID);

ALTER TABLE PRODUCTIONPROCESSSCAN
  ADD CONSTRAINT PRODUCTIONPROCESSSCAN_VALID CHECK ((FROMPRODPROCESSBUFFER_ID IS NOT NULL AND TOPRODPROCESSBUFFER_ID IS NULL) OR (FROMPRODPROCESSBUFFER_ID IS NULL AND TOPRODPROCESSBUFFER_ID IS NOT NULL) OR (FROMPRODPROCESSBUFFER_ID IS NOT NULL AND TOPRODPROCESSBUFFER_ID IS NOT NULL));


--------------------- PRODPROCESSBUFFERSNAPSHOT ---------------------
CREATE SEQUENCE SEQ_PRODPROCESSBUFFERSNAPSHOT
START WITH 1
INCREMENT BY 1;

CREATE TABLE PRODPROCESSBUFFERSNAPSHOT
( PRODPROCESSBUFFERSNAPSHOT_ID   NUMBER NOT NULL,
  PLANT_ID                   NUMBER NOT NULL,
  BUSINESSUNIT_ID            NUMBER NOT NULL,
  SNAPSHOTLOCALDATE          DATE NOT NULL,
  SNAPSHOTLOCALTIMEOFDAY     NUMBER NOT NULL,
  PRODUCTIONPROCESSBUFFER_ID NUMBER NOT NULL,
  PRODUCT_LINK_ID            NUMBER NOT NULL,
  SIZEDEFINITION_LINK_ID     NUMBER NOT NULL,
  NUMBEROFITEMS              NUMBER NOT NULL,
  SYSTEMUSER_ID              NUMBER NOT NULL,
  TIMESTAMP                  DATE NOT NULL
);

ALTER TABLE PRODPROCESSBUFFERSNAPSHOT
  ADD CONSTRAINT XPKPRODPROCESSBUFFERSNAPSHOT PRIMARY KEY (PRODPROCESSBUFFERSNAPSHOT_ID);
  
CREATE UNIQUE INDEX XAK1PRODPROCESSBUFFERSNAPSHOT ON PRODPROCESSBUFFERSNAPSHOT (BUSINESSUNIT_ID ASC,SNAPSHOTLOCALDATE ASC, SNAPSHOTLOCALTIMEOFDAY ASC,
                                                                                PRODUCTIONPROCESSBUFFER_ID ASC, PRODUCT_LINK_ID ASC, SIZEDEFINITION_LINK_ID ASC);
  
CREATE INDEX XIE1PRODPROCESSBUFFERSNAPSHOT ON PRODPROCESSBUFFERSNAPSHOT (PLANT_ID ASC, SNAPSHOTLOCALDATE ASC);
CREATE INDEX XIE2PRODPROCESSBUFFERSNAPSHOT ON PRODPROCESSBUFFERSNAPSHOT (TIMESTAMP ASC);

CREATE INDEX XIF1PRODPROCESSBUFFERSNAPSHOT ON PRODPROCESSBUFFERSNAPSHOT (BUSINESSUNIT_ID ASC);
CREATE INDEX XIF2PRODPROCESSBUFFERSNAPSHOT ON PRODPROCESSBUFFERSNAPSHOT (PLANT_ID ASC);
CREATE INDEX XIF3PRODPROCESSBUFFERSNAPSHOT ON PRODPROCESSBUFFERSNAPSHOT (PRODUCTIONPROCESSBUFFER_ID ASC);
CREATE INDEX XIF4PRODPROCESSBUFFERSNAPSHOT ON PRODPROCESSBUFFERSNAPSHOT (PRODUCT_LINK_ID ASC);
CREATE INDEX XIF5PRODPROCESSBUFFERSNAPSHOT ON PRODPROCESSBUFFERSNAPSHOT (SIZEDEFINITION_LINK_ID ASC);

ALTER TABLE PRODPROCESSBUFFERSNAPSHOT
  ADD CONSTRAINT PRODPROCESSBUFFERSNAPSHOT_BUID FOREIGN KEY (BUSINESSUNIT_ID)
  REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);
ALTER TABLE PRODPROCESSBUFFERSNAPSHOT
  ADD CONSTRAINT PRODPROCESSBUFFERSNAPSHOT_PLID FOREIGN KEY (PLANT_ID)
  REFERENCES PLANT (PLANT_ID);
ALTER TABLE PRODPROCESSBUFFERSNAPSHOT
  ADD CONSTRAINT PRODPROCESSBUFFERSNAPSHOT_PBID FOREIGN KEY (PRODUCTIONPROCESSBUFFER_ID)
  REFERENCES PRODUCTIONPROCESSBUFFER (PRODUCTIONPROCESSBUFFER_ID);
ALTER TABLE PRODPROCESSBUFFERSNAPSHOT
  ADD CONSTRAINT PRODPROCESSBUFFERSNAPSHOT_PRID FOREIGN KEY (PRODUCT_LINK_ID)
  REFERENCES PRODUCT_LINK (PRODUCT_LINK_ID);
ALTER TABLE PRODPROCESSBUFFERSNAPSHOT
  ADD CONSTRAINT PRODPROCESSBUFFERSNAPSHOT_SZID FOREIGN KEY (SIZEDEFINITION_LINK_ID)
  REFERENCES SIZEDEFINITION_LINK (SIZEDEFINITION_LINK_ID);
  
  
--------------------- MULTIREADSCANBATCHCONTENTS ---------------------
ALTER TABLE MULTIREADSCANBATCHCONTENTS ADD (PRODUCTIONPROCESSBUFFER_ID NUMBER,
                                            UNIQUEITEMBATCHNUMBER VARCHAR2(15),
                                            PRODUCTIONPROCESSSCAN_ID NUMBER);
