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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:01:27+00:00 2026-06-18T11:01:27+00:00

I have a Product entity and table and would like the database design to

  • 0

I have a Product entity and table and would like the database design to allow finding a product by different keywords on top of its name, that is, like using a thesaurus e.g. product name “HDR-TD20V” should also be found by keywords “camcorder”, “camera”, “video camera”, etc. Note that this same mechanics can be used to locate the same record from different input languages e.g. looking for “camara de video” (Spanish) or “videokamera” (German) should also find the same record.

Assuming that I am using Hibernate-search i.e. Lucene I have the following two design choices:

  1. De-normalized approach: Product table has a keywords column that contain comma separated keywords for that product. This clearly violates the First Normal Form “… the value of each attribute contains only a single value from that domain.”. However, this would integrate nicely with Hibernate-search.
  2. Normalized approach: Define a Keyword entity table i.e. Keyword(id,keyword,languageId) and the many-to-many association ProductKeyword(productId,keywordId) but the integration with Hibernate-Search is not so intuitive anymore … unless e.g. I create a materialized view i.e. select * from Product p, Keyword k, ProductKeyword pk where p.id=pk.productId and k.id=pk.keywordId and index this materialized view.

I would of course prefer the choice 2 but I am not sure how Hibernate-search would optimally cover this use-case.

  • 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-18T11:01:28+00:00Added an answer on June 18, 2026 at 11:01 am

    Something like this should work:

    @Indexed
    public class Product {
        @Id
        private long id;
    
        @ManyToMany
        @IndexedEmbedded
        Set<Keyword> keywords;
    
        // ...
    }
    
    public class Keyword {
    
        @Id
        private long id;
    
        // only needed if you want a bidirectional relation
        @ManyToMany
        @ContainedIn
        Set<Product> products;
    
        // ...
    }
    

    I am leaving out options for lazy loading etc. How exactly the JPA mapping looks like depends on the user case

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

Sidebar

Related Questions

I have product item webpages located in /product/items/*.html?id=12345&ref=54321 and I would like the webpages
I have an existing database (PostgreSQL in my case), and would like to access
I have a settings table in a database that is accessed through Entity Framework
What would be the best way to design this MySQL database? I have cars
I have entity for Doctrine: <?php /** * @Entity * @Table(name=orders) */ class Orders
Say I have the following entity called inventory: I would like to know if
Suppose I have public class Product: Entity { public IList<Item> Items { get; set;
I have an entity Product which has relationship category, which is optional, and use
I have a Product and Category entity in many-to-many association. I am trying to
In our system we have an entity Product , which might have various custom

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.