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 8592887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:51:34+00:00 2026-06-11T23:51:34+00:00

I have 2 entities, let’s say Client and Company (both subclass of User ).

  • 0

I have 2 entities, let’s say Client and Company (both subclass of User).
Each having a list of Events: ClientEvents and CompanyEvents

The reason we’ve split up those tables at first (instead of going with Events table) was that events of each kind don’t mix (you can operate only on one kind of event at a time). That would also result in having 2 smaller tables instead of one big table.

  1. Is that a good way to go? (big table data volume ~1M)
    Maybe there is no need to split those tables in two and just use inheritance?
  2. What would be the best way to model it as Entities?

The attributes and operations on both types of entities are identical so I could model it as:

 @MappedSuperclass  
 public abstract class **Event** {...}  
 @Entity @Table(name="client_event")  
 public class **ClientEvent** {...}  
 @Entity @Table(name="company_event")  
 public class **CompanyEvent** {...}

Now is there a way to query each type of specific event without duplicating methods in DAO (using hibernate or JPA, maybe generics would be of use here)?
3. Is there a ‘rule of thumb’ in situations like this (two separate beings but identical attributes and operations) to model database tables and entities?

  • 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-06-11T23:51:35+00:00Added an answer on June 11, 2026 at 11:51 pm

    It depends on the size of table (number of events in total), for how long you want to keep those events in an active table, frequency of new events and retrieval of old events.

    You can keep one table if new events aren’t frequent. Its better to have two separate tables if the new events are very frequent and you need to search them often.

    you can make the searching/retrieval faster by archiving those old events into one table.

    In short, any design depends on the need of the business.

    Multiple tables will allow you to search faster while single table will give you ease of access and simplicity of the code/design.

    For the access, you can use same method, just pass the event type as the parameter and build the query upon that.

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

Sidebar

Related Questions

OK, let's say that I have two entities, A and B. For each user,
Let's say I have two entities: Group and User. Every user can be member
Let's say I have entities A, B, C and each A has many B
Let's say I have three entities, Company , StandardCompany , and CompanyTemplate , where
I have two Entities, let's say Car and Photo. Each photo has foreign key
Let's say, I have two tables, entities and tags. Relation between them is expressed
Let's assume I have two entities - project team and employee. Each employee could
OK so I have two entities in my data model (let's say entityA and
Let's say I have 2 entities in my data layer (Country and Language) that
Let's say I have two entities: Classroom and Student. The Classroom has a to-many

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.