--Order 20014643.40


---UFHBUNDLE table---

CREATE SEQUENCE SEQ_UHFBUNDLE
START WITH 1
INCREMENT BY 1;

CREATE TABLE UHFBUNDLE
(
	UHFBUNDLE_ID         NUMBER NOT NULL ,
	BUSINESSUNIT_ID      NUMBER NOT NULL ,
	PRODUCT_LINK_ID      NUMBER NOT NULL ,
	SIZEDEFINITION_LINK_ID NUMBER NOT NULL ,
	BUNDLESIZE           NUMBER NOT NULL ,
	WORKSTATION          VARCHAR2(12) NOT NULL ,
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
);

COMMENT ON COLUMN UHFBUNDLE.BUNDLESIZE IS 'Number of unique items in the bundle.';

COMMENT ON COLUMN UHFBUNDLE.WORKSTATION IS 'Code of workstation that created this bundle.';

CREATE INDEX XIE1UHFBUNDLE ON UHFBUNDLE
(BUSINESSUNIT_ID   ASC,PRODUCT_LINK_ID   ASC,SIZEDEFINITION_LINK_ID   ASC);

ALTER TABLE UHFBUNDLE
ADD CONSTRAINT  XPKUHFBUNDLE PRIMARY KEY (UHFBUNDLE_ID);

ALTER TABLE UHFBUNDLE
ADD CONSTRAINT UHFBUNDLE_BU FOREIGN KEY (BUSINESSUNIT_ID) REFERENCES BUSINESSUNIT (BUSINESSUNIT_ID);

ALTER TABLE UHFBUNDLE
ADD CONSTRAINT UHFBUNDLE_PRODUCT_LINK FOREIGN KEY (PRODUCT_LINK_ID) REFERENCES PRODUCT_LINK (PRODUCT_LINK_ID);

ALTER TABLE UHFBUNDLE
ADD CONSTRAINT UHFBUNDLE_SIZEDEFINITION_LINK FOREIGN KEY (SIZEDEFINITION_LINK_ID) REFERENCES SIZEDEFINITION_LINK (SIZEDEFINITION_LINK_ID);


---MULTIREADSCANBATCH table---

ALTER TABLE MULTIREADSCANBATCHCONTENTS
	ADD (UHFBUNDLE_ID NUMBER);


---UNIQUEITEM table---
ALTER TABLE UNIQUEITEM
	ADD (UHFBUNDLE_ID NUMBER);

CREATE INDEX XIF20UNIQUEITEM ON UNIQUEITEM
(UHFBUNDLE_ID   ASC);

ALTER TABLE UNIQUEITEM
ADD CONSTRAINT UNIQUEITEM_UHFBUNDLE FOREIGN KEY (UHFBUNDLE_ID) REFERENCES UHFBUNDLE (UHFBUNDLE_ID) ON DELETE SET NULL;