|
Hello, I would work with this model: -- ----------------------------------------------------- -- Table `mydb`.`user` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`user` ( `id_user` INT NOT NULL AUTO_INCREMENT, `login` VARCHAR(16) NOT NULL, `password` VARCHAR(200) NOT NULL, `name` VARCHAR(100) NOT NULL, `email` VARCHAR(100) NOT NULL, `telephone` VARCHAR(20) NOT NULL, PRIMARY KEY (`id_user`), UNIQUE INDEX `login_UNIQUE` (`login` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`config_event` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`config_event` ( `id_config_event` INT NOT NULL AUTO_INCREMENT, `event_code` VARCHAR(15) NOT NULL, `event_name` VARCHAR(100) NULL, PRIMARY KEY (`id_config_event`), UNIQUE INDEX `event_code_UNIQUE` (`event_code` ASC), UNIQUE INDEX `event_name_UNIQUE` (`event_name` ASC)) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`config_notification` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`config_notification` ( `id_config_notification` INT NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL, `config_event_id` INT NOT NULL, `on_screen` VARCHAR(1) NULL DEFAULT '0', `sms` VARCHAR(1) NULL DEFAULT '0', `email` VARCHAR(1) NULL DEFAULT '0', PRIMARY KEY (`id_config_notification`), INDEX `fk_config_notification_user_idx` (`user_id` ASC), INDEX `fk_config_notification_config_event1_idx` (`config_event_id` ASC), CONSTRAINT `fk_config_notification_user` FOREIGN KEY (`user_id`) REFERENCES `mydb`.`user` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `fk_config_notification_config_event1` FOREIGN KEY (`config_event_id`) REFERENCES `mydb`.`config_event` (`id_config_event`) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; Greetings, fernando
|