--Order 20014522


CREATE TABLE BATCHPICKUP
(
	BATCH_ID             NUMBER NOT NULL ,
	CUSTOMER_ID          NUMBER NOT NULL ,
	PICKUPDAY_ID         NUMBER NOT NULL ,
	PICKUPDATE           DATE NOT NULL ,
	SYSTEMUSER_ID        NUMBER NOT NULL ,
	TIMESTAMP            DATE NOT NULL 
);

ALTER TABLE BATCHPICKUP
ADD CONSTRAINT  XPKBATCHPICKUP PRIMARY KEY (BATCH_ID,CUSTOMER_ID);


ALTER TABLE BATCHPICKUP
ADD CONSTRAINT BATCHPICKUP_BATCH_ID FOREIGN KEY (BATCH_ID) REFERENCES BATCH (BATCH_ID) ON DELETE CASCADE;

CREATE INDEX XIF1BATCHPICKUP ON BATCHPICKUP
(BATCH_ID   ASC);

ALTER TABLE BATCHPICKUP
ADD CONSTRAINT BATCHPICKUP_CUSTOMER_ID FOREIGN KEY (CUSTOMER_ID) REFERENCES CUSTOMER (CUSTOMER_ID) ON DELETE CASCADE;

CREATE INDEX XIF2BATCHPICKUP ON BATCHPICKUP
(CUSTOMER_ID   ASC);

ALTER TABLE BATCHPICKUP
ADD CONSTRAINT BATCHPICKUP_PICKUPDAY_ID FOREIGN KEY (PICKUPDAY_ID) REFERENCES DAY (DAY_ID);

CREATE INDEX XIF3BATCHPICKUP ON BATCHPICKUP
(PICKUPDAY_ID   ASC);








