 --order 502627     


     
      /*
      ACTION is CREATE Table PRODUCTRANKING
      */

CREATE SEQUENCE SEQ_PRODUCTRANKING
START WITH 1
INCREMENT BY 1;


CREATE TABLE PRODUCTRANKING (
       PRODUCTRANKING_ID    NUMBER NOT NULL,
       PRIORITY             NUMBER NOT NULL,
       RANKING              VARCHAR2(10) NOT NULL,
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE UNIQUE INDEX XAK1PRODUCTRANKING ON PRODUCTRANKING
(
       PRIORITY                       
);

CREATE UNIQUE INDEX XAK2PRODUCTRANKING ON PRODUCTRANKING
(
       RANKING                        
);


ALTER TABLE PRODUCTRANKING
       ADD  ( CONSTRAINT XPKPRODUCTRANKING PRIMARY KEY (
              PRODUCTRANKING_ID) ) ;

      /*
      CHANGE REPORT for Table PRODUCT
          - Adding a new relationship PROD_PRODUCTRANKING_ID
          WARNING : Create FK statement may fail (existing data may violate the new FK rules: adding a new FK PROD_PRODUCTRANKING_ID of table PRODUCT, which references table PRODUCTRANKING).
          - Adding column PRODUCTRANKING_ID
      ACTION is ALTER or modify Table PRODUCT
      */

ALTER TABLE PRODUCT ADD (PRODUCTRANKING_ID    NUMBER NULL);

CREATE INDEX XIF28PRODUCT ON PRODUCT
(
       PRODUCTRANKING_ID              ASC
);


ALTER TABLE PRODUCT
       ADD  ( CONSTRAINT PROD_PRODUCTRANKING_ID
              FOREIGN KEY (PRODUCTRANKING_ID)
                             REFERENCES PRODUCTRANKING ) ;



