开发者

Facebook-wall like MySQL Structure problem

I don’t want any code just a how-to answer.

I’m trying to add a facebook-wall-like feature to a webapp (not commercial, only experimental).

The first thing I thought about was to store something like “1/2011-10-10/texthere,2/2011-10-10/texthere” where 1 would be the id & 2011-10-10 the date. Then I would explode it in php and have an array. (Then search for each id in the users 开发者_运维百科table etc…)

But this has some problems. One would be if I have too many posts, it will be extremely heavy to a webpage and very difficult to limit results (without talking about character restriction for the array’s sake).

So I thought about two other solutions that have the pros and cons for me.

  • Use one table with 4 columns: Poster id, Receiver id, Message, Date Posted

  • One table for each user (desperate solution :))

So, should I direclty go for my first other solution or there is a better one?

Adv thanks


One table per user is a bad idea. Storing different values in different columns is what databases are made for. So it's probably a much better idea! ;-)


The solution to your problem would be a standard Database Table.

Use a table with columns

  • PosterId
  • Wall/RecieverId
  • Message
  • Date Posted

This would be a standard database structure. Use the mysql PDO functions to access your data and place in a php array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜