 /*ORDER 502438*/ 
      /*
      ACTION is CREATE Table PLANTQUALITYGRADESETTINGS
      */

CREATE TABLE PLANTQUALITYGRADESETTINGS (
       QUALITYGRADE_ID      NUMBER NOT NULL,
       PLANT_ID             NUMBER NOT NULL,
       EXPECTEDRETURNPERCENTAGE NUMBER(4,1) DEFAULT 0.0 NOT NULL
                                   CONSTRAINT ExpectedRetPerc_valid
                                          CHECK (EXPECTEDRETURNPERCENTAGE BETWEEN 0.0 AND 100.0),
       SYSTEMUSER_ID        NUMBER NOT NULL,
       TIMESTAMP            DATE NOT NULL
);

CREATE INDEX XIF1PLANTQUALITYGRADESETTINGS ON PLANTQUALITYGRADESETTINGS
(
       QUALITYGRADE_ID                ASC
);

CREATE INDEX XIF2PLANTQUALITYGRADESETTINGS ON PLANTQUALITYGRADESETTINGS
(
       PLANT_ID                       ASC
);


ALTER TABLE PLANTQUALITYGRADESETTINGS
       ADD  ( CONSTRAINT XPKPLANTQUALITYGRADESETTINGS PRIMARY KEY (
              QUALITYGRADE_ID, PLANT_ID) ) ;


ALTER TABLE PLANTQUALITYGRADESETTINGS
       ADD  ( CONSTRAINT PLANTQUALITYGRADESETTINGS_PLAN
              FOREIGN KEY (PLANT_ID)
                             REFERENCES PLANT
                             ON DELETE CASCADE ) ;


ALTER TABLE PLANTQUALITYGRADESETTINGS
       ADD  ( CONSTRAINT PLANTQUALITYGRADESETTINGS_QUAL
              FOREIGN KEY (QUALITYGRADE_ID)
                             REFERENCES QUALITYGRADE
                             ON DELETE CASCADE ) ;



