--ABS-89259/ ABS-104236

CREATE TABLE CONTAINERSPERPNSTOP
(
	CONTAINERSPERSTOP_ID NUMBER NOT NULL,
	PACKINGNOTE_ID NUMBER NOT NULL, 
	SYSTEMUSER_ID            NUMBER NOT NULL,
	TIMESTAMP                DATE NOT NULL 
);

CREATE UNIQUE INDEX XAK1CONTAINERSPERPNSTOP ON CONTAINERSPERPNSTOP
(CONTAINERSPERSTOP_ID   ASC, PACKINGNOTE_ID  ASC);

CREATE INDEX XIF1CONTAINERSPERPNSTOP ON CONTAINERSPERPNSTOP (CONTAINERSPERSTOP_ID  ASC);

CREATE INDEX XIF2CONTAINERSPERPNSTOP ON CONTAINERSPERPNSTOP (PACKINGNOTE_ID   ASC);

ALTER TABLE CONTAINERSPERPNSTOP ADD CONSTRAINT FK_CONTAINERPNST_CONTST FOREIGN KEY (CONTAINERSPERSTOP_ID)
REFERENCES CONTAINERSPERSTOP (CONTAINERSPERSTOP_ID) ON DELETE CASCADE;

ALTER TABLE CONTAINERSPERPNSTOP ADD CONSTRAINT FK_CONTAINERPNST_PN FOREIGN KEY (PACKINGNOTE_ID)
REFERENCES PACKINGNOTE (PACKINGNOTE_ID) ON DELETE CASCADE;
