Created
July 16, 2016 12:10
-
-
Save pboethig/ad571d8a216011a28ef22b5c0299cf42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE `blog` /*!40100 DEFAULT CHARACTER SET utf8 */; | |
CREATE TABLE `post` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`content` longtext COLLATE utf8_unicode_ci NOT NULL, | |
`userid` int(11) NOT NULL, | |
`created` datetime NOT NULL, | |
`updated` datetime DEFAULT NULL, | |
PRIMARY KEY (`id`), | |
KEY `userid` (`userid`), | |
CONSTRAINT `post_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
CREATE TABLE `replies` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`userid` int(11) NOT NULL, | |
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`content` longtext COLLATE utf8_unicode_ci NOT NULL, | |
`created` datetime NOT NULL, | |
`updated` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`postid` int(10) DEFAULT NULL, | |
PRIMARY KEY (`id`), | |
KEY `userid` (`userid`), | |
KEY `postid` (`postid`), | |
CONSTRAINT `replies_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | |
CONSTRAINT `replies_ibfk_2` FOREIGN KEY (`postid`) REFERENCES `post` (`id`) ON DELETE CASCADE ON UPDATE CASCADE | |
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
CREATE TABLE `user` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`username` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`email` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`password` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`firstname` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`lastname` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`created` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`updated` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
PRIMARY KEY (`id`), | |
UNIQUE KEY `UNIQ_8D93D649F85E0677` (`username`) | |
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment