/*order 502196*/      
      /*
      ACTION is CREATE Table CONTAINERSPERSTOP
      */

CREATE SEQUENCE SEQ_CONTAINERSPERSTOP
START WITH 1
INCREMENT BY 1;

CREATE TABLE CONTAINERSPERSTOP (
       CONTAINERSPERSTOP_ID NUMBER NOT NULL,
       STOP_ID              NUMBER NOT NULL,
       DISTRIBUTIONPOINT_LINK_ID NUMBER NOT NULL,
       TRANSPORTARTICLE_ID  NUMBER NOT NULL,
       REMARK               VARCHAR2(40) NULL,
       NUMBERSTICKERS       NUMBER DEFAULT 0 NOT NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE INDEX XIF1CONTAINERSPERSTOP ON CONTAINERSPERSTOP
(
       STOP_ID                        ASC
);

CREATE INDEX XIF2CONTAINERSPERSTOP ON CONTAINERSPERSTOP
(
       DISTRIBUTIONPOINT_LINK_ID      ASC
);

CREATE INDEX XIF3CONTAINERSPERSTOP ON CONTAINERSPERSTOP
(
       TRANSPORTARTICLE_ID            ASC
);


ALTER TABLE CONTAINERSPERSTOP
       ADD  ( CONSTRAINT XPKCONTAINERSPERSTOP PRIMARY KEY (
              CONTAINERSPERSTOP_ID) ) ;


ALTER TABLE CONTAINERSPERSTOP
       ADD  ( CONSTRAINT CONTAINERSPERSTOP_TRANSPORTART
              FOREIGN KEY (TRANSPORTARTICLE_ID)
                             REFERENCES TRANSPORTARTICLE ) ;


ALTER TABLE CONTAINERSPERSTOP
       ADD  ( CONSTRAINT CONTAINERSPERSTOP_DISTRIBUTION
              FOREIGN KEY (DISTRIBUTIONPOINT_LINK_ID)
                             REFERENCES DISTRIBUTIONPOINT_LINK
                             ON DELETE CASCADE ) ;


ALTER TABLE CONTAINERSPERSTOP
       ADD  ( CONSTRAINT CONTAINERSPERSTOP_STOP_ID
              FOREIGN KEY (STOP_ID)
                             REFERENCES STOP
                             ON DELETE CASCADE ) ;



