• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implement DB design in hibernate

 
Isuru Jay
Greenhorn
Posts: 9
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am designing a database to store Electric and electronic products. As different products have lot of different features I have a table call "Product" to store common features and product specific tables to stare its own features.

Here I consider about 3 tables
1. Product - common features
2. TV - television specific features
3. Fridge - fridge specific features

I have attached an image and it will be clear I think.

My problem is how to implement it in hibernate? The issue is here product table have a relationship with either Fridge or TV table.

Can somebody help me to solve this?

thanks...


products.jpg
[Thumbnail for products.jpg]
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you consider working with a discriminator column? Have a look here for all possibilities.

The Joined, Multiple Table Inheritance approach will be exactly what you are looking for.

Hope it helps!
Kind regards,
Roel
 
Isuru Jay
Greenhorn
Posts: 9
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel. yes, that's what I was looking for. Thank you very much.

And one more thing

If I follow this way, will it be a issue with the performance when retrieving records from these tables?
Actually I need a very good performance while searching the products.
Could you please suggest any improvements for this product table.

Thanks and Regards,
Isuru

 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isuru Jay wrote:If I follow this way, will it be a issue with the performance when retrieving records from these tables?
Actually I need a very good performance while searching the products.
Could you please suggest any improvements for this product table.

With this approach (seperate tables) you (hibernate) will of course need a join to get all data. So I doubt if this could be a performance issue, certainly if your database design has the required primary keys, foreign keys and indexes. I'll use this approach myself in a production environment for almost 1 year and no complaints about performance so far

But if performance is really important you could of course opt for the single table approach. Then you'll have just 1 product table containing all common fields and all product specific features. Using this approach a join isn't required anymore.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic