-- ABS-46021/ ABS-51232

---CONTRACTPRODUCTPLPC table---
CREATE TABLE CONTRACTPRODUCTPLPC
(
  CONTRACTPRODUCT_ID        NUMBER NOT NULL,
  PRODUCTLISTPERCUSTOMER_ID NUMBER NOT NULL,
  SYSTEMUSER_ID             NUMBER NOT NULL,
  TIMESTAMP                 DATE NOT NULL
)
;

ALTER TABLE CONTRACTPRODUCTPLPC
  ADD CONSTRAINT XPKCONTRACTPRODUCTPLPC PRIMARY KEY (CONTRACTPRODUCT_ID, PRODUCTLISTPERCUSTOMER_ID);
  
CREATE INDEX XIF1CONTRACTPRODUCTPLPC ON CONTRACTPRODUCTPLPC (CONTRACTPRODUCT_ID ASC);
CREATE INDEX XIF2CONTRACTPRODUCTPLPC ON CONTRACTPRODUCTPLPC (PRODUCTLISTPERCUSTOMER_ID ASC);

ALTER TABLE CONTRACTPRODUCTPLPC
  ADD CONSTRAINT CONTRACTPRODUCTPLPC_CP FOREIGN KEY (CONTRACTPRODUCT_ID)
  REFERENCES CONTRACTPRODUCT (CONTRACTPRODUCT_ID) ON DELETE CASCADE;
  
ALTER TABLE CONTRACTPRODUCTPLPC
  ADD CONSTRAINT CONTRACTPRODUCTPLPC_PLPC FOREIGN KEY (PRODUCTLISTPERCUSTOMER_ID)
  REFERENCES PRODUCTLISTPERCUSTOMER (PRODUCTLISTPERCUSTOMER_ID) ON DELETE CASCADE;