DROP TABLE IF EXISTS SavingsProduct;

CREATE TABLE SavingsProduct (
  `product_id` smallint unsigned NOT NULL,
  `cycle` tinyint unsigned NOT NULL,
  `class_id` tinyint unsigned NOT NULL,
  `min_savings_amount` mediumint unsigned NOT NULL,
  `max_savings_amount` mediumint unsigned NOT NULL,
  `interest_rate` decimal(13,10) NOT NULL,
  `balance_id` tinyint unsigned DEFAULT NULL,
  `time_period` smallint unsigned DEFAULT NULL,
  `time_period_unit` tinyint unsigned DEFAULT NULL,
  `frequency` smallint unsigned DEFAULT NULL,
  `frequency_unit` tinyint unsigned DEFAULT NULL,
  `minimum_balance` mediumint unsigned DEFAULT NULL,
  `min_age_savings` tinyint unsigned NOT NULL,
  `max_age_savings` tinyint unsigned NOT NULL,
  PRIMARY KEY (product_id),
  FOREIGN KEY (product_id) REFERENCES Product (id) ON DELETE NO ACTION ON UPDATE CASCADE,
  FOREIGN KEY (time_period_unit) REFERENCES TenureMaster (id) ON DELETE NO ACTION ON UPDATE CASCADE,
  FOREIGN KEY (frequency_unit) REFERENCES TenureMaster (id) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE=InnoDB CHARACTER SET utf8;



