This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate database design multiple tables per class or add a type field  RSS feed

 
Johnny minty
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am building a web application which manages an email server and I'm in the process of designing the database structure that will be used however I'm stuck on a design decision.

My problem is as follows : At delivery time the mail server needs to look up mail routes. There are inbound routes and outbound routes which essentially are the same thing however and depending on the direction of the mail one or the other will be used.

From an object oriented design I have a top level table containing a matcher field to match on either the source or destination domain and a OneToMany relationship to the mail routes table containing the routes.

Domain Routes (long domain_id, String domainMatcher, @OneToMany mail_route)

Mail Routes (long route_id, String gateway, int port, @ManyToOne long domain_id)

I see I have 2 options :

1 ) I create a separate model one for inbound routes and one for outbound routes creating 2 @OneToMany relationships in the domain_routes table. This will make the routes easier to manage and clearer within the code however will require a new table.
2 ) I add a type field which can be used to filter the route type. This will remove the need for a separate table but it seems more messy.

Thank you for your help in advance.




 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!