Skip to content

Instantly share code, notes, and snippets.

@ybm
Last active December 16, 2015 02:09
Show Gist options
  • Save ybm/5359940 to your computer and use it in GitHub Desktop.
Save ybm/5359940 to your computer and use it in GitHub Desktop.
程序员问答网站的数据库安装文件
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL auto_increment,
`password` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`description` text,
`website` text,
`points` int(11) NOT NULL default '0',
`moderator` int(10) unsigned NOT NULL,
`created` datetime NOT NULL,
`lastactivity` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `questions`
--
DROP TABLE IF EXISTS `questions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `questions` (
`id` int(10) unsigned NOT NULL auto_increment,
`title` text NOT NULL,
`description` text NOT NULL,
`created` timestamp NOT NULL default '0000-00-00 00:00:00',
`updated` timestamp NOT NULL default '0000-00-00 00:00:00',
`link` text NOT NULL,
`userid` int(10) unsigned NOT NULL,
`linkcache` longtext NOT NULL,
`votes` int(11) NOT NULL default '0',
`accepted` int(10) unsigned NOT NULL default '0',
`answers` int(10) unsigned NOT NULL default '0',
`kb` int(10) unsigned NOT NULL default '0',
`slug` text NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userid`) REFERENCES `users` (`id`),
FULLTEXT KEY `title` (`title`,`description`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `questions_votes`
--
DROP TABLE IF EXISTS `questions_votes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `questions_votes` (
`id` int(10) unsigned NOT NULL auto_increment,
`questionid` int(10) unsigned NOT NULL,
`userid` int(10) unsigned NOT NULL,
`vote` int(11) NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userid`) REFERENCES `users` (`id`),
FOREIGN KEY (`questionid`) REFERENCES `questions` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `answers`
--
DROP TABLE IF EXISTS `answers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `answers` (
`id` int(10) unsigned NOT NULL auto_increment,
`questionid` int(10) unsigned NOT NULL,
`description` text NOT NULL,
`created` timestamp NOT NULL default '0000-00-00 00:00:00',
`updated` timestamp NOT NULL default '0000-00-00 00:00:00',
`userid` int(10) unsigned NOT NULL,
`accepted` int(10) unsigned NOT NULL,
`votes` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
FOREIGN KEY (`userid`) REFERENCES `users` (`id`),
FOREIGN KEY (`questionid`) REFERENCES `questions` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `answers_votes`
--
DROP TABLE IF EXISTS `answers_votes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `answers_votes` (
`id` int(10) unsigned NOT NULL auto_increment,
`answerid` int(10) unsigned NOT NULL,
`userid` int(10) unsigned NOT NULL,
`vote` int(11) NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userid`) REFERENCES `users` (`id`),
FOREIGN KEY (`answerid`) REFERENCES `answers` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `comments`
--
DROP TABLE IF EXISTS `comments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comments` (
`id` int(10) unsigned NOT NULL auto_increment,
`type` int(10) unsigned NOT NULL,
`comment` text NOT NULL,
`votes` int(10) unsigned NOT NULL default '0',
`created` timestamp NOT NULL default '0000-00-00 00:00:00',
`userid` int(10) unsigned NOT NULL,
`typeid` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userid`) REFERENCES `users` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `comments_votes`
--
DROP TABLE IF EXISTS `comments_votes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `comments_votes` (
`id` int(10) unsigned NOT NULL auto_increment,
`commentid` int(10) unsigned NOT NULL,
`userid` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userid`) REFERENCES `users` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `favorites`
--
DROP TABLE IF EXISTS `favorites`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `favorites` (
`id` int(10) unsigned NOT NULL auto_increment,
`questionid` int(10) unsigned NOT NULL,
`userid` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userid`) REFERENCES `users` (`id`),
FOREIGN KEY (`questionid`) REFERENCES `questions` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tags`
--
DROP TABLE IF EXISTS `tags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tags` (
`id` int(10) unsigned NOT NULL auto_increment,
`tag` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `tags_questions`
--
DROP TABLE IF EXISTS `tags_questions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `tags_questions` (
`id` int(10) unsigned NOT NULL auto_increment,
`tagid` int(10) unsigned NOT NULL,
`questionid` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`tagid`) REFERENCES `tags` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `activities`
--
DROP TABLE IF EXISTS `activities`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `activities` (
`id` int(10) unsigned NOT NULL auto_increment,
`userid` int(10) unsigned NOT NULL,
`activity` varchar(255) NOT NULL default '',
`points` int(11) NOT NULL,
`created` datetime NOT NULL,
`activityid` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`userid`) REFERENCES `users` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment