2019-10-15 12:44:00 +00:00
|
|
|
CREATE TABLE `vn`.`userPhone` (
|
|
|
|
`id` INT NOT NULL AUTO_INCREMENT,
|
|
|
|
`userFk` INT(10) UNSIGNED NOT NULL,
|
|
|
|
`typeFk` VARCHAR(45) NOT NULL,
|
2019-11-20 10:37:13 +00:00
|
|
|
`phone` VARCHAR(25) NOT NULL,
|
2019-10-15 12:44:00 +00:00
|
|
|
PRIMARY KEY (`id`),
|
2019-11-20 10:37:13 +00:00
|
|
|
UNIQUE INDEX `UserFk_Phone` (`userFk` ASC, `typeFk` ASC, `phone` ASC));
|
2019-10-15 12:44:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
ALTER TABLE `vn`.`userPhone`
|
|
|
|
ADD CONSTRAINT `fgnTypeFk`
|
|
|
|
FOREIGN KEY (typeFk)
|
|
|
|
REFERENCES `vn`.`userPhoneType` (code)
|
|
|
|
ON DELETE RESTRICT
|
|
|
|
ON UPDATE CASCADE;
|
|
|
|
|
|
|
|
ALTER TABLE `vn`.`userPhone`
|
|
|
|
ADD CONSTRAINT `fgnUserFk`
|
|
|
|
FOREIGN KEY (userFk)
|
|
|
|
REFERENCES `account`.`user` (id)
|
|
|
|
ON DELETE CASCADE
|
|
|
|
ON UPDATE CASCADE;
|
|
|
|
|