Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

James Barrett
James Barrett
13,253 Points

Database schema for a social networking project; need some advice!

Hi there,

I am creating an ERD to get a graphical view of my database, here is what I have so far:

https://i.gyazo.com/27956e90df0de5616cc74cce8fa13f35.png

My question is, what is the best practice for storing comments and likes in a post? Should these be completely different tables? I read in a blog once that normalizing a database for the web can be horrible for querying; what's the best approach to this?

(Ignore the Lift part, that's more specific to what the project actually is)

Thanks, James.

1 Answer

Here's a StackOverflow article you might find interesting: http://stackoverflow.com/questions/8112831/implementing-comments-and-likes-in-database

And here's another re Facebook: http://stackoverflow.com/questions/19400622/database-structure-of-facebook-to-store-comments-and-post

There's also a thread on StackExchange: http://programmers.stackexchange.com/questions/215613/database-model-for-keeping-track-of-likes-shares-comments-on-blog-posts-over-tim

Plus another 940,000 pages if you google best way to store comments and likes in a database