回复 5# Rain.Stone
这是三个表的数据结构,不同的需求有不同的写法,根据需求,自已写吧。- DROP TABLE IF EXISTS cdb_posts;
- CREATE TABLE cdb_posts (
- pid int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '帖子id',
- fid smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '论坛id',
- tid mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '主题id',
- first tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是首贴',
- author varchar(15) NOT NULL DEFAULT '' COMMENT '作者姓名',
- authorid mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '作者id',
- subject varchar(80) NOT NULL DEFAULT '' COMMENT '标题',
- dateline int(10) unsigned NOT NULL DEFAULT '0' COMMENT '发表时间',
- message mediumtext NOT NULL COMMENT '消息',
- useip varchar(15) NOT NULL DEFAULT '' COMMENT '发帖者IP',
- invisible tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否通过审核',
- anonymous tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否匿名',
- usesig tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启用签名',
- htmlon tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否允许HTML',
- bbcodeoff tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否关闭BBCODE',
- smileyoff tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否关闭表情',
- parseurloff tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否允许粘贴URL',
- attachment tinyint(1) NOT NULL DEFAULT '0' COMMENT '附件',
- rate smallint(6) NOT NULL DEFAULT '0' COMMENT '评分分数',
- ratetimes tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '评分次数',
- status tinyint(1) NOT NULL DEFAULT '0' COMMENT '帖子状态',
- PRIMARY KEY (pid),
- KEY fid (fid),
- KEY authorid (authorid),
- KEY dateline (dateline),
- KEY invisible (invisible),
- KEY displayorder (tid,invisible,dateline),
- KEY first (tid,first)
- ) TYPE=MyISAM COMMENT='帖子表';
- DROP TABLE IF EXISTS cdb_threads;
- CREATE TABLE cdb_threads (
- tid mediumint(8) unsigned NOT NULL auto_increment COMMENT '主题id',
- fid smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '上级论坛',
- iconid smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '图标',
- typeid smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '主题分类id',
- sortid smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '分类信息id',
- readperm tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '阅读权限',
- price smallint(6) NOT NULL DEFAULT '0' COMMENT '价格',
- author char(15) NOT NULL DEFAULT '' COMMENT '会员名',
- authorid mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '会员id',
- subject char(80) NOT NULL DEFAULT '' COMMENT '标题',
- dateline int(10) unsigned NOT NULL DEFAULT '0' COMMENT '发表时间',
- lastpost int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后发表',
- lastposter char(15) NOT NULL DEFAULT '' COMMENT '最后发表人id',
- views int(10) unsigned NOT NULL DEFAULT '0' COMMENT '浏览次数',
- replies mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '回复次数',
- displayorder tinyint(1) NOT NULL DEFAULT '0' COMMENT '显示顺序',
- highlight tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否高亮',
- digest tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否精华',
- rate tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否评分',
- special tinyint(1) NOT NULL DEFAULT '0' COMMENT '特殊主题',
- attachment tinyint(1) NOT NULL DEFAULT '0' COMMENT '附件',
- moderated tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否被管理员改动',
- closed mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '是否关闭',
- itemid mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT 'supe关联id',
- supe_pushstatus tinyint(1) NOT NULL DEFAULT '0' COMMENT 'supe推送状态',
- recommends SMALLINT(6) NOT NULL DEFAULT '0' COMMENT '推荐指数',
- recommend_add SMALLINT(6) NOT NULL DEFAULT '0' COMMENT '支持人数',
- recommend_sub SMALLINT(6) NOT NULL DEFAULT '0' COMMENT '反对人数',
- heats INT(10) unsigned NOT NULL DEFAULT '0' COMMENT '主题热度值',
- PRIMARY KEY (tid),
- KEY digest (digest),
- KEY sortid (sortid),
- KEY displayorder (fid,displayorder,lastpost),
- KEY typeid (fid,typeid,displayorder,lastpost),
- KEY recommends (recommends),
- KEY heats (heats),
- KEY authorid (authorid)
- ) TYPE=MyISAM COMMENT='主题表';
- DROP TABLE IF EXISTS cdb_attachments;
- CREATE TABLE cdb_attachments (
- aid mediumint(8) unsigned NOT NULL AUTO_INCREMENT COMMENT '附件id',
- tid mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '主题id',
- pid int(10) unsigned NOT NULL DEFAULT '0' COMMENT '帖子id',
- width smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '附件宽度',
- dateline int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上传时间',
- readperm tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '阅读权限',
- price smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '附件价格',
- filename char(100) NOT NULL DEFAULT '' COMMENT '原文件名',
- filetype char(50) NOT NULL DEFAULT '' COMMENT '文件类型',
- filesize int(10) unsigned NOT NULL DEFAULT '0' COMMENT '文件大小',
- attachment char(100) NOT NULL DEFAULT '' COMMENT '服务器路径',
- downloads mediumint(8) NOT NULL DEFAULT '0' COMMENT '下载次数',
- isimage tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否图片',
- uid mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '会员id',
- thumb tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否是缩率图',
- remote tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否远程附件',
- PRIMARY KEY (aid),
- KEY tid (tid),
- KEY pid (pid,aid),
- KEY uid (uid),
- KEY dateline (dateline, isimage, downloads)
- ) TYPE=MyISAM COMMENT='附件表';
复制代码 |