use `akura`;

CREATE  TABLE `STUDENT_STATUS` (
  `STUDENT_STATUS_ID` INT(11) NOT NULL AUTO_INCREMENT ,
  `DESCRIPTION` VARCHAR(45) NOT NULL ,
  `MODIFIED_TIME` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
  PRIMARY KEY (`STUDENT_STATUS_ID`) 
) ENGINE = InnoDB

DEFAULT CHARACTER SET = latin1

COLLATE = latin1_swedish_ci;

INSERT INTO `STUDENT_STATUS` (`STUDENT_STATUS_ID`, `DESCRIPTION`) VALUES (1, 'Current');
INSERT INTO `STUDENT_STATUS` (`STUDENT_STATUS_ID`, `DESCRIPTION`) VALUES (2, 'Past');
INSERT INTO `STUDENT_STATUS` (`STUDENT_STATUS_ID`, `DESCRIPTION`) VALUES (3, 'Suspend');
INSERT INTO `STUDENT_STATUS` (`STUDENT_STATUS_ID`, `DESCRIPTION`) VALUES (4, 'Temporary Leave');

ALTER TABLE `STUDENT` 
ADD COLUMN `STUDENT_STATUS_ID` INT(11) NULL DEFAULT 1,  

  ADD CONSTRAINT `fk_STUDENT_STUDENTSTATUS1`

  FOREIGN KEY (`STUDENT_STATUS_ID` )

  REFERENCES `STUDENT_STATUS` (`STUDENT_STATUS_ID` )

  ON DELETE RESTRICT

  ON UPDATE CASCADE ;

UPDATE `STUDENT` SET `STUDENT_STATUS_ID`=1 
WHERE `STUDENT_STATUS_ID` is null;








