Файл: onlinepoisk.wm-scripts.ru/bd.sql
Строк: 35
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone =
"+00:00";
CREATE TABLE IF NOT EXISTS `cache` (
`id` int(11)
NOT NULL AUTO_INCREMENT,
`key` varchar(128) NOT NULL,
`data`
mediumtext,
`expiredAt` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `key` (`key`,`expiredAt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
AUTO_INCREMENT=40789 ;
CREATE TABLE IF NOT EXISTS `pl` (
`id` int(11)
NOT NULL AUTO_INCREMENT,
`userId` int(11) NOT NULL,
`name` varchar(45)
NOT NULL,
`pos` int(11) DEFAULT '666',
`status` tinyint(1) DEFAULT
'0',
PRIMARY KEY (`id`),
KEY `fk_pl_1` (`userId`),
KEY `pos`
(`pos`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
CREATE
TABLE IF NOT EXISTS `pl_track` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`plId` int(11) NOT NULL,
`artist` varchar(32) DEFAULT NULL,
`name`
varchar(32) DEFAULT NULL,
`vkId` varchar(32) DEFAULT NULL,
`lyricsid`
bigint(20) DEFAULT NULL,
`duration` varchar(32) DEFAULT NULL,
`pos`
int(11) DEFAULT '666',
PRIMARY KEY (`id`),
KEY `pl` (`plId`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
CREATE TABLE
IF NOT EXISTS `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`login`
varchar(32) NOT NULL,
`password` varchar(32) DEFAULT NULL,
PRIMARY KEY
(`id`),
KEY `login` (`login`),
KEY `login_pass` (`login`,`password`)
)
ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
CREATE TABLE IF
NOT EXISTS `user_session` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userId` int(11) DEFAULT NULL,
`sessKey` varchar(32) DEFAULT NULL,
`expiredAt` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `sessKey`
(`sessKey`,`expiredAt`),
KEY `userId` (`userId`)
) ENGINE=InnoDB DEFAULT
CHARSET=utf8 AUTO_INCREMENT=8 ;
ALTER TABLE `pl`
ADD CONSTRAINT
`fk_pl_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`) ON DELETE NO
ACTION ON UPDATE NO ACTION;
ALTER TABLE `pl_track`
ADD CONSTRAINT `pl`
FOREIGN KEY (`plId`) REFERENCES `pl` (`id`) ON DELETE CASCADE ON UPDATE
CASCADE;
ALTER TABLE `user_session`
ADD CONSTRAINT `userId` FOREIGN KEY
(`userId`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;