回复:[iMySQLer] Re: 如何设计这个数据库?

3 views
Skip to first unread message

寻找树林

unread,
Apr 14, 2010, 5:17:28 AM4/14/10
to mysqler
 
如果按照分表的思路,可能其他事件还是要继续分表,这样肯定不合吧
如果是我,那就把history_logs设置为
user_id  friend_id  event_id  date_event
 
如果需要其他字段,再增加一个扩展关联表记录number及其他事件的字段
 
------------------ 原始邮件 ------------------
发件人: "sky.jian"<sky...@gmail.com>;
发送时间: 2010年4月14日(星期三) 下午4:17
收件人: "MySQLer"<mys...@googlegroups.com>;
主题: [iMySQLer] Re: 如何设计这个数据库?
 
如果是我,倾向选择单个表来存放,仅仅冗余一个数字字段,而且如果是空,根本 就不会存放数据,1000w而已,不会浪费多少存储空间。但是带来的收益
却是非常 的明显:无论从维护角度还是开发实现角度来说,都大大简化。

On Apr 14, 3:22 pm, coler99 <colerc...@gmail.com> wrote:
> 事情经过
>
> 一位帅哥(id为1)送了999朵玫瑰花给一位美女(id为2)
>
> 数据记录在history_logs1表中
> history_logs1表如下
>
> user_id  friend_id  event_id  date_event      number
> 2     1     10     2010-02-14 10:37:21  999
>
> event_id=10表示送玫瑰花
>
> 这位帅哥又邀请这位美女一起去看电影
>
> 数据记录在history_logs2表中
> history_logs2表如下
>
> user_id  friend_id  event_id  date_event
> 2     1     11     2010-02-14 20:30:05
>
> event_id=11表示邀请您一起去看电影
>
> 美女来了以后,系统要将帅哥的两条消息按照时间排序以下面的形式展现给美女
>
> [2010-02-14 10:37:21]您的好友[帅哥]送给您[999]朵玫瑰花
> [2010-02-14 20:30:05]您的好友[帅哥]邀请您一起去看电影
>
> []中的数据从数据库中读取,其他描述性文字都是预先根据event_id设定好的
>
> 1,请问SQL语句应该怎么写?
> 2,另一种设计方案是将所有消息都储存在history_logs1表中,但是类似邀请去看电影的消息就会有number这个字段是冗余的,这个表储存
> 着1000W条以上的记录
> 3,这样设计数据库是否合理?如果有好的方案,请指教

--
MySQLer 邮件组
要发布讨论请发 Mail 至 邮件组邮件地址:mys...@googlegroups.com
要退订次邮件组请发 Email 至 mysqler+u...@googlegroups.com
要了解更多的信息,请访问:http://groups.google.com/group/mysqler?hl=en

线上讨论组:http://www.iMySQLer.com
Message has been deleted

nathan wu

unread,
Apr 14, 2010, 9:23:28 AM4/14/10
to mys...@googlegroups.com
个人认为
如果history_log1中的number如果占据很大的话,一张表就够了

2010/4/14 nathan wu <cunh...@gmail.com>:
> base_table
> id, user_id, friend_id, event_id
> 1, 2, 1, 10
> 2, 2, 1, 11
>
> history_log1
> ptr_id number
> 1, 999
> history_log2
> ptr_id
> 2,
>
> 2010/4/14 Nick King <nick.kin...@gmail.com>:
>> 访问量是多少?另外像Number这种扩展需求有多少?

> --
> Nathan.wu
> Cel: +86-136-0517-7121
> Man proposes, God disposes.
>

--
Nathan.wu
Cel: +86-136-0517-7121
Man proposes, God disposes.

nathan wu

unread,
Apr 14, 2010, 9:21:09 AM4/14/10
to mys...@googlegroups.com
base_table
id, user_id, friend_id, event_id
1, 2, 1, 10
2, 2, 1, 11

history_log1
ptr_id number
1, 999
history_log2
ptr_id
2,

2010/4/14 Nick King <nick.kin...@gmail.com>:
> 访问量是多少?另外像Number这种扩展需求有多少?
>
> 在 2010年4月14日 下午5:17,寻找树林 <searc...@gmail.com>写道:
>>
>>

--

Zhao Jiajia

unread,
Apr 15, 2010, 2:14:37 AM4/15/10
to mys...@googlegroups.com
我也觉得放在一个表中比较合适,1000W的数据量真的没多少~~空间换时间!~~

2010/4/14 nathan wu <cunh...@gmail.com>
To unsubscribe, reply using "remove me" as the subject.
Reply all
Reply to author
Forward
0 new messages