--ABSN-9340

-- PARKEDCONTAINERCONTENT TABLE
CREATE SEQUENCE SEQ_PARKEDCONTAINERCONTENT
START WITH 1
INCREMENT BY 1;

CREATE TABLE PARKEDCONTAINERCONTENT
(
  PARKEDCONTAINERCONTENT_ID          NUMBER NOT NULL,
  CONTAINER_ID                       NUMBER NOT NULL,
  PRODUCTLISTPERDISTRIBUTIONPOINT_ID NUMBER NOT NULL,
  STOCKCOUNTQTY                      NUMBER DEFAULT 0 NOT NULL,
  DELIVERYDATE                       DATE NOT NULL,
  CREATIONTIMESTAMP                  DATE NOT NULL,
  CREATIONSYSTEMUSER_ID              NUMBER NOT NULL,
  SYSTEMUSER_ID                      NUMBER NOT NULL,
  TIMESTAMP                          DATE NOT NULL
)
;

COMMENT ON COLUMN PARKEDCONTAINERCONTENT.STOCKCOUNTQTY
  IS 'The count the user did on ECA. If no count is done, default with 0';
COMMENT ON COLUMN PARKEDCONTAINERCONTENT.DELIVERYDATE
  IS 'The delivery date selected on ECA for which the user does the initial count';
COMMENT ON COLUMN PARKEDCONTAINERCONTENT.CREATIONTIMESTAMP
  IS 'The time the ECA user parked the cart';
COMMENT ON COLUMN PARKEDCONTAINERCONTENT.CREATIONSYSTEMUSER_ID
  IS 'The ECA user that counted and parked the cart';

ALTER TABLE PARKEDCONTAINERCONTENT
  ADD CONSTRAINT XPKPARKEDCONTAINERCONTENT PRIMARY KEY (PARKEDCONTAINERCONTENT_ID);
  
CREATE INDEX XIF1PARKEDCONTAINERCONTENT ON PARKEDCONTAINERCONTENT (CONTAINER_ID ASC);
CREATE INDEX XIF2PARKEDCONTAINERCONTENT ON PARKEDCONTAINERCONTENT (PRODUCTLISTPERDISTRIBUTIONPOINT_ID ASC);

ALTER TABLE PARKEDCONTAINERCONTENT
  ADD CONSTRAINT FK_PARKEDCONTCONTENT_CONTAINER FOREIGN KEY (CONTAINER_ID)
  REFERENCES CONTAINER (CONTAINER_ID);
  
ALTER TABLE PARKEDCONTAINERCONTENT
  ADD CONSTRAINT FK_PARKEDCONTCONTENT_PLPD FOREIGN KEY (PRODUCTLISTPERDISTRIBUTIONPOINT_ID)
  REFERENCES PRODUCTLISTPERDISTRIBPOINT (PRODUCTLISTPERDISTRIBPOINT_ID);
