Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5927821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:13:23+00:00 2026-05-22T14:13:23+00:00

I am designing a database for an application where a user can comment on

  • 0

I am designing a database for an application where a user can comment on pictures & videos.

Should I keep separate tables for comments like (Picture_comments & videos_comments)

OR
should I keep single table for comment and other mapping tables like (picture_comment_mapping & video_comment_mapping).

Which one will be better approach and why?

Detail
Approach 1:

user
     id
     name

Picture
     id
     link
video
     id
     link

comment_video
     id
     user_id
     video_id
     comment
comment_picture
     id
     user_id
     picture_id
     comment

Approach 2:

user
     id
     name

picture
     id
     link
video
     id
     link

comment
     id
     user_id
     comment

comment_picture_mapping
     id
     comment_id
     picture_id
comment_video_mapping
     id
     comment_id
     video_id

Which one is better approach and why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:13:24+00:00Added an answer on May 22, 2026 at 2:13 pm

    I would make an entity with name “Comment”, and add relation mapping on on that comment entity with user. The comment entity will also contain enumerated value on one column saying if its for picture or its for video. Something like –

    enum MimeType {
        PICTURE, VIDEO;
    }
    
    class Comment {
        @ManyToONe
        private User user;
        @Enumerated
        private MimeType mimeType;
    }
    

    Why I like this approach? Because its cleaner, and resulting entities will be less, and I do not have to write different queries to search for different types of mime type comments. And since comments are on diff table, i can load them lazily.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing my database and LINQ To SQL ASP.NET web application. Imagine I have
I'm designing a small SQL database to be used by a web application. Let's
I am designing an application that needs to save geometric shapes in a database.
I am designing database tables for a master-detail scenario. The specific requirement is that
When designing a database to use MVCC (Multi-Version Concurrency Control), you create tables with
I am designing a User table in my database. I have about 30 or
I'm designing a few applications that will share 2 or 3 database tables and
When designing a new application/database for multiple users, it usually involves having a table
I have designed a database for an application which contains user settings. This database
I would like to ideally set up a user interface for designing emails that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.