02-18-11, 13:34 #1Registered User
- Join Date
- Feb 2011
Unanswered: Database design for social networking website
I am designing a social networking website in JSP for my project. The website working is somewhat similar to orkut. One user can send messages to another user. I have 2 different ideas to save the messages in database.
First, i can create a table named messages in database with columns -sender_id, receiver_id, message, time. It will store message form a particular user to his friend. But in this structure records in table will increase at a very faster rate. e.g. for 100 users having 100 scraps each there will be (100X100=)10000 records in the table, making the table quiet heavy very soon.
Second logic is to create a dedicated table (userid_messages) for every registered user to store his messages. In this logic no of tables in database will increase as the no of users increase.
I am using JSP with IBM DB2 database. Please suggest me which of these 2 is the better way to handle user messages. Please tell me if you have any other better way also.
Thanks in advance.
02-22-11, 18:40 #2Registered User
- Join Date
- May 2003
Without being able to see your complete requirements, it is extremely unlikely that having a dedicated table for each user to store their own messages is the best way to go. DB2 tables can easily have billions of rows, but you are not going to want to deal with a very large number of tables.
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390