佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1180|回复: 4

Contact List要怎樣design?

[复制链接]
发表于 28-8-2006 03:41 PM | 显示全部楼层 |阅读模式
我在做一個system,類似friendster的。
每一個member可以add其他members在自己的contact list裏面。

關於這個contact list,我要怎樣design我的database呢?

我暫時考慮到兩种方法,

(方法一)
把所有人的contact放在同一個table裏,
table是這樣的
tblContact(contactID, memberID1, memberID2)

比如説這樣子,memberA的id是 0001,memberB的id是 0002,
那麽,儅memberA add了 memberB進他的contact list時,
就INSERT INTO tblConcact(memberID1, memberID2) VALUES(0001, 0002)
這樣子。

但是如果這樣子的話,我的record會變得很多,
不懂search的時候會不會很慢?


(方法二)
儅每一個member create account的時候,也create一個table給他
這個table是專門收集他的contact list的

比如説memberA add memberB進入contact list的時候,
把memberB的ID insert進去memberA的table;
把memberA的ID insert進去memberB的table;

但是這樣子的話,我會有很多table,不懂database會不會變得file size太大?




那一種方法比較好?
或者你們有什麽更好的database design?
回复

使用道具 举报


ADVERTISEMENT

发表于 29-8-2006 05:08 PM | 显示全部楼层
The first method is the better although you will create alot of record.

For the search issue, maybe you can tunn the server such as index the field, or try to filter it layer by layer.

Example:

select memberID2
From tblConcact
where memberID1 = 0001

select *
From tblConcact
where memberID1 = 0001

the first 1 will have a better performance then the 2nd query. besides that, adding the index to the key field will also increase the performance.
回复

使用道具 举报

发表于 29-8-2006 08:31 PM | 显示全部楼层
当然是方法一...
用方法二的话... 你要怎么 search?
回复

使用道具 举报

 楼主| 发表于 29-8-2006 11:40 PM | 显示全部楼层
原帖由 goatstudio 于 29-8-2006 08:31 PM 发表
当然是方法一...
用方法二的话... 你要怎么 search?


如果是方法一的話
query = "SELECT * FROM tblConcact WHERE memID = ?"
add parameter ? = 那個人的ID

如果是方法二的話
query = "SELECT * FROM " + 那個人的ID
回复

使用道具 举报

发表于 31-8-2006 09:55 AM | 显示全部楼层
原帖由 b4dboyz 于 29-8-2006 11:40 PM 发表


如果是方法一的話
query = "SELECT * FROM tblConcact WHERE memID = ?"
add parameter ? = 那個人的ID

如果是方法二的話
query = "SELECT * FROM " + 那個人的ID



方法二还是难以和其它的 table 做 join... 例如说要算总 contact list 的人数, 或其它比较复杂一点的 report... 就十分艰难了.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 23-9-2024 05:17 PM , Processed in 0.113452 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表