ylbtech-DatabaseDesgin:ylbtech-QQ(騰訊)-羣空間-數據庫設計 |
DatabaseName:QQ-羣空間web
Model:羣相冊、羣共享、羣論壇、羣成員、留言板、公告。6個模塊。數據庫
Type:空間-羣空間、論壇數據庫設計
Url:http://qun.qzone.qq.com/ide
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/ 本文版權歸做者和博客園共有,歡迎轉載,但未經做者贊成必須保留此段聲明,且在文章頁面明顯位置給出原文鏈接,不然保留追究法律責任的權利。 |