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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:17:15+00:00 2026-06-18T10:17:15+00:00

In my application there are products and a product-variant-group which has a defined set

  • 0

In my application there are products and a product-variant-group which has a defined set of properties which a product of this group must declare and the combination of the properties is unique across that product-variant-group.

Example screen from amazon:

enter image description here

In the image the first select menu has all values obviously. The next select menu depends on the previously selected value, and so on.

Those defined group properties have a unique priority assigned to it which in the following derived table equals the property itself.

For a given property/priority and given list of of property/priority-value pairs. I want to retrieve its possible values.
The priorities of the value pairs must be smaller then the given priority.

public String[] getProductVariantGroupValues(int productVariantGroupId, int priority, Map<Integer, String> prevValues);

An example makes it much clearer:

I have an sql statement which lists all product-variant-group properties that related products have defined:

+---------+----------+-------- +
| product | priority | value   |
+---------+----------+---------+
|       1 |        1 | Black   |
|       1 |        2 | 38      |
|       1 |        3 | Dots    |
|       2 |        1 | Black   |
|       2 |        2 | 38      |
|       2 |        3 | Stripes |
|       3 |        1 | Yellow  |
|       3 |        2 | 40      |
|       3 |        3 | Stripes |
+---------+----------+---------+

Other view for understanding *(priority is arbitrary just for understanding, with this view this would be trivial)*:

+---------+--------+--------+---------+
| product | value1 | value2 | value3  |
+---------+--------+--------+---------+
|       1 | Black  | 38     | Dots    |
|       2 | Black  | 38     | Stripes |
|       3 | Yellow | 40     | Stripes |
+---------+---------------------------+

Call the above method with priority = 3 and prevValues = {(1, Black), (2, 38)} should result in following result array: {Dots, Stripes}.

If black is selected for property/priority 1 and 38 is selected for property/priority 2 the only possible following values for property/priority 3 are {Dots, Stripes}

The example is simplified and an arbitrary number of properties/priority should be supported. The query must be created dynamically to support arbitrary number of lower priority values.

Maybe I should just use the second table appraoch with a fixed set of properties which would make the unique constraint and this query very simple.

  • 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-18T10:17:16+00:00Added an answer on June 18, 2026 at 10:17 am

    If I understand the question correctly, you have a value for priority 1 and for priority 2 and want to get all priority 3 values that match. The following query gets the products:

    select product
    from t
    group by product
    having max(case when priority = 1 and value = 'Black' then 1 else 0 end) = 1 and
           max(case when priority = 2 and value = 40 then 1 else 0 end) = 1
    

    To get the priority 3 values requires or a clever select statement (assuming priorities are not repeated for a product):

    select product, max(case when priority = 3 then value end)
    from t
    group by product
    having max(case when priority = 1 and value = 'Black' then 1 else 0 end) = 1 and
           max(case when priority = 2 and value = 40 then 1 else 0 end) = 1
    

    These queries are to give you an idea of how to construct the queries in your code. The generalization should be pretty straightforward.

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

Sidebar

Related Questions

In System.Windows.Forms.Application there are two properties called LocalUserAppDataPath and UserAppDataPath . On this computer
My PHP application has the function product_fetch([parameters]) which returns 'Product' objects which information are
On my CakePHP 1.3 application there is a product page. On this page it
We have an application, which sells downloadable products. Scenario is: Add product to our
I am writing an application which produces invoices. I was wondering it there was
In the following console application example, the event is defined like this: public delegate
How to use Amazon Product Advertising API to show Products inside my iPhone Application?
I'm writing a multistore webshop application in PHP/MYSQL. The products table has about a
AppEngine 1.2.2. I define a class Product like so: @PersistenceCapable(identityType = IdentityType.APPLICATION, table=Products) public
I am developing one android application. In which I have some Products and form

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.