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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:24:26+00:00 2026-05-29T11:24:26+00:00

I’m trying to come up with a database/model design for product and related dynamic

  • 0

I’m trying to come up with a database/model design for product and related dynamic product attributes. However at the modeling part I’m afraid I’m doing something “wrong”, as I end up using A LOT of JOINS. Basically I’m hoping to get some input on how to achieve the desired functionality, perhaps with a more simple design.
Should anyone with experience feel that I missed something of importance – then please enlighten me 🙂

Examples of dynamic product attributes:

  • Size
  • Color
  • Manufacturer
  • Weight

The “dynamic” attribute covers two aspects, one where there’s a single value, like weight that equals some value, or the other example color, which holds a lot of different values.
In addition to the attribute values, each attribute also has unique language settings. E.g. the attribute key/value can change depending on the customer language.

Structure of my tabels:

Product

- id
- created
- modified

Product_variants

- id
- product_id
- quantity
- price

Attribute

- id
- visible
- required
- comparable

Attribute_group

- id
- type

Attribute_groups_attributes

- attribute_group_id
- attribute_id

Attribute_group_languages

- id
- attribute_group_id
- name
- locale

Attribute_languages

- id
- attribute_id
- name
- value
- locale

Product_attribute

- product_id
- attribute_id
- group
- variant

Example of a query

In order to fetch the newest products and matched attributes, I execute the nasty query below:

SELECT pv.price, pv.special_price, pv.overlay_id, p.id, pv.id variant, pl.url_key, pl.name, UNIX_TIMESTAMP(p.created) created, al.value color_value, a.id color_id,al.name color_name
FROM x_product_attribute pa
INNER JOIN x_attribute_group ag
ON pa.attribute_id = ag.id AND pa.group = 1 AND pa.variant = 0 AND ag.type LIKE 'color%'
INNER JOIN x_attribute_group_languages agl
ON agl.attribute_group_id = ag.id AND agl.locale = :locale
INNER JOIN x_attribute_groups_attributes aga
ON aga.attribute_group_id = pa.attribute_id
INNER JOIN x_product_attribute pa2
ON aga.attribute_id = pa2.attribute_id AND pa2.variant = 1 AND pa2.group = 0
INNER JOIN product_variants pv
ON pa2.product_id = pv.id
INNER JOIN x_attribute_languages al
ON al.attribute_id = pa2.attribute_id AND al.locale = :locale
INNER JOIN x_attribute a
ON a.id = pa2.attribute_id
INNER JOIN products p
ON p.id = pa.product_id
INNER JOIN product_languages pl
ON pl.product_id = p.id
INNER JOIN shop_products sp
ON sp.shop_id = :shop_id AND sp.product_id = pa.product_id
GROUP BY p.id,a.id
ORDER BY p.created DESC,a.sort ASC, p.id DESC 

As mentioned, there’s a lot of JOINS in a query that should be relative simple. I could split this up into smaller queries, but I’m not sure what would be the most effective – while still mapping and keeping the “dynamic” properties of the attributes.

  • 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-05-29T11:24:27+00:00Added an answer on May 29, 2026 at 11:24 am

    I would suggest a NoSQL solution, such as MongoDB. It will make designing your application much easier since you can represent your products with simple name-value pairs (just like JSON).

    If you stick with SQL, I think that you will find that your application and database become unmanageable.

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

Sidebar

Related Questions

I'm trying to come up with a relational model and database implementation, but keep
I'm trying to come up with (or find) a reusable system for database schema
Greetings stackers, I'm trying to come up with the best database schema for an
im trying to come up with a design for a wrapper for use when
We're trying to come up with a recommended design pattern for our team when
I am trying to come out with a good design for the storage of
I'm trying to come up with a function that produces possible database matches for
I am trying to design a database structure for a website that offers people
I'm trying to generate my model from the database as usual, creating the model
I am trying come up with a way to pull the tables out of

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.