Dom
Dom

Reputation: 1028

creating a database for a photo gallery with comments

I am creating a social network and want to have a similar photo gallery to that of facebook. Im guessing I need to use AJAX but I would like to have a comments section for each photo. I was just wondering what the best way would be to design a database around this. Do I just make a table of comments? Would I run into performance issues because Im sure each user would have more than one photo, so the contents tables will get pretty large. Supposing I had 10 million users and each had a 100 photos that with two comments each that would be 2 billion entries and that is only 10 million users, what would happen if that number grew. This would greatly slow down the website. I know for now I can just develop something simple like one table but I would like to create something fast and be knowledgeable for the future. If someone could help me out with this I would be greatly appreciated.

Upvotes: 0

Views: 1323

Answers (2)

Sankalp Srivastava
Sankalp Srivastava

Reputation: 3

go for associative array that's what most of social networking sites like facebook etc use use somewhat like:

photo-gallery:
 {
  photo:
  {
   id:
   caption:
   path:
   comment:
   {
    id:
    commentor-id:
    comment-description:
   }
   comment:
   {
    id:
    commentor-id:
    comment-description:
   }
   .
   ....and so on
  }
 }

Upvotes: 0

vulkanino
vulkanino

Reputation: 9124

If you have 10 million users, you'll have the money to buy more resources to handle the requests :)

I would design a table with the comments, and another for the photos. The two tables are of course joined with a one-to-many relationship.

A good, properly configured, RDMBS won't care to store and select photos along with the comments. That's the db job, don't worry.

Upvotes: 2

Related Questions