use master
go
-- =============================================
-- DatabaseName:QQ-群空間
-- pubdate:16:50 2013-09-26
-- author:Yuanbo
-- http://qun.qzone.qq.com/
-- =============================================
IF EXISTS (SELECT *
FROM master..sysdatabases
WHERE name = N'qq_qun')
DROP DATABASE qq_qun
GO
CREATE DATABASE qq_qun
GO
use qq_qun
go
-- =============================================
-- ylb:1,賬戶表
--
-- =============================================
create table account
(
account_id int identity(100000,1) primary key, --編號(hào)【PK】
nickname varchar(20) not null, --昵稱
pwd varchar(20) not null, --密碼
[type] int, --類型 0:QQ號(hào);1:QQ群號(hào)
[enable] bit --狀態(tài) 0:正常;1:禁用
)
-- =============================================
-- ylb: 3.1.1 相冊(cè)表
-- =============================================
create table album
(
album_id int primary key identity(1,1), --編號(hào)【PK】
album_name varchar(30) not null, --相冊(cè)名稱
album_desc varchar(80), --相冊(cè)描述
pubdate datetime default(getdate()), --創(chuàng)建時(shí)間
album_url varchar(100), --封面圖片
account_qq int references account(account_id), --相冊(cè)創(chuàng)建者的QQ號(hào)
account_qun_id int references account(account_id), --QQ群號(hào)
)
GO
-- =============================================
-- ylb: 3.2.1 相片表
-- =============================================
create table photo
(
photo_id int primary key identity(100,1), --編號(hào)【PK】
photo_name varchar(30) not null, --相片名稱
--photo_desc varchar(100), --描述
photo_url varchar(100), --保存地址
pubdate datetime default(getdate()), --上傳時(shí)間
album_id int references Album(album_id), --相冊(cè)編號(hào)[FK]
account_qq int references account(account_id), --相冊(cè)創(chuàng)建者的QQ號(hào)
account_qun_id int references account(account_id), --QQ群號(hào)
)
GO
-- =============================================
-- ylb: 3.2.2 相片評(píng)論表
-- =============================================
create table replyphoto
(
replyphoto_id int primary key identity(100,1),--編號(hào)
content varchar(200) not null, --評(píng)論內(nèi)容
pubdate datetime default(getdate()), --評(píng)論時(shí)間
baseId int default(0), --評(píng)論級(jí)次 0:發(fā)表;其他:回復(fù)|跟貼
photo_id int references photo(photo_id), --照片編號(hào)[FK]
account_qq int references account(account_id), --相冊(cè)創(chuàng)建者的QQ號(hào)
account_qun_id int references account(account_id), --QQ群號(hào)
)
-- =============================================
-- ylb:1,群共享
--
-- =============================================
create table share
(
[filename] varchar(20), --文件名
ttl datetime, --有效期【14天】
filesize int, --文件大小【8.65KB】
uploaded_author varchar(20), --上傳者
pubdate datetime default(getdate()), --上傳時(shí)間
download_cnt int, --下載次數(shù)
account_id int references account(account_id), --上傳者QQ號(hào)
account_qun_id int references account(account_id) --群編號(hào)
)
go
-- =============================================
-- ylb:1,群論壇
--
-- =============================================
create table bbs
(
bbs_id int primary key identity(100,1), --編號(hào)【PK】
[subject] varchar(20), --主題
content varchar(400), --內(nèi)容
pubdate datetime default(getdate()), --創(chuàng)建時(shí)間
lock_enable bit, --鎖帖|解鎖
stick_enable bit, --0:不頂置;1:頂置
tags_enable bit, --0:;1:精華
lightbox_enable bit, --1:高亮
account_qq int references account(account_id), --相冊(cè)創(chuàng)建者的QQ號(hào)
account_qun_id int references account(account_id) --QQ群號(hào)
)
go
-- =============================================
-- ylb:1,回復(fù)主題
--
-- =============================================
create table replaybbs
(
replaybbs_id int primary key identity(100,1), --編號(hào)【PK】
content varchar(400), --內(nèi)容
pubdate datetime default(getdate()), --創(chuàng)建時(shí)間
bbs_id int references bbs(bbs_id), --主題編號(hào)
account_qq int references account(account_id), --相冊(cè)創(chuàng)建者的QQ號(hào)
account_qun_id int references account(account_id) --QQ群號(hào)
)
go
-- =============================================
-- ylb:1,群成員
--
-- =============================================
create table member
(
member_id int primary key identity(100,1),--編號(hào)
group_nikename varchar(30), --群昵稱
sex varchar(2), --性別
phone varchar(13), --電話
email varchar(60), --郵箱
remark varchar(200),--備注
pubdate datetime default(getdate()), --創(chuàng)建時(shí)間
alow_admin_edit_enable bit, --允許管理員協(xié)助修改我的群名片
[role] int, --角色:群主|管理員|成員【power】
account_id int references account(account_id), --上傳者QQ號(hào)
account_qun_id int references account(account_id)--群編號(hào)
)
go
-- =============================================
-- ylb:1,留言板
--
-- =============================================
create table messageboard
(
messageboard_id int primary key identity(100,1),--編號(hào)
content varchar(30), --內(nèi)容
pubdate datetime default(getdate()), --創(chuàng)建時(shí)間
account_id int references account(account_id), --上傳者QQ號(hào)
account_qun_id int references account(account_id)--群編號(hào)
)
go
-- =============================================
-- ylb:1,公告
--
-- =============================================
create table notice
(
notice_id int primary key identity(100,1),--編號(hào)
content varchar(30), --內(nèi)容
pubdate datetime default(getdate()), --創(chuàng)建時(shí)間
account_id int references account(account_id), --上傳者QQ號(hào)
account_qun_id int references account(account_id)--群編號(hào)
)
go
-- =============================================
-- ylb:1,標(biāo)簽【公共】
--
-- =============================================
create table tag
(
tag_id uniqueidentifier, --guid
tag_name varchar(30), --標(biāo)簽名稱
pubdate datetime default(getdate()) --創(chuàng)建時(shí)間
)
go
print 'QQ 群空間數(shù)據(jù)創(chuàng)建成功!'