1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| CREATE TABLE US_user(
US_ident INT UNSIGNED AUTO_INCREMENT,
US_sesa INT,
US_firstname VARCHAR(50),
US_lastname VARCHAR(50),
PRIMARY KEY(US_ident),
UNIQUE(US_sesa)
);
CREATE TABLE USL_user_license(
US_ident INT UNSIGNED,
US_ident_manager INT UNSIGNED,
COU_ident INT UNSIGNED,
LO_ident INT UNSIGNED,
CO_ident INT UNSIGNED NOT NULL,
PRIMARY KEY(US_ident),
FOREIGN KEY(US_ident) REFERENCES US_user(US_ident),
FOREIGN KEY(US_ident_manager) REFERENCES USL_user_license(US_ident),
FOREIGN KEY(COU_ident, LO_ident) REFERENCES LO_location(COU_ident, LO_ident),
FOREIGN KEY(CO_ident) REFERENCES CO_company(CO_ident)
);
CREATE TABLE LI_license(
LI_ident INT UNSIGNED AUTO_INCREMENT,
LI_activate_date DATE NOT NULL,
LI_deactivate_date DATE,
AP_ident INT UNSIGNED NOT NULL,
US_ident INT UNSIGNED NOT NULL,
PRIMARY KEY(LI_ident),
FOREIGN KEY(AP_ident) REFERENCES AP_application(AP_ident),
FOREIGN KEY(US_ident) REFERENCES USL_user_license(US_ident)
); |
Partager