Alex Rivera | Logout

Most efficient database design for a blog (posts and comments)

Asked 2010-08-16T19:09:16.687
16

What would be the best way of designing a database to store blog posts and comments? I am currently thinking one table for posts, and another for comments, each with a post ID.

It seems to me, however, trawling through a large table of comments to find those for the relevant post would be expensive, and would be done every time a blog post is loaded (perhaps with some amount of caching).

Is there a better way?

Edit
Report

1 Answer

22

It seems to me, however, trawling through a large table of comments

All the database vendors agree with you.

They offer "indexes" to limit this.

answered 2010-08-16T19:14:43.943

Your Answer