Модератор: Модераторы
ALTER TABLE TB_PROV
ADD CONSTRAINT FK_TB_PROV FOREIGN KEY (TB_DOC_ID) REFERENCES TB_DOC (TB_DOC_ID)
ON DELETE CASCADE ON UPDATE CASCADE
CREATE TABLE blanki.lica(
id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
fam VARCHAR(30) NOT NULL,
imya VARCHAR(30) NOT NULL,
otch VARCHAR(30) DEFAULT NULL,
dr DATE NOT NULL,
s_pol_id TINYINT(4) UNSIGNED NOT NULL,
mr VARCHAR(255) NOT NULL,
s_reg_roj_id SMALLINT(6) UNSIGNED DEFAULT NULL,
nas_punkti_id INT(11) UNSIGNED DEFAULT NULL COMMENT 'Населенный пункт рождения',
s_strani_id SMALLINT(6) UNSIGNED NOT NULL COMMENT 'Гражданство',
s_nacii_id SMALLINT(6) UNSIGNED DEFAULT NULL,
inn BIGINT(20) UNSIGNED DEFAULT NULL,
s_obrazovanii_id TINYINT(4) UNSIGNED DEFAULT NULL,
d_smerti DATE DEFAULT NULL,
when_vvod DATETIME NOT NULL,
when_izm DATETIME NOT NULL,
who_vvod INT(11) UNSIGNED NOT NULL,
who_izm INT(11) UNSIGNED NOT NULL,
PRIMARY KEY (id),
UNIQUE INDEX dr (dr),
UNIQUE INDEX fam (fam),
INDEX FK_lica_nas_punkti_id (nas_punkti_id),
INDEX FK_lica_s_nacii_id (s_nacii_id),
INDEX FK_lica_s_obrazovanii_id (s_obrazovanii_id),
INDEX FK_lica_s_pol_id (s_pol_id),
INDEX FK_lica_s_reg_roj_id (s_reg_roj_id),
INDEX FK_lica_s_strani_id (s_strani_id),
UNIQUE INDEX imya (imya),
UNIQUE INDEX mr (mr),
UNIQUE INDEX otch (otch),
CONSTRAINT FK_lica_nas_punkti_id FOREIGN KEY (nas_punkti_id)
REFERENCES blanki.nas_punkti (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FK_lica_s_nacii_id FOREIGN KEY (s_nacii_id)
REFERENCES blanki.s_nacii (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FK_lica_s_obrazovanii_id FOREIGN KEY (s_obrazovanii_id)
REFERENCES blanki.s_obrazovanii (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FK_lica_s_pol_id FOREIGN KEY (s_pol_id)
REFERENCES blanki.s_pol (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FK_lica_s_reg_roj_id FOREIGN KEY (s_reg_roj_id)
REFERENCES blanki.s_reg_roj (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FK_lica_s_strani_id FOREIGN KEY (s_strani_id)
REFERENCES blanki.s_strani (id) ON DELETE CASCADE ON UPDATE CASCADE
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 6