ylbtech-DatabaseDesgin:ylbtech-QQ(騰訊)-群空間-數據庫設計 |
DatabaseName:QQ-群空間
Model:群相冊、群共享、群論壇、群成員、留言板、公告。6個模塊。
Type:空間-群空間、論壇
1.A,數據庫關系圖(Database Diagram) |
1.B,數據庫設計腳本(Database Design Script)-第一版 |

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, --編號【PK】 nickname varchar(20) not null, --昵稱 pwd varchar(20) not null, --密碼 [type] int, --類型 0:QQ號;1:QQ群號 [enable] bit --狀態 0:正常;1:禁用 ) -- ============================================= -- ylb: 3.1.1 相冊表 -- ============================================= create table album ( album_id int primary key identity(1,1), --編號【PK】 album_name varchar(30) not null, --相冊名稱 album_desc varchar(80), --相冊描述 pubdate datetime default(getdate()), --創建時間 album_url varchar(100), --封面圖片 account_qq int references account(account_id), --相冊創建者的QQ號 account_qun_id int references account(account_id), --QQ群號 ) GO -- ============================================= -- ylb: 3.2.1 相片表 -- ============================================= create table photo ( photo_id int primary key identity(100,1), --編號【PK】 photo_name varchar(30) not null, --相片名稱 --photo_desc varchar(100), --描述 photo_url varchar(100), --保存地址 pubdate datetime default(getdate()), --上傳時間 album_id int references Album(album_id), --相冊編號[FK] account_qq int references account(account_id), --相冊創建者的QQ號 account_qun_id int references account(account_id), --QQ群號 ) 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()), --評論時間 baseId int default(0), --評論級次 0:發表;其他:回復|跟貼 photo_id int references photo(photo_id), --照片編號[FK] account_qq int references account(account_id), --相冊創建者的QQ號 account_qun_id int references account(account_id), --QQ群號 ) -- ============================================= -- ylb:1,群共享 -- -- ============================================= create table share ( [filename] varchar(20), --文件名 ttl datetime, --有效期【14天】 filesize int, --文件大小【8.65KB】 uploaded_author varchar(20), --上傳者 pubdate datetime default(getdate()), --上傳時間 download_cnt int, --下載次數 account_id int references account(account_id), --上傳者QQ號 account_qun_id int references account(account_id) --群編號 ) go -- ============================================= -- ylb:1,群論壇 -- -- ============================================= create table bbs ( bbs_id int primary key identity(100,1), --編號【PK】 [subject] varchar(20), --主題 content varchar(400), --內容 pubdate datetime default(getdate()), --創建時間 lock_enable bit, --鎖帖|解鎖 stick_enable bit, --0:不頂置;1:頂置 tags_enable bit, --0:;1:精華 lightbox_enable bit, --1:高亮 account_qq int references account(account_id), --相冊創建者的QQ號 account_qun_id int references account(account_id) --QQ群號 ) go -- ============================================= -- ylb:1,回復主題 -- -- ============================================= create table replaybbs ( replaybbs_id int primary key identity(100,1), --編號【PK】 content varchar(400), --內容 pubdate datetime default(getdate()), --創建時間 bbs_id int references bbs(bbs_id), --主題編號 account_qq int references account(account_id), --相冊創建者的QQ號 account_qun_id int references account(account_id) --QQ群號 ) go -- ============================================= -- ylb:1,群成員 -- -- ============================================= create table member ( member_id int primary key identity(100,1),--編號 group_nikename varchar(30), --群昵稱 sex varchar(2), --性別 phone varchar(13), --電話 email varchar(60), --郵箱 remark varchar(200),--備注 pubdate datetime default(getdate()), --創建時間 alow_admin_edit_enable bit, --允許管理員協助修改我的群名片 [role] int, --角色:群主|管理員|成員【power】 account_id int references account(account_id), --上傳者QQ號 account_qun_id int references account(account_id)--群編號 ) go -- ============================================= -- ylb:1,留言板 -- -- ============================================= create table messageboard ( messageboard_id int primary key identity(100,1),--編號 content varchar(30), --內容 pubdate datetime default(getdate()), --創建時間 account_id int references account(account_id), --上傳者QQ號 account_qun_id int references account(account_id)--群編號 ) go -- ============================================= -- ylb:1,公告 -- -- ============================================= create table notice ( notice_id int primary key identity(100,1),--編號 content varchar(30), --內容 pubdate datetime default(getdate()), --創建時間 account_id int references account(account_id), --上傳者QQ號 account_qun_id int references account(account_id)--群編號 ) go -- ============================================= -- ylb:1,標簽【公共】 -- -- ============================================= create table tag ( tag_id uniqueidentifier, --guid tag_name varchar(30), --標簽名稱 pubdate datetime default(getdate()) --創建時間 ) go print 'QQ 群空間數據創建成功!'
1.C,數據庫設計腳本(Database Design Script)-第二版 |
![]() |
作者:ylbtech 出處:http://ylbtech.cnblogs.com/ 本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。 |