SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;

SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;

SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';



CREATE SCHEMA IF NOT EXISTS `banks` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;

USE `banks` ;



-- -----------------------------------------------------

-- Table `banks`.`bank`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `banks`.`bank` ;



CREATE  TABLE IF NOT EXISTS `banks`.`bank` (

  `bank_id` INT NOT NULL AUTO_INCREMENT ,

  `bank_name` VARCHAR(45) NOT NULL ,

  `bank_logo` VARCHAR(45) NOT NULL ,

  `bank_employees` INT(11) NOT NULL ,

  `bank_image` VARCHAR(100) NOT NULL ,

  `bank_hq` VARCHAR(45) NOT NULL ,

  `bank_customers` VARCHAR(45) NOT NULL ,

  `has_visa` TINYINT NOT NULL ,

  `has_interswitch` TINYINT NOT NULL ,

  `bank_created` VARCHAR(45) NOT NULL ,

  PRIMARY KEY (`bank_id`) )

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `banks`.`branch`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `banks`.`branch` ;



CREATE  TABLE IF NOT EXISTS `banks`.`branch` (

  `branch_id` INT NOT NULL AUTO_INCREMENT ,

  `branch_parent` INT(11) NOT NULL ,

  `branch_xcord` VARCHAR(45) NOT NULL ,

  `branch_ycord` VARCHAR(45) NOT NULL ,

  `branch_location` VARCHAR(45) NOT NULL ,

  `branch_number` VARCHAR(45) NOT NULL ,

  PRIMARY KEY (`branch_id`) ,

  INDEX `branch_parent_idx` (`branch_parent` ASC) ,

  CONSTRAINT `branch_parent`

    FOREIGN KEY (`branch_parent` )

    REFERENCES `banks`.`bank` (`bank_id` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `banks`.`atm`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `banks`.`atm` ;



CREATE  TABLE IF NOT EXISTS `banks`.`atm` (

  `atm_id` INT NOT NULL AUTO_INCREMENT ,

  `atm_parent` INT(11) NOT NULL ,

  `atm_xcord` VARCHAR(45) NOT NULL ,

  `atm_ycord` VARCHAR(45) NOT NULL ,

  `atm_location` VARCHAR(45) NOT NULL ,

  PRIMARY KEY (`atm_id`) ,

  INDEX `atm_parent_idx` (`atm_parent` ASC) ,

  CONSTRAINT `atm_parent`

    FOREIGN KEY (`atm_parent` )

    REFERENCES `banks`.`bank` (`bank_id` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `banks`.`account`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `banks`.`account` ;



CREATE  TABLE IF NOT EXISTS `banks`.`account` (

  `account_id` INT NOT NULL AUTO_INCREMENT ,

  `account_name` VARCHAR(45) NOT NULL ,

  `account_parent` INT(11) NOT NULL ,

  `account_minimum` INT(11) NOT NULL ,

  `has_monthly_charge` TINYINT NOT NULL ,

  `account_charge` INT(11) NOT NULL ,

  `account_benefits` VARCHAR(255) NOT NULL ,

  PRIMARY KEY (`account_id`) ,

  INDEX `account_parent_idx` (`account_parent` ASC) ,

  CONSTRAINT `account_parent`

    FOREIGN KEY (`account_parent` )

    REFERENCES `banks`.`bank` (`bank_id` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `banks`.`event`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `banks`.`event` ;



CREATE  TABLE IF NOT EXISTS `banks`.`event` (

  `event_id` INT NOT NULL AUTO_INCREMENT ,

  `event_name` VARCHAR(45) NOT NULL ,

  `event_parent` INT(11) NOT NULL ,

  `event_xcord` VARCHAR(45) NOT NULL ,

  `event_ycord` VARCHAR(45) NOT NULL ,

  `event_location` VARCHAR(45) NOT NULL ,

  `event_date` VARCHAR(45) NOT NULL ,

  PRIMARY KEY (`event_id`) ,

  INDEX `event_parent_idx` (`event_parent` ASC) ,

  CONSTRAINT `event_parent`

    FOREIGN KEY (`event_parent` )

    REFERENCES `banks`.`bank` (`bank_id` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;





-- -----------------------------------------------------

-- Table `banks`.`promotion`

-- -----------------------------------------------------

DROP TABLE IF EXISTS `banks`.`promotion` ;



CREATE  TABLE IF NOT EXISTS `banks`.`promotion` (

  `promotion_id` INT NOT NULL AUTO_INCREMENT ,

  `promotion_name` VARCHAR(45) NOT NULL ,

  `promotion_parent` INT(11) NOT NULL ,

  `promotion_desc` VARCHAR(45) NOT NULL ,

  `promotion_prize` VARCHAR(45) NOT NULL ,

  `promotion_start` VARCHAR(45) NOT NULL ,

  `promotion_end` VARCHAR(45) NOT NULL ,

  PRIMARY KEY (`promotion_id`) ,

  INDEX `promotion_parent_idx` (`promotion_parent` ASC) ,

  CONSTRAINT `promotion_parent`

    FOREIGN KEY (`promotion_parent` )

    REFERENCES `banks`.`bank` (`bank_id` )

    ON DELETE NO ACTION

    ON UPDATE NO ACTION)

ENGINE = InnoDB;



USE `banks` ;





SET SQL_MODE=@OLD_SQL_MODE;

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

