web-QQ(腾讯)-EMail-QQMsg(仿QQ短信)-数据库设计

简介:

专题图编号:ylbtechOpenSource

1,功能描述

 仿QQ短信(QQ邮箱里面的功能),登录,短息主界面,发信息,单个话题对话。

2,技术与环境

操作系统:

windows

开发语言:

C#

开发框架:

 

数据库:

SQLServer

开发软件:

Microsoft Visual Studio 2010

开发技术:

 ASP.net

项目组长:

yuanbo

成员:

null

个人主页:

http://www.cnblogs.com/ylbtech/

科研团队:

ylbtech

教研团队:

ylbtech

3,数据库设计
复制代码
-- =============================================
-- ylb;仿QQ短信
-- development time:11:35 2012-04-18
-- =============================================
use master
go
IF EXISTS (SELECT * 
       FROM   master..sysdatabases 
       WHERE  name = N'QQMessage')
    DROP DATABASE QQMessage
GO

CREATE DATABASE QQMessage
GO

use QQMessage
go
-- =============================================
-- ylb;1,Users
-- remark:用户表
-- =============================================
create table Users
(
userId int primary key identity(100,1),    --编号[PK]
nickname varchar(200) not null,        --昵称
userpass varchar(200) not null,        --密码
headImage varchar(200),            --头像地址
username varchar(200),            --备注姓名
flag int default(0) check(flag in(0,1))    --标识,flag=1,说明此用户已注销,0:正常
)

go
-- =============================================
-- ylb;2,Note
-- remark:短信表
-- =============================================
create table Message
(
msgId int primary key identity(200,1),    --编号[PK]
toUserId varchar(200) not null,        --收信人编号[FK]
content varchar(500) not null,        --发新内容
pubdate datetime default(getdate()),    --发送时间
sendUserId int        --发送用户编号[FK]

)
-- =============================================
-- ylb;3,Friend
-- remark:好友表
-- =============================================
create table Friend
(
userId int not null,    --用户编号
friendId int not null    --用户好友编号

)

print '数据创建成功!'

-- =============================================
-- ylb;仿QQ短信
-- development time:11:35 2012-04-18
-- =============================================
use QQMessage

go
--InsertData
insert into Users(nickname,userpass,headImage) values('sunshine','m123','default.jpg')
insert into Users(nickname,userpass,headImage) values('rain','m123','default.jpg')
insert into Users(nickname,userpass,headImage) values('lanchong','m123','default.jpg')
insert into Users(nickname,userpass,headImage) values('sun','m123','default.jpg')

select * from Users


go
--修改备注
update Users set username='袁博' where userId=102
go
--登录
select count(*) from Users where userId=100 and userpass='m123'
go
--删除一组会话
delete Message where toUserId=100 and sendUserId=101 or toUserId=101 and sendUserId=100


go
--1,发送信息
--1,outBox
insert into Message(toUserId,content,sendUserId) values(100,'I is sunshie',101)
--2,inBox
insert into Message(toUserId,content,sendUserId) values(101,'Who are you?',100)

insert into Message(toUserId,content,sendUserId) values(100,'sunshie',101)


go
--2,我的收信列表
--2_1,List
select userId,nickname,headImage,username from Users
where userId in(select sendUserId from Message where toUserId=100) 
or userId in(select toUserId from Message where sendUserId=100)

go
--2_2,附属最近的一条短信
select top 1 msgId,toUserId,content,pubdate,sendUserId from Message 
where toUserId=100 and sendUserId=101 or toUserId=101 and sendUserId=100
order by msgId desc





--最新的回复
select top 1 content from Message where toUserId=101 and sendUserId=100
order by msgId desc

go
select userId,nickname,headImage,username from Users
where userId in(select sendUserId from Message where toUserId=100)

select userId,nickname,headImage,username,content from Users u left join Message m
on u.userId=m.toUserId


go
--3,单机看详细
select * from Users
select * from Message

go
--3_1,获取备注
select nickname from Users where userId=1

go
--3_2,获取列表
select * from Users u left join Message m
on u.userId=m.toUserId
go
--结论
select userId,nickname,headImage,username,msgId,content,pubdate,sendUserId from Users u 
left join Message m on u.userId=m.toUserId
where toUserId=100 and sendUserId=101 or toUserId=101 and sendUserId=100
复制代码
4,功能截图

 4.1,前台

4.1.1  /SignIn.aspx

4.1.2  /Menu.aspx  短息主界面

4.1.3  /Write.aspx  写短消息

4.1.4  /Detail.aspx  单个对话组

 

5,代码分析

 解决方案属性图

5.1,前台

5.1.1  /Handler/SendMsg.ashx

复制代码
<%@ WebHandler Language="C#" Class="SendMsg" %>

using System;
using System.Web;

public class SendMsg : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";

        //发送短信
        int toUserId = Convert.ToInt32(context.Request["toUserId"]);
        int sendUserId = Convert.ToInt32(context.Request["sendUserId"]);

        MessageInfo dal = new MessageInfo()
        {
            ToUserId = toUserId,
            SendUserId = sendUserId,
            Content = context.Server.UrlDecode(context.Request["content"])
        };

        //Call Fun
        int id= MessageOper.Add(dal);
        context.Response.Write(id+"");
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}
复制代码

 5.2,后台

6,示例|讲解案例下载

博客园讲解:  http://ylbtech.cnblogs.com/

百度文库开发文档: http://passport.baidu.com/?business&aid=6&un=ylbtech#7

谷歌开源代码下载: http://code.google.com/p/ylbtechopensource/downloads/list

请单击“ver1.1 QQMessage”


本文转自ylbtech博客园博客,原文链接:http://www.cnblogs.com/ylbtech/archive/2012/09/04/2670359.html,如需转载请自行联系原作者

相关文章
|
25天前
|
缓存 NoSQL 关系型数据库
在Python Web开发过程中:数据库与缓存,MySQL和NoSQL数据库的主要差异是什么?
MySQL是关系型DB,依赖预定义的表格结构,适合结构化数据和复杂查询,但扩展性有限。NoSQL提供灵活的非结构化数据存储(如JSON),无统一查询语言,但能横向扩展,适用于大规模、高并发场景。选择取决于应用需求和扩展策略。
114 1
|
5月前
|
数据库
如何在web.config文件中配置连接Access数据库?
如何在web.config文件中配置连接Access数据库?
34 0
|
5月前
|
SQL 关系型数据库 MySQL
GO web 开发 实战三,数据库预处理
GO web 开发 实战三,数据库预处理
|
5月前
|
关系型数据库 MySQL Go
GO web 开发 实战二,数据库相关
GO web 开发 实战二,数据库相关
|
3月前
|
前端开发 数据库 Python
使用 Python 的 Web 框架(如 Django 或 Flask)来建立后端接口,用于处理用户的请求,从数据库中查找答案并返回给前端界面
【1月更文挑战第13天】使用 Python 的 Web 框架(如 Django 或 Flask)来建立后端接口,用于处理用户的请求,从数据库中查找答案并返回给前端界面
86 7
|
4月前
|
SQL 数据库 开发者
Python Web 开发: 什么是 Django ORM?如何使用它进行数据库操作?
Python Web 开发: 什么是 Django ORM?如何使用它进行数据库操作?
|
1月前
|
NoSQL 关系型数据库 Linux
Star 1.6k!当Web遇上Linux和数据库!一站式管理平台的开源之旅!
Star 1.6k!当Web遇上Linux和数据库!一站式管理平台的开源之旅!
|
2月前
|
SQL 监控 Java
Java Web应用中数据库连接池的配置与优化
Java Web应用中数据库连接池的配置与优化
|
3月前
|
前端开发 JavaScript Java
基于spring+jsp+mysql实现的Java web论坛系统【源码+数据库+指导运行】
基于spring+jsp+mysql实现的Java web论坛系统【源码+数据库+指导运行】
|
4月前
|
关系型数据库 MySQL 数据库
Web 框架 Flask 快速入门(三)数据库-MySQL
数据库 1、数据库的安装与配置 这节用到flask的两个扩展,使用pip安装扩展就行
64 0