什么是一个好主意,以节省"闲谈"在数据库中的数据? [英] What is a good idea to save "Chat" data in database?

查看:87
本文介绍了什么是一个好主意,以节省"闲谈"在数据库中的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个聊天网站。我使用asp.net和SQL Server 2008

I am working on a Chat website. I am using asp.net and SQL Server 2008

这个想法将是相同的像正常的聊天网站。我的问题是,我不知道如何创造一个良好的数据库设计。

The idea will be same like normal chatting websites. My problem is, I do not understand how to create a good database design.

我与SQL Server VB asp.net的良好的知识。

I have good knowledge of vb asp.net with SQL Server.

在我的项目,我创建了一个表中添加新用户 ID,UNAME,uPassoword uDetail

In my project, I created a table for adding new user with ID, uName, uPassoword and uDetail columns.

然后....我创建了一个名为 User_Friends(UNAME,uFriendName)的表

Then.... I created a table named User_Friends (uName , uFriendName).

假设当用户ABC添加新的好友将其保存在该表中的关系的uname =ABC和uFriendName =XYZ,同所有其他用户会做补充有朋友和所有的数据会在一个表( User_Friends )。所有的细节,谁是他的朋友的信息是这个 User_Friends 表。

Suppose when user "abc" add new friend it save the relation uName = "abc" and uFriendName ="xyz" in this table, same all other users will do to add there friends and all that data will go in one table (User_Friends). All detail that who is whose friend information is in this User_Friends table.

我的问题是:


  • 但如果有10000个或更多用户,每个用户添加很多朋友,朋友DB什么。

  • 如果我要保存数据库的每个用户聊天一样。我应该使用一个表的所有用户聊天记录或别的东西。

然后将它是一个缓慢的过程中获得详细信息从一个表或不?

Then WILL IT BE A SLOW PROCESS TO GET DETAIL FROM ONE TABLE OR NOT?

请咨询我如何设计DB或者给我一些有用的链接以获得帮助。

Please advice me how to design DB or give me some useful links for help.

推荐答案

保存聊天数据到数据库空间费时的工作,我会preFER你这样做:

saving chat data into database is a space consuming task, i would prefer you to do it this way:


  1. 用户A聊天与他的地图B ......一旦聊天窗口关闭做它的一个文本文件
    并将其与文件名保存到像年/月/日的文件夹结构用户ID +用户朋友id,例如:AB.txt

  1. user A chats with his friend B... once the chat window is closed make a text file of it and save it into a folder structure like Year/Month/Date with file name as 'userid+user friend id' eg: AB.txt

有关每天保持数据追加到同一个文本文件中。所以在未来,我们将展示在一个文件中,每天完成的所有聊天记录。

For every day keep appending data to the same text file. so in future we will show all chats done in a day in a single file.

添加一个表格的聊天记录与标识,文件名,创建日期时间。检查该文件名在DB已经存在,如果present采取文件和数据追加到它
否则插入具有完全限定的路径一行到数据库,并保存聊天数据到它

Add a table chat history with Id,File Name,Created Date Time. Check if that file name already exists in DB if present take that file and append data to it else insert a row with fully qualified path into DB and save chat data into it

这篇关于什么是一个好主意,以节省"闲谈"在数据库中的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆