#-----------------------------------------------------------------------------
#-- katao_member_group
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `katao_member_group`;


CREATE TABLE `katao_member_group`
(
       `id` INTEGER  NOT NULL AUTO_INCREMENT,
       `katao_member_group_name` VARCHAR(255),
       PRIMARY KEY (`id`)
);

#-----------------------------------------------------------------------------
#-- katao_assoc_member_group
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `katao_assoc_member_group`;


CREATE TABLE `katao_assoc_member_group`
(
       `member_id` INTEGER  NOT NULL,
       `group_id` INTEGER  NOT NULL,
       PRIMARY KEY (`member_id`,`group_id`),
       CONSTRAINT `katao_assoc_member_group_FK_1`
               FOREIGN KEY (`member_id`)
               REFERENCES `katao_member` (`id`)
               ON DELETE CASCADE,
       INDEX `katao_assoc_member_group_FI_2` (`group_id`),
       CONSTRAINT `katao_assoc_member_group_FK_2`
               FOREIGN KEY (`group_id`)
               REFERENCES `katao_member_group` (`id`)
               ON DELETE CASCADE
);

#-----------------------------------------------------------------------------
#-- katao_member_adhesion
#-----------------------------------------------------------------------------

DROP TABLE IF EXISTS `katao_member_adhesion`;


CREATE TABLE `katao_member_adhesion`
(
       `id` INTEGER  NOT NULL AUTO_INCREMENT,
       `katao_user_id` INTEGER  NOT NULL,
       `year` DATE  NOT NULL,
       `amount` FLOAT  NOT NULL,
       `type` INTEGER(2),
       `payment_kind` INTEGER  NOT NULL,
       `check_no` VARCHAR(255),
       PRIMARY KEY (`id`),
       INDEX `katao_member_adhesion_FI_1` (`katao_user_id`),
       CONSTRAINT `katao_member_adhesion_FK_1`
               FOREIGN KEY (`katao_user_id`)
               REFERENCES `katao_user` (`id`)
);

