ylbtech-DatabaseDesgin:web-3g-(163)網易-博客-數據庫設計 |
1.A,數據庫關系圖 |
1.B,數據庫設計腳本 |
1.B.1,/App_Data/1,3g163EMail.sql

USE MASTER go -- ============================================= -- ylb: 3g版網易郵箱 -- url: http://m.mail.163.com/ -- devloper:ylb,tech -- author: YuanBo -- date: 11:11 2012-07-05 -- ============================================= IF EXISTS (SELECT * FROM master..sysdatabases WHERE name = N'_3g163EMail') DROP DATABASE _3g163EMail GO CREATE DATABASE _3g163EMail GO USE _3g163EMail GO -- ============================================= -- ylb: 1.1郵箱帳戶表 -- ============================================= create table MailUsers ( mailUser varchar(100) primary key, --帳號名稱[PK] pwd varchar(100) not null --密碼 )
1.B.2,/App_Data/2,3g163Blog.sql

USE MASTER go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 11:11 2012-07-05 -- ============================================= IF EXISTS (SELECT * FROM master..sysdatabases WHERE name = N'_3g163Blog') DROP DATABASE _3g163Blog GO CREATE DATABASE _3g163Blog GO USE _3g163Blog GO --ylb:1, 用戶 GO -- ============================================= -- ylb: 1.1,用戶基本資料表 -- ============================================= create table Users ( userId int primary key identity(100,1), --編號【PK】 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), --現居住地-縣 mailUser varchar(100) not null --用戶賬號[FP], 於網易登錄系統MailUser表的mailUser列相關 ) GO -- ============================================= -- ylb: 1.2,博客統計表 -- ============================================= create table BlogStatistics ( blogStatisticsId int primary key identity(100,1),--編號【PK】 todayAccessNo int default(0), --今日訪問量 sunAccessNo int default(0), --總訪問量 integral int default(0), --博客等級 userId int references Users(userId) --積分【FK】 ) --ylb:2,日志 GO -- ============================================= -- ylb: 2.1,日志分類表 -- ============================================= create table BlogClass ( blogClassId int primary key identity(100,1), --編號【PK】 className varchar(100) not null, --分類名稱 userId int references Users(userId) --用戶編號【FK】 ) GO -- ============================================= -- ylb: 2.2,日志表 -- ============================================= --drop table Article create table Article ( articleId int primary key identity(1,1), --編號【PK】 title varchar(200) not null, --標題 content varchar(5000), --內容 blogClassId int references BlogClass(blogClassId), --分類編號【FK】 pubdate datetime default(getdate()), --分布日期 readCnt int default(0), --閱讀數量 replyCnt int default(0), --回復數量 allowView int default(0), --顯示范圍權限 -100:公開;100:好友;1000:私人 draftFlag int default(0), --0:發送;1:保存草稿 userId int references Users(userId) --用戶編號[FK] ) GO -- ============================================= -- ylb: 2.3,日志評論表 -- ============================================= create table ArticleReply ( articleReplyId int primary key identity(100,1), --編號【PK】 content varchar(200) not null, --內容 pubdate datetime default(getdate()), --回復時間 userId int references Users(userId), --回復人,用戶編號【FK】 articleId int references Article(articleId) --文章編號[FK] ) --ylb:3, 相冊 GO -- ylb: 3.1 相冊類別表 -- ============================================= -- ylb: 3.1.1 相冊類別表 -- ============================================= create table Album ( albumId int primary key identity(1,1), --編號【PK】 albumName varchar(100) not null, --相冊名 pubdate datetime default(getdate()), --創建時間 userId int references Users(userId), --用戶編號【PF】 albumUrl varchar(100) --封面圖片 ) GO -- ============================================= -- ylb: 3.1.2 相冊類別評論表 -- ============================================= create table ReplyAlbum ( replyAlbumId int primary key identity(100,1),--編號 content varchar(200) not null, --評論內容 pubdate datetime default(getdate()), --評論時間 baseId int default(0), --評論級次 0:發表;其他:回復|跟貼 albumId int references Album(albumId), --相冊編號[FK] userId int references Users(userId) --用戶編號[FK] ) -- ylb: 3.2 相冊表 GO -- ============================================= -- ylb: 3.2.1 相冊表 -- ============================================= create table Photo ( photoId int primary key identity(100,1), --編號【PK】 imgUrl varchar(100), --保存地址 imgDesc varchar(100), --描述 [注:3g版不顯示] albumId int references Album(albumId), --相冊編號[FK] userId int references Users(userId) --用戶編號[FK] 有爭議 ) GO -- ============================================= -- ylb: 3.2.2 相冊評論表 -- ============================================= create table ReplyPhoto ( replyPhotoId int primary key identity(100,1),--編號 content varchar(200) not null, --評論內容 pubdate datetime default(getdate()), --評論時間 baseId int default(0), --評論級次 0:發表;其他:回復|跟貼 photoId int references Photo(photoId), --照片編號[FK] userId int references Users(userId) --用戶編號[FK] ) GO -- ============================================= -- ylb: 4,博友組表 -- ============================================= create table FriendsGroup ( friendsGroupId int primary key identity(100,1), --編號【PK】 friendsGroupName varchar(100), --組名 userId int references Users(userId) --用戶編號【FK】 ) GO -- ============================================= -- ylb: 4,博友表 -- ============================================= create table Friend ( friendId int references Users(userId), --編號 userId int references Users(userId), --用戶編號 pubdate datetime default(getdate()), --加添時間 friendsGroupId int references FriendsGroup(friendsGroupId) --好友分組【FK】 ) -- ylb: 5,消息 GO -- ============================================= -- ylb: 5, 消息表 -- ============================================= create table Msg ( msgId int primary key identity(100,1), --編號【PK】 inUserId int references Users(userId), --接受用戶編號【FK】 sendUserId int references Users(userId), --發送用戶編號【FK】 content varchar(200), --內容 pubdate datetime default(getdate()) --發送時間 ) GO -- ============================================= -- ylb: 6, 留言表 -- ============================================= create table Note ( noteId int primary key identity(1,1), --編號 content varchar(200), --內容 pubdate datetime default(getdate()), --時間 inUserId int, --主人編號 sendUserid int --發送人編號 ) GO -- ============================================= -- ylb: 7, 通知表 -- ============================================= create table Notice ( noticeId int primary key identity(1,1), --編號 content varchar(200), --內容 pubdate datetime default(getdate()), --時間 remark varchar(200), --備注 inUserId int --主人編號 ) GO -- ============================================= -- ylb: 7, 最近訪客 -- ============================================= create table RecentVisitor ( recentVisitorId int primary key identity(1,1), --編號 hostId int, --主人編號 visitId int, --來訪者編號 pubdate datetime default(getdate()) --時間 ) GO -- ============================================= -- ylb: 7, 最近走訪 -- ============================================= create table RecentVisited ( recentVisitedId int primary key identity(1,1), --編號 hostId int, --主人編號 visitId int, --來訪者編號 pubdate datetime default(getdate()) --時間 ) GO -- ============================================= -- ylb: 7, 最近走訪 -- ============================================= create table RecentVisit ( recentVisitId int primary key identity(1,1), --編號 hostId int, --主人編號 visitId int, --來訪者編號 pubdate datetime default(getdate()), --時間 type varchar(100) --類型 ) GO -- ============================================= -- ylb: 8, 心情隨筆 -- ============================================= create table Feeling ( feelingId int primary key identity(1,1), --編號 content varchar(200), --內容 pubdate datetime default(getdate()), --時間 baseId int, --baseId=0:首發;baseId=num:則恢復 userId int --用戶編號 ) GO -- ============================================= -- ylb: 9, 話題 -- ============================================= create table Topic ( topicId int primary key identity(1,1), --編號[PK] title varchar(100) unique, --標題[U] readCount int default(0), --閱讀次數[D] pubdate datetime default(getdate()) --創建時間[D] ) GO print '網易博客數據創建完成'
1.C,功能實現代碼 |
1.C.1,郵件數據基本查詢
/App_Data/1,3g163EMail/1,MailUsers.sql

use _3g163Email go -- ============================================= -- ylb: 3g版網易郵箱 -- url: http://m.mail.163.com/ -- devloper:ylb,tech -- author: YuanBo -- date: 11:11 2012-07-05 -- ============================================= -- ============================================= -- ylb-menu: 1, 郵箱帳戶表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: 1,用戶登錄 -- ============================================= insert into MailUsers(mailUser,pwd) values('yb@163.com','m123456') GO insert into MailUsers(mailUser,pwd) values('yinghua@163.com','m123456') GO -- ============================================= -- ylb: 1,用戶登錄 -- ============================================= select COUNT(*) from MailUsers where mailUser='yb@163.com' and pwd='m123456'
1.C.2,博客查詢
/App_Data/2,3g163Blog/1,Users.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:45 2012/7/7 -- ============================================= -- ============================================= -- ylb-menu: 1, 用戶表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: 1,用戶登錄 -- ============================================= insert into Users(nickname,realname,sex,birthday,constellation,mailUser) values('sunshine','yb','F','1989-2-23',1,'yb@163.com') GO insert into BlogClass(className,userId) values('默認分類',100) GO insert into Users(nickname,realname,sex,birthday,constellation,mailUser) values('yinghua','dream','F','1989-2-23',1,'yinghua@163.com') GO insert into BlogClass(className,userId) values('默認分類',101) GO -- ============================================= -- ylb: 1,獲取用戶個人資料 -- ============================================= select userId,nickname,realname,sex,birthday,constellation from Users where userId=200 GO -- ============================================= -- ylb: 2,更新用戶個人資料 -- ============================================= update Users set nickname='yb',realname='sunshine',sex='F',birthday='1989-2-23',constellation=1 where userId=200 GO -- ============================================= -- ylb: 3,獲取用戶個人資料[登錄后] -- ============================================= select userId,nickname from Users where mailUser='yb@163.com' GO -- ============================================= -- ylb: 4, 查找好友[模糊查詢],根據昵稱 -- ============================================= select userId,nickname from Users where nickname like '%n%' order by userId asc
/App_Data/2,3g163Blog/2,BlogClass.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 10:35 2012/7/8 -- ============================================= -- ============================================= -- ylb-menu: 2, 日志類別表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: -- ============================================= GO -- ============================================= -- ylb: 1,添加一個新日志分類 -- ============================================= insert into BlogClass(className,userId) values('life',200) GO -- ============================================= -- ylb: 2,查詢所有分類,根據userId;排序,添加着在上 -- ============================================= select blogClassId,className from BlogClass where userId=200 order by blogClassId desc
/App_Data/2,3g163Blog3,Article/.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:37 2012/7/8 -- ============================================= -- ============================================= -- ylb-menu: 1, 文章表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: -- ============================================= GO -- ============================================= -- ylb:1,添加一篇博文,根據userId -- ============================================= --select title,content,blogClassId,allowView,draftFlag,userId from Article --insert into Article(title,content,blogClassId,allowView,draftFlag,userId) values() GO -- ============================================= -- ylb:2,查看所有短目錄博文列表,根據userId,按userId降序排列 -- ============================================= select articleId,title,allowView,draftFlag,readCnt,(select COUNT(*) from ArticleReply where articleId=a.articleId) from Article a where userId=1 order by articleId desc GO -- ============================================= -- ylb:3,統計用戶發表博文的數量,根據userId -- ============================================= select COUNT(*) from Article where userId=100 GO -- ============================================= -- ylb:4,查一篇博文的,根據articleId -- ============================================= select articleId,title,content,blogClassId,allowView,draftFlag,readCnt,(select COUNT(*) from ArticleReply where articleId=a.articleId),userId from Article a where articleId=1 GO -- ============================================= -- ylb:5,更新一篇博文的,根據articleId -- ============================================= select title,content,blogClassId,allowView,draftFlag from Article where articleId=1 GO -- ============================================= -- ylb:6,別人或着匿名查看則,訪問數量在原基數上加一,根據articleId -- date: 22:48 2012/7/10 -- ============================================= update Article set readCnt=readCnt+1 where articleId=1 GO -- ============================================= -- ylb:7,刪除一篇博文,根據articleId -- date: 13:24 2012-07-11 -- ============================================= delete Article where articleId=0 GO -- ============================================= -- ylb:8,該日志的上一篇或者下一篇,根據articleId -- ============================================= --下一篇 select top 1 articleId,title from Article where articleId>2 order by articleId asc --上一篇 select top 1 articleId,title from Article where articleId<2 order by articleId desc GO -- ============================================= -- ylb:9,查看所有短目錄博文列表[Friend],根據userId,按userId降序排列 -- ============================================= select top 10 articleId,title,userId,(select nickname from Users where userId=a.userId)'nickname' from Article a where userId=1 and allowView=-100 order by articleId desc
/App_Data/2,3g163Blog/4,ArticleReply.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:37 2012/7/8 -- ============================================= -- ============================================= -- ylb-menu: 2.3, 日志評論表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: -- ============================================= GO -- ============================================= -- ylb:1,添加一條博文評論 -- date:14:51 2012-07-11 -- ============================================= insert into ArticleReply(content,userId,articleId) values() GO -- ============================================= -- ylb:2,獲取所有博文評論,根據articleId -- ============================================= select top 5 articleReplyId,content,pubdate,userId,articleId,(select nickname from Users where userId=ar.userId) 'nickname' from ArticleReply ar where articleId=0 order by articleReplyId DESC GO -- ============================================= -- ylb:3,刪除一條評論,根據articleReplyId -- ============================================= delete articleReply where articleReplyId=0 GO -- ============================================= -- ylb:4,該篇日志多少評論,根據articleReplyId -- date:9:08 2012/7/12 -- ============================================= select COUNT(*) from ArticleReply where articleId=0
/App_Data/2,3g163Blog/5,Album.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 11:18 2012/7/12 -- ============================================= -- ============================================= -- ylb-menu: 1, 相冊表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: -- ============================================= select * from Album GO -- ============================================= -- ylb: 1,添加一個新相冊 -- date: 11:18 2012/7/12 -- ============================================= insert into Album(albumName,userId) values() select @@IDENTITY GO -- ============================================= -- ylb: 2,查詢所有新相冊,根據userId -- date: 11:18 2012/7/12 -- ============================================= select albumId,albumName,pubdate,userId,albumUrl,(select COUNT(*) from Photo where albumId=p.albumId) 'photoCnt' from Photo p where userId=0 order by albumId desc GO --如果該用戶沒有相冊,則創建默認"我的相冊" GO -- ============================================= -- ylb: 3, 用戶擁有的相冊數量,根據userId [方法位置有異議] -- date: 11:18 2012/7/12 -- ============================================= select COUNT(*) from Album where userId=0 GO -- ============================================= -- ylb: 4,查詢所有新相冊[dropDownList],根據userId -- date: 11:18 2012/7/12 -- ============================================= select albumId,albumName from Album where userId=0 GO -- ============================================= -- ylb: 5,查詢新相冊,根據albumId -- date: 11:18 2012/7/12 -- ============================================= select albumId,albumName from Album where albumId=0 select * from Album
,6
/App_Data/2,3g163Blog/6,Phone.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 23:24 2012/7/12 -- ============================================= -- ============================================= -- ylb-menu: 1, 相冊表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: -- ============================================= GO -- ============================================= -- ylb: 1,上傳一張照片 -- ============================================= select imgUrl,albumId,userId from Photo insert into Photo(imgUrl,albumId,userId) values() select @@IDENTITY GO -- ============================================= -- ylb: 2,添加描述,根據photoId -- ============================================= update Photo set imgDesc='' where photoId=0 GO -- ============================================= -- ylb: 3,查看一張照片,根據photoId -- ============================================= select albumId,imgUrl from Photo where photoId=0 GO -- ============================================= -- ylb: 4,查看一張照片,根據albumId -- ============================================= select photoId,imgUrl,albumId from Photo where albumId=0 order by photoId desc GO -- ============================================= -- ylb: 5,相冊包涵照片的數量,根據albumId -- ============================================= select COUNT(*) from Photo where albumId=0 -- ============================================= -- ylb:6,該照片的上一張或者下一張,根據photoId -- ============================================= --下一篇 select top 1 photoId,imgUrl from Photo where photoId>2 order by photoId asc --上一篇 select top 1photoId,imgUrl from Photo where photoId<2 order by photoId desc GO -- ============================================= -- ylb: 7,刪除一張照片,根據photoId -- ============================================= delete ReplyPhoto where photoId=1 delete Photo where photoId=0
/App_Data/2,3g163Blog/7,RelyAlbum.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 11:18 2012/7/12 -- ============================================= -- ============================================= -- ylb-menu: 1, 相冊評論表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: -- ============================================= GO -- ============================================= -- ylb:1, 添加一條評論 -- ============================================= select content,baseId,albumId,userId from ReplyAlbum --insert into ReplyAlbum(content,baseId,albumId,userId) values() GO -- ============================================= -- ylb:2,查詢所有評論,根據albumId -- ============================================= select replyAlbumId,content,pubdate,baseId,ra.userId,u.nickname from ReplyAlbum ra inner join Users u on ra.userId=u.userId where albumId=0 order by replyAlbumId desc GO -- ============================================= -- ylb:3, 刪除一條評論 -- ============================================= delete ReplyAlbum where replyAlbumId=0
/App_Data/2,3g163Blog/8,ReplyPhoto.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 11:18 2012/7/12 -- ============================================= -- ============================================= -- ylb-menu: 1, 照片評論表的操作與步驟 -- ============================================= select * from ReplyPhoto GO -- ============================================= -- ylb_TestData: -- ============================================= GO -- ============================================= -- ylb:1, 添加一條評論 -- ============================================= select content,baseId,photoId,userId from ReplyPhoto --insert into ReplyPhoto(content,baseId,photoId,userId) values() GO -- ============================================= -- ylb:2,查詢所有評論,根據photoId -- ============================================= select replyPhotoId,content,pubdate,baseId,rp.userId,u.nickname from ReplyPhoto rp inner join Users u on rp.userId=u.userId where photoId=0 order by replyPhotoId desc GO -- ============================================= -- ylb:3, 刪除一條評論 -- ============================================= delete ReplyPhoto where replyPhotoId=0
/App_Data/2,3g163Blog/9,Note.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:45 2012/7/7 -- ============================================= -- ============================================= -- ylb-menu: 7, 留言表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: -- ============================================= select * from Note GO -- ============================================= -- ylb:1, 增加一條留言 -- ============================================= select content,inUserId,sendUserId from Note --insert into Note(content,inUserId,sendUserId) values() GO -- ============================================= -- ylb:2, 查詢所有留言,根據inUserId -- ============================================= select noteId,content,pubdate,inUserId,sendUserId,u.nickname from Note n inner join Users u on n.sendUserId=u.userId where inUserId=0 order by noteId desc GO -- ============================================= -- ylb:3, 刪除一條留言 -- ============================================= delete Note where noteId=0 GO -- ============================================= -- ylb:4, 留言數量,根據inUserId -- ============================================= select COUNT(*) from Note where inUserId=0 GO -- ============================================= -- ylb:5, 查詢留言,根據noteId -- ============================================= select noteId,content,pubdate,inUserId,sendUserId,u.nickname from Note n inner join Users u on n.sendUserId=u.userId where noteId=0 GO -- ============================================= -- ylb:6, 查詢所有留言[Friend],根據inUserId -- sql方法同sql2 -- ============================================= select top 5 noteId,content,pubdate,inUserId,sendUserId,u.nickname from Note n inner join Users u on n.sendUserId=u.userId where inUserId=0 order by noteId desc
/App_Data/2,3g163Blog/10,Notice.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:45 2012/7/7 -- ============================================= -- ============================================= -- ylb-menu: 10, 通知表的操作與步驟 -- ============================================= GO -- ============================================= -- ylb_TestData: -- ============================================= insert into Notice(content,remark,inUserId) values('手機相片嫌導出麻煩?怕意外丟失?『網易雲相冊』提供手機相片無線上傳,安全備份,自動關聯你的網易博客相冊。點擊查看詳情' ,'系統通知',100) GO -- ============================================= -- ylb: 1,[admin]發布通知 [現在還不對] -- ============================================= select content,remark,inUserId from Notice insert into Notice(content,remark,inUserId) values() GO -- ============================================= -- ylb: 2,查看所有通知,根據inUserId -- ============================================= select noticeId,content,pubdate,remark,inUserId from Notice where inUserId=0 GO -- ============================================= -- ylb: 3,刪除一條通知,根據noticeId -- ============================================= delete Notice where noticeId=0 GO -- ============================================= -- ylb: 4,通知數量,根據inUserId -- ============================================= select COUNT(*) from Notice where inUserId=0
,11
/App_Data/2,3g163Blog/11,Feeling.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:45 2012/7/7 -- ============================================= -- ============================================= -- ylb-menu: 11, 心情隨筆表的操作與步驟 -- ============================================= select * from Feeling GO -- ============================================= -- ylb_TestData: -- ============================================= GO -- ============================================= -- ylb: 1, 增加隨筆 -- ============================================= select content,baseId,userId from Feeling insert into Feeling(content,baseId,userId) values() GO -- ============================================= -- ylb: 2, 查詢所有隨筆,根據userId -- ============================================= select feelingId,content,pubdate,baseId,f.userId,u.nickname,(select COUNT(*) from Feeling where baseId=f.feelingId)'replyCnt' from Feeling f inner join Users u on f.userId=u.userId where f.userId=0 and baseId=0 order by feelingId desc GO select feelingId,content,pubdate,baseId,f.userId,u.nickname,(select COUNT(*) from Feeling where baseId=f.feelingId)'replyCnt' from Feeling f inner join Users u on f.userId=u.userId where f.baseId=0 order by feelingId desc GO -- ============================================= -- ylb: 3, 刪除一條隨筆以及回復 -- ============================================= delete Feeling where baseId=0 delete Feeling where feelingId=0 GO -- ============================================= -- ylb: 4, 查隨筆,根據feelingId -- ============================================= select feelingId,content,pubdate from Feeling where feelingId=0 GO -- ============================================= -- ylb: 5, 最新的隨筆,根據userId -- ============================================= select top 1 feelingId,content,pubdate from Feeling where userId=0 order by feelingId desc
/App_Data/2,3g163Blog/12.RecentVisitsql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:45 2012/7/7 -- ============================================= -- ============================================= -- ylb-menu: 11, 最近來訪|最近訪問表的操作與步驟 -- ============================================= select * from RecentVisit GO -- ============================================= -- ylb_TestData: -- ============================================= GO -- ============================================= -- ylb: 1, 新增一條記錄 -- ============================================= select hostId,visitId,type from RecentVisit --insert into RecentVisit(hostId,visitId,type) values() GO -- ============================================= -- ylb: 2, 訪問記錄 -- ============================================= -- 2.1 最近訪問 select recentVisitId,hostId,visitId,pubdate,nickname from RecentVisit rv inner join Users u on rv.visitId=u.userId where type='visitor' and hostId=0 order by recentVisitID desc GO -- 2.2 最近來訪 select recentVisitId,hostId,visitId,pubdate,nickname from RecentVisit rv inner join Users u on rv.visitId=u.userId where type='visited' and hostId=0 order by recentVisitID desc GO -- ============================================= -- ylb: 2, -- =============================================
/App_Data/2,3g163Blog/13,FriendsGroup.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:02 2012-07-26 -- ============================================= -- ============================================= -- ylb-menu: 1, 好友組表的操作與步驟 -- ============================================= select friendsGroupId,friendsGroupName,userId from FriendsGroup GO -- ============================================= -- ylb: 1, 查好友分組,根據userId -- ============================================= select friendsGroupId,friendsGroupName from FriendsGroup where userId=0 GO -- ============================================= -- ylb: 2, 添加一個分組 -- ============================================= select friendsGroupName,userId from FriendsGroup insert into FriendsGroup(friendsGroupName,userId) values('happy',100) GO -- ============================================= -- ylb: 3, 刪除一個好友分組 -- ============================================= delete FriendsGroup where friendsGroupId=0 GO -- ============================================= -- ylb: 1, -- ============================================= --select * from Users
/App_Data/2,3g163Blog/14,Friend.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 15:02 2012-07-26 -- ============================================= -- ============================================= -- ylb-menu: 1, 好友表的操作與步驟 -- ============================================= select * from Friend GO -- ============================================= -- ylb: 1, 查詢好友,根據userId, freindsGroupId -- ============================================= select friendId,pubdate,nickname from Friend f inner join Users u on f.friendId=u.userId where userId=0 GO -- ============================================= -- ylb: 1, -- ============================================= GO -- ============================================= -- ylb: 1, -- ============================================= GO -- ============================================= -- ylb: 1, -- =============================================
/App_Data/2,3g163Blog/15,Topic.sql

use _3g163Blog go -- ============================================= -- ylb: 3g版網易博客 -- url: http://3g.163.com/blog/ -- devloper:ylb,tech -- author: YuanBo -- date: 10:47 2013-01-31 -- ============================================= -- ============================================= -- ylb-menu: 9, 話題的操作與步驟 -- ============================================= --insert into Topic(title) values('') insert into Topic(title) values('High rion') insert into Topic(title) values('military') GO -- ============================================= -- ylb:1, 查看最近話題 -- ============================================= select top 10 topicId,title,readCount from Topic order by topicId desc GO -- ============================================= -- ylb:2, 增加一條 -- ============================================= insert into Topic(title) values('High rion') GO -- ============================================= -- ylb:3, 刪除一條 -- ============================================= delete Topic where topicId=2 GO -- ============================================= -- ylb:4, 話題訪問量加一 -- ============================================= update Topic set readCount=readCount+1 where title=''
![]() |
作者:ylbtech 出處:http://ylbtech.cnblogs.com/ 本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。 |