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

  • Home
  • SEARCH
  • 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 165009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:50:43+00:00 2026-05-11T11:50:43+00:00

I was thinking about some stuff lately and I was wondering what would be

  • 0

I was thinking about some stuff lately and I was wondering what would be the RIGHT way to do something like the following scenario (I’m sure it is a quite common thing for DB guys to do something like it).

Let’s say you have a products table, something like this (MySQL):

CREATE TABLE `products` (   `id` int(11) NOT NULL auto_increment,   `product_name` varchar(255) default NULL,   `product_description` text,   KEY `id` (`id`),   KEY `product_name` (`product_name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 

Nothing out of the ordinary here. Now lets say that there are a hierarchy of categories in a different table, and there is a separate table which binds many-to-many relationships with products table – so that each product belongs to some kind of a category (I’ll omit those, because thats not the issue here).

Now comes the interesting part – what IF each of the categories mandates additional set of variables to the product items. For example products in the computer monitors category must have LCD/CRT enum field, screen size enum etc. – and some other category, lets say ice creams have some other variables like flavor varchar, shelf storage time int etc.

The problem herein lies in that all products have a common set of variables (id, name, description and sort of like that), but there are additional variables which are not consistent from category to category – but all products should share common set, because in the end they all belong to the products group, so one can query for example SELECT * FROM products ORDER BY company_id (trivial example, maybe not representative, but you get the picture).

Now, I see severa potential resolutions:
– generate separate table for each product category and store products there with appropriate additional variables – stupid and not query friendly

– product table stays the same with common variables, and for each category create a separate table with additional variables binding two tables with a JOIN – normalized, but query performance and clarity issues – how would one filter down products from category (1st table – products) and additional filter for extra variable (17′ LCD monitors ie.) – it would require SQL JOIN trickery

– products table stays the same and add another variable type text that holds for example JSON data that hold additional variables – compact and neat, but can’t filter through variables with SQL

I know I’m missing something quite obvious and simple here – I’m a bit rusty on the normalization techniques 🙂


edit: I’ve been searching around stackoverflow before asking this question without success. However, after I’ve posted the question I have clicked on one of my tags ‘normalization’ and found several similar questions which resulted in to look up ‘generalization specialization relational design’. Point of the story is that this must be the first occurrence in my internet life that tags are actually useful in search. However, I would still like to hear from you guys and your opinions.


edit2: The problem with approach no.2 is that I expect somewhere around ~1000 specializations. There is a hierarchy (1-4 level deep) of categories and end nodes add specialized variables – they accumulate in the order of ~1000, so it would be a bit unpractical to add specialized tables to join with.


edit3: Due to the vast number of attribute volatility in my case ‘entity attribute value’ that was suggested looks like the way to go. Here comes query nightmares! Thanks guys.

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

    How many product types do you expect? Do they each have their own application logic?

    You can do a generalized model called the ‘entity attribute value’ model, but it has a LOT of pitfalls when you’re trying to deal with specific properties of a product. Simple search queries turn into real nightmares at times. The basic idea is that you have a table that holds the product ID, property name (or ID into a properties table), and the value. You can also add in tables to hold templates for each product type. So one set of tables would tell you for any given product what properties it can have (possibly along with valid value ranges) and another set of tables would tell you for any individual product what the values are.

    I would caution strongly against using this model though, since it seems like a really slick idea until you have to actually implement it.

    If you number of product types is reasonably limited, I’d go with your second solution – one main product table with base attributes and then additional tables for each specific type of product.

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

Sidebar

Related Questions

I know its probably possible, but is it practical and doable to try and
I know its probably possible, but is it practical and doable to try and

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.