another update of the schema for the zotero_www database.

introduces references between tables
master
Patrick Höhn 2014-10-29 19:12:34 +01:00
parent b6bbde73a2
commit 1440f927e8
1 changed files with 16 additions and 9 deletions

25
www.sql
View File

@ -24,14 +24,16 @@ CREATE TABLE `sessions` (
`id` int(10) unsigned NOT NULL, `id` int(10) unsigned NOT NULL,
`modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`lifetime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `lifetime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
KEY (`userID`), PRIMARY KEY (`userID`, `id`),
KEY (`id`) FOREIGN KEY (`userID`) REFERENCES `users` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users_email` ( CREATE TABLE `users_email` (
`userID` mediumint unsigned NOT NULL, `userID` mediumint unsigned NOT NULL,
`email` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `email` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
PRIMARY KEY (`userID`) PRIMARY KEY (`userID`),
UNIQUE KEY (`email`),
FOREIGN KEY (`userID`) REFERENCES `users` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `storage_institutions` ( CREATE TABLE `storage_institutions` (
@ -44,31 +46,36 @@ PRIMARY KEY (`institutionID`)
CREATE TABLE `storage_institution_email` ( CREATE TABLE `storage_institution_email` (
`email` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, `email` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`institutionID` int(10) unsigned NOT NULL, `institutionID` int(10) unsigned NOT NULL,
PRIMARY KEY (`email`) PRIMARY KEY (`institutionID`),
FOREIGN KEY (`institutionID`) REFERENCES `storage_institutions` (`institutionID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users` ( CREATE TABLE `users` (
`userID` mediumint unsigned auto_increment NOT NULL, `userID` mediumint unsigned auto_increment NOT NULL,
`username` varchar(40) NOT NULL, `username` varchar(40) NOT NULL,
`password` char(40) NULL, `password` char(40) NULL,
UNIQUE KEY (`username`), PRIMARY KEY (`username`, `userID`),
UNIQUE KEY (`userID`) UNIQUE KEY `username` (`username`),
UNIQUE KEY `userID` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `users_meta` ( CREATE TABLE `users_meta` (
`userID` mediumint unsigned NOT NULL, `userID` mediumint unsigned NOT NULL,
`metaKey` enum('profile_realname', 'publishLibrary', 'publishNotes') NOT NULL, `metaKey` enum('profile_realname', 'publishLibrary', 'publishNotes') NOT NULL,
`metaValue` varchar(255) NOT NULL `metaValue` varchar(255) NOT NULL,
FOREIGN KEY (`userID`) REFERENCES `users` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `LUM_User` ( CREATE TABLE `LUM_User` (
`UserID` int(10) unsigned NOT NULL, `UserID` int(10) unsigned NOT NULL,
`RoleID` int(10) unsigned NOT NULL, `RoleID` int(10) unsigned NOT NULL,
PRIMARY KEY (`UserID`) PRIMARY KEY (`UserID`, `RoleID`),
FOREIGN KEY (`RoleID`) REFERENCES `LUM_Role` (`RoleID`),
FOREIGN KEY (`UserID`) REFERENCES `users` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `LUM_Role` ( CREATE TABLE `LUM_Role` (
`RoleID` int(10) unsigned NOT NULL, `RoleID` int(10) unsigned NOT NULL,
`Name' enum('Deleted','Invalid','Valid') NOT NULL, `Name` enum('Deleted','Invalid','Valid') NOT NULL,
PRIMARY KEY (`RoleID`) PRIMARY KEY (`RoleID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;