· 8 years ago · Aug 27, 2018, 02:38 PM
1CREATE TABLE IF NOT EXISTS USERS (
2 USRID INT(32) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Unique ID for each user/company',
3 USRUSERNAME VARCHAR(256) NOT NULL COMMENT 'Username of user/company',
4 USRPASSWORD VARCHAR(256) NOT NULL COMMENT 'Password of user/company',
5 USRACTIVE BOOLEAN NOT NULL DEFAULT 1 COMMENT 'TRUE if this user is active',
6 USRFOOTNOTE LONGTEXT COMMENT 'Footnotes for user',
7 USRADMIN INT(32) UNSIGNED NOT NULL COMMENT 'Id for user role, secondary key for ADMIN details, USER is admin if id is not set to null',
8 USRCOMPANY INT(32) UNSIGNED NOT NULL COMMENT 'Id for user role, secondary key for ADMIN details, USER is company if id is not set to null',
9 USROPERATIVE INT(32) UNSIGNED NOT NULL COMMENT 'Id for user role, secondary key for ADMIN details, USER is operative if id is not set to null',
10 USRDATCRE DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP() COMMENT 'Creation date',
11 USRDATMOD DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP() COMMENT 'Modification date',
12 PRIMARY KEY (USRID),
13 FOREIGN KEY (USRADMIN) REFERENCES ADMINS (ADMID),
14 FOREIGN KEY (USRCOMPANY) REFERENCES COMPANIES (CMPID),
15 FOREIGN KEY (USROPERATIVE) REFERENCES OPERATIVES (OPRID)
16) COMMENT = 'Users and their core info';