ylbtech-QQ(腾讯)-群

ylbtech-DatabaseDesgin:ylbtech-QQ(腾讯)-Account-账户模块, Role-角色、权限模块, Message-消息模块, Qzone-QQ空间,Contacts-通讯录-数据库设计

-- =============================================
-- DatabaseName:QQ-QQ
-- Desc: 手机版QQ
-- Model:Account-账户模块, Role-角色、权限模块, Message-消息模块, Qzone-QQ空间,Contacts-通讯录
-- pubdate:09:58 2013-12-06
-- author:Yuanbo
-- http://qzone.qq.com/
-- =============================================

1.A,数据库关系图(Database Diagram)【至于有的模块表多,没有截图数据库关系图,在家在查询分析器创建一下,新建一个数据库关】

Account-账户模块,

Role-角色、权限模块,

Message-消息模块,

Qzone-QQ空间,

这个没有截图。

Contacts-通讯录,

1.B,数据库设计脚本(Database Design Script)

 Account-账户模块, Role-角色、权限模块, Message-消息模块, Qzone-QQ空间,Contacts-通讯录

1.B,Account-账户模块
use master
GO
-- =============================================
-- DatabaseName:QQ-QQ
-- Desc: 手机版QQ
-- Model:Account-账户模块, Role-角色、权限模块, Message-消息模块, Qzone-QQ空间,Contacts-通讯录
-- pubdate:09:58 2013-12-06
-- author:Yuanbo
-- http://qzone.qq.com/
-- =============================================
IF EXISTS (SELECT * 
       FROM   master..sysdatabases 
       WHERE  name = N'qq_wap_qq')
    DROP DATABASE qq_wap_qq
GO

CREATE DATABASE qq_wap_qq
GO
use qq_wap_qq

GO
-- =============================================
-- ylb:1,账户表
-- =============================================
create table account
(
account_id int identity(100000,1) primary key,    --编号【PK】
pwd varchar(20) not null,        --密码
[type] int,        --类型 0:QQ号;1:QQ群号
[enable] bit --状态 0:正常;1:禁用
)

GO
-- =============================================
-- ylb: 1.1,用户基本资料表
-- =============================================
create table Users
(
nickname varchar(200) not null,        --昵称
realname varchar(200) null,        --真实姓名
sex char(1) check(sex in('M','F','N')) default('N'),    --性别M:男;F:女;N:未知
birthday datetime,            --生日

constellation int,    --星座
province varchar(100),        --现居住地-省
city varchar(100),        --现居住地-市
county varchar(100),        --现居住地-县
account_id int references account(account_id)    --QQ账号【FK】
)

GO
-- =============================================
-- ylb:1,分组
-- =============================================
create table [group]
(
group_id uniqueidentifier,    --编号【Guid】
groupname varchar(200),        --组名
account_id int references account(account_id)    --QQ账号【FK】
)

GO
-- =============================================
-- ylb:1,我的好友
-- =============================================
create table friend
(
friend_id int,    --好友的QQ号
account_id int references account(account_id),    --QQ账号【FK】
group_id uniqueidentifier,    --分组编号
pubdate datetime default(getdate())    --添加时间
)

GO
-- =============================================
-- ylb:1,群
-- =============================================
create table self_qun
(
qun_id int,    --好友的QQ号
account_id int references account(account_id),    --QQ账号【FK】
)

GO
-- =============================================
-- ylb:1,群、讨论组
-- =============================================
create table qun
(
qun_id int,    --好友的QQ号
account_id int references account(account_id),    --QQ账号【FK】
role varchar(200),    --角色:群主、管理员、成员
--[type] varchar(200) not null,    --类型,比如:群、讨论组
pubdate datetime default(getdate())    --添加时间
)

GO
-- =============================================
-- ylb:1,讨论组
-- =============================================
create table taolunzu
(
taolunzu_id int,    --好友的QQ号
account_id int references account(account_id),    --QQ账号【FK】
pubdate datetime default(getdate())    --添加时间
)
View Code
1.B,Role-角色、权限模块
use qq_wap_qq

go
-- =============================================
-- ylb:1,角色、权限访问关系设计
-- =============================================
go
-- =============================================
-- 1,角色表【器官|组织】
-- =============================================
create table [role]
(
role_id uniqueidentifier primary key,     --编号【PK】
rolen_ame varchar(20),    --角色名称
role_desc varchar(200),    --角色描述
enable bit    --状态 0:正常;1:禁用
)
go
go
-- =============================================
-- 1,P:账户角色关系表
-- =============================================
create table accountrole
(
account_id int references account(account_id),    --账户-编号【FK】
role_id uniqueidentifier references role(role_id),    --角色-编号【FK】
enable bit    --状态 0:正常;1:禁用
)
go

-- =============================================
-- 1,功能表(事件表)【细胞】
-- =============================================
create table event
(
event_id uniqueidentifier primary key,    --编号【PK】
event_name varchar(20),    --事件名称
event_desc varchar(200),--事件描述
enable bit    --状态 0:正常;1:禁用
)

go
-- =============================================
-- 1,P:角色功能关系表
-- =============================================
create table roleevent
(
role_id uniqueidentifier references role(role_id),
event_id uniqueidentifier references event(event_id),
enable bit    --状态 0:正常;1:禁用
)
View Code
1.B,Message-消息模块
use qq_wap_qq
GO
-- =============================================
-- ylb:1,消息【核心模块】
-- =============================================

GO
-- =============================================
-- ylb:1,消息
-- =============================================
create table message
(
message_id int primary key identity(20000,1),    --编号【PK,ID】
content varchar(400),
pubdate datetime default(getdate()),    --发布时间
send_account_id int references account(account_id),    --发送-QQ账号【FK】
accept_account_id int references account(account_id),    --接受-QQ账号【FK】
status int, --发送状态 0:成功;1:失败
offline_send bit --0:否;1:是。如是“是”,则接受者等登录则发送过去
)
View Code
1.B,Qzone-QQ空间
use qq_wap_qq
GO
-- =============================================
-- ylb:1,QQ空间【核心模块】
-- =============================================

GO
-- =============================================
-- ylb:1,说说、日志、相册、留言
-- =============================================

GO
-- =============================================
-- ylb:1,时间轴(消息|好友动态)
-- =============================================
create table timeline
(
timeline_id int primary key identity(10000,1),    --编号【PK,ID】
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
[type] varchar(200) not null,    --类型,比如:说说、日志、留言、
pubdate datetime default(getdate()),    --发布时间
status bit default(0),    --时候0:未读;1:已读
account_id int references account(account_id)    --QQ账号【FK】
)

GO
-- =============================================
-- ylb: 8, 说说
-- =============================================
create table feeling
(
feeling_id int primary key identity(1,1),    --编号
content varchar(200),                        --内容
pubdate datetime default(getdate()),        --时间
base_id int,                                    --base_id=0:首发;base_id=num:则回复
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
account_id int references account(account_id)    --QQ账号【FK】
)
GO


--ylb:2,日志
GO
-- =============================================
-- ylb: 2.1,日志分类表
-- =============================================
create table blogclass
(
blogclass_id int primary key identity(100,1),    --编号【PK】
class_name varchar(100) not null,        --分类名称
account_id int references account(account_id)    --QQ账号【FK】
)

GO
-- =============================================
-- ylb: 2.2,日志表
-- =============================================
create table article
(
article_id int primary key identity(1,1),    --编号【PK】
title varchar(200) not null,            --标题
content varchar(5000),                    --内容
blogclass_id int references blogclass(blogclass_id),        --分类编号【FK】
pubdate datetime default(getdate()),            --分布日期

read_cnt int default(0),                    --阅读数量
reply_cnt int default(0),                --回复数量
allow_view int default(0),                --显示范围权限 -100:公开;100:好友;1000:私人
draft_flag int default(0),                    --0:发送;1:保存草稿
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
account_id int references account(account_id)    --QQ账号【FK】
)

GO
-- =============================================
-- ylb: 2.3,日志评论表
-- =============================================
create table articlereply
(
articlereply_id int primary key identity(100,1),    --编号【PK】
content varchar(200) not null,            --内容
pubdate datetime default(getdate()),        --回复时间
article_id int references article(article_id), --文章编号[FK]
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
account_id int references account(account_id)    --QQ账号【FK】
)

--ylb:3, 相册
GO
-- ylb: 3.1 相册类别表
-- =============================================
-- ylb: 3.1.1 相册类别表
-- =============================================
create table album
(
album_id int primary key identity(1,1),    --编号【PK】
album_name varchar(100) not null,        --相册名
pubdate datetime default(getdate()),        --创建时间
album_url varchar(100),                        --封面图片
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
account_id int references account(account_id)    --QQ账号【FK】
)

GO
-- =============================================
-- ylb: 3.1.2 相册类别评论表
-- =============================================
create table replyalbum
(
replyalbum_id int primary key identity(100,1),--编号
content varchar(200) not null,            --评论内容
pubdate datetime default(getdate()),        --评论时间
base_id int default(0),                --评论级次 0:发表;其他:回复|跟贴
album_id int references album(album_id),    --相册编号[FK]
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
account_id int references account(account_id)    --QQ账号【FK】
)


-- ylb: 3.2 相册表
GO
-- =============================================
-- ylb: 3.2.1 相册表
-- =============================================
create table photo
(
photo_id int primary key identity(100,1),    --编号【PK】
img_url varchar(100),                --保存地址
img_desc varchar(100),                --描述 [注:3g版不显示]
album_id int references album(album_id),    --相册编号[FK]
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
account_id int references account(account_id)    --QQ账号【FK】
)

GO
-- =============================================
-- ylb: 3.2.2 相册评论表
-- =============================================
create table replyphoto
(
replyphoto_id int primary key identity(100,1),--编号
content varchar(200) not null,            --评论内容
pubdate datetime default(getdate()),        --评论时间
base_id int default(0),                --评论级次 0:发表;其他:回复|跟贴
photo_id int references photo(photo_id),    --照片编号[FK]
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
account_id int references account(account_id)    --QQ账号【FK】
)


GO
-- =============================================
-- ylb: 6, 留言表
-- =============================================
create table note
(
note_id int primary key identity(1,1),    --编号
content varchar(200),                    --内容
pubdate datetime default(getdate()),    --时间
base_id int,                                    --base_id=0:首发;base_id=num:则回复
guid uniqueidentifier,    --Guid全局唯一标示和对应模块的相同【FK】
account_id int references account(account_id)    --QQ账号【FK】
)

GO
-- =============================================
-- ylb: 7, 最近走访
-- =============================================
create table recentvisit
(
recentvisitId int primary key identity(1,1),    --编号
host_account_id int references account(account_id),        --主人编号
visit_account_id int references account(account_id),    --来访者编号
pubdate datetime default(getdate()),    --时间
type int            --类型 0:谁看过我;1:我看过谁;2:被挡访客
)
View Code
1.B,Contacts-通讯录
use qq_wap_qq
go
-- =============================================
-- ylb:1,通讯录
-- =============================================

GO
-- =============================================
-- ylb: 3,联系人组
-- =============================================
create table contactgroup
(
contactgroup_id int primary key identity(10,1),    --编号【PK】
contactgroup_name varchar(100) not null,            --分组名称
account_id int references account(account_id),    --QQ账号【FK】
)

GO
-- =============================================
-- ylb: 3.2,联系人
-- =============================================
create table contact
(
contact_id int primary key identity(100,1),        --编号【PK】
[name] varchar(100) not null,                --姓名
email_pref varchar(100),                                --电子邮箱
tel_cell varchar(100),                --电话|移动电话号
contactgroup_ids varchar(100),        --联系人分组编号【FK】
account_id int references account(account_id),    --QQ账号【FK】
)
GO
View Code
1.C,功能实现代码(Function Implementation Code)
warn 作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/ylbtech/p/3461659.html