3

Assuming there are a few categories: blog, video, gallery. Each of them contains post data like id, title, content, author_id, created_at, but different category have few more specific field: video will have links, gallery will have imgURL.

Besides, user can leave comment. Comment have identical fields with Content too: id, title, content, author_id, created_at, and original_post_id.

My question is: blog, video, gallery, comment have common field, should I create a table called CommonContent: id, title, content, author_id, created_at?

CommonContent and Blog/ Video/ Comment are in 1:1 relationship. So should I still create a CommonContent table? My concern is if all common fields put in one table, it creates bottleneck when selecting data.

2

I think the benefit of having a common table for blog, video, gallery, comment is that you will have unique id for each one of these, but that is really not needed.

And It seems that all these share some common attributes, so we need to have common table to save those, but from application point of view they will be different and needs to be save in different table.

Saving all of them in common table will be problem in maintainance, and also while fetching those entry to show in UI, So it would be better to have different table for all these four.

Then there comes thing is how to store comments, Well comments can be on video or blog or gallery, and with time it can be very large in numbers so you can choose one comment table for each category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.