--Order 20012939.470

---------------------------WORKORDERNCPICKSEQUENCE-------------------------------

CREATE TABLE WORKORDERNCPICKSEQUENCE
(
	WORKORDER_ID         NUMBER NOT NULL ,
	PICKLIST_ID          NUMBER NOT NULL ,
	NC_PICKINGSEQUENCE   NUMBER DEFAULT  0  NOT NULL ,
	NC_MIN_DISTANCE      NUMBER DEFAULT  0  NOT NULL 
);

COMMENT ON COLUMN WORKORDERNCPICKSEQUENCE.NC_PICKINGSEQUENCE IS 'PickingSequence that is defined for one or more stockroom locations that may be used to fullfill the demand for the workorder when using the current pick list';

COMMENT ON COLUMN WORKORDERNCPICKSEQUENCE.NC_MIN_DISTANCE IS 'Minimum distance between current picking sequence and all picking sequences that have been defined for the reference work order of the pick list.';


ALTER TABLE WORKORDERNCPICKSEQUENCE
ADD CONSTRAINT  XPKWORKORDERNCPICKINGSEQUENCE PRIMARY KEY (WORKORDER_ID,PICKLIST_ID,NC_PICKINGSEQUENCE);


ALTER TABLE WORKORDERNCPICKSEQUENCE
ADD CONSTRAINT WONPICKSEQ_WORKORDER_ID FOREIGN KEY (WORKORDER_ID) REFERENCES WORKORDER (WORKORDER_ID) ON DELETE CASCADE;

CREATE  INDEX XIF1WORKORDERNCPICKINGSEQUENCE ON WORKORDERNCPICKSEQUENCE
(WORKORDER_ID   ASC);

ALTER TABLE WORKORDERNCPICKSEQUENCE
ADD CONSTRAINT WONPICKSEQ_PICKLIST_ID FOREIGN KEY (PICKLIST_ID) REFERENCES PICKLIST (PICKLIST_ID) ON DELETE CASCADE;

CREATE  INDEX XIF2WORKORDERNCPICKINGSEQUENCE ON WORKORDERNCPICKSEQUENCE
(PICKLIST_ID   ASC);
