views:

70

answers:

2

Like facebook, everyone has messages on the wall. Are all messages stored in only one table? And it will only display messages belong to the user's ID when loading the page? And if it is then there will be so many rows in that table. Is there any limit of the rows in one table?

Or every user has one table only store their own messages?

+1  A: 

Facebook's wall is not stored in MySQL at all as far as I know. They use Cassandra - a NoSQL database from Apache I think, and being NoSQL it uses entirely different philosophy than relative relational databases (like MySQL)

http://en.wikipedia.org/wiki/Apache_Cassandra

They use MySQL for other data though.

Also see similar question (answered) here:

http://stackoverflow.com/questions/1309231/facebook-walls-database-structure

Mchl
First I had heard about Cassandra, great answer :) +1 on the dawn of the new SO day.
Michael Robinson
You mean "relational" not "relative" :P
Bakkal
I obviously do ;)
Mchl
+1  A: 

Or every user has one table only store their own messages?

That's not a good idea, you could end up with lots of tables. Lots of rows are better.

I would simply use a "table" that pairs message_id with user_id with proper indexes to quickly find messages attributed to a specific user.

Is there any limit of the rows in one table?

Quote from MySQL 5.1 Features:

Support for large databases. We use MySQL Server with databases that contain 50 million records. We also know of users who use MySQL Server with 200,000 tables and about 5,000,000,000 rows.

Bakkal
Lots of tables, and dynamic SQL because SQL doesn't allow dynamic FROM or JOIN clauses...
OMG Ponies