Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Implement DB design in hibernate

 
Greenhorn
Posts: 9
Spring Java 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]
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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
Spring Java 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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.
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic