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

The Archive Base Latest Questions

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

I do not have much experience in table design. My goal is to create

  • 0

I do not have much experience in table design. My goal is to create one or more product tables that meet the requirements below:

  • Support many kinds of products (TV, Phone, PC, …). Each kind of product has a different set of parameters, like:

    • Phone will have Color, Size, Weight, OS…

    • PC will have CPU, HDD, RAM…

  • The set of parameters must be dynamic. You can add or edit any parameter you like.

How can I meet these requirements without a separate table for each kind of product?

  • 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:20:59+00:00Added an answer on May 11, 2026 at 11:20 am

    You have at least these five options for modeling the type hierarchy you describe:

    • Single Table Inheritance: one table for all Product types, with enough columns to store all attributes of all types. This means a lot of columns, most of which are NULL on any given row.

    • Class Table Inheritance: one table for Products, storing attributes common to all product types. Then one table per product type, storing attributes specific to that product type.

    • Concrete Table Inheritance: no table for common Products attributes. Instead, one table per product type, storing both common product attributes, and product-specific attributes.

    • Serialized LOB: One table for Products, storing attributes common to all product types. One extra column stores a BLOB of semi-structured data, in XML, YAML, JSON, or some other format. This BLOB allows you to store the attributes specific to each product type. You can use fancy Design Patterns to describe this, such as Facade and Memento. But regardless you have a blob of attributes that can’t be easily queried within SQL; you have to fetch the whole blob back to the application and sort it out there.

    • Entity-Attribute-Value: One table for Products, and one table that pivots attributes to rows, instead of columns. EAV is not a valid design with respect to the relational paradigm, but many people use it anyway. This is the ‘Properties Pattern’ mentioned by another answer. See other questions with the eav tag on StackOverflow for some of the pitfalls.

    I have written more about this in a presentation, Extensible Data Modeling.


    Additional thoughts about EAV: Although many people seem to favor EAV, I don’t. It seems like the most flexible solution, and therefore the best. However, keep in mind the adage TANSTAAFL. Here are some of the disadvantages of EAV:

    • No way to make a column mandatory (equivalent of NOT NULL).
    • No way to use SQL data types to validate entries.
    • No way to ensure that attribute names are spelled consistently.
    • No way to put a foreign key on the values of any given attribute, e.g. for a lookup table.
    • Fetching results in a conventional tabular layout is complex and expensive, because to get attributes from multiple rows you need to do JOIN for each attribute.

    The degree of flexibility EAV gives you requires sacrifices in other areas, probably making your code as complex (or worse) than it would have been to solve the original problem in a more conventional way.

    And in most cases, it’s unnecessary to have that degree of flexibility. In the OP’s question about product types, it’s much simpler to create a table per product type for product-specific attributes, so you have some consistent structure enforced at least for entries of the same product type.

    I’d use EAV only if every row must be permitted to potentially have a distinct set of attributes. When you have a finite set of product types, EAV is overkill. Class Table Inheritance would be my first choice.


    Update 2019: The more I see people using JSON as a solution for the ‘many custom attributes’ problem, the less I like that solution. It makes queries too complex, even when using special JSON functions to support them. It takes a lot more storage space to store JSON documents, versus storing in normal rows and columns.

    Basically, none of these solutions are easy or efficient in a relational database. The whole idea of having ‘variable attributes’ is fundamentally at odds with relational theory.

    What it comes down to is that you have to choose one of the solutions based on which is the least bad for your app. Therefore you need to know how you’re going to query the data before you choose a database design. There’s no way to choose one solution that is ‘best’ because any of the solutions might be best for a given application.

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

Sidebar

Ask A Question

Stats

  • Questions 285k
  • Answers 285k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer perl -p -e 's/.*(YES|NO)\s*$/$1/;' If you want Y and N… May 13, 2026 at 4:49 pm
  • Editorial Team
    Editorial Team added an answer Here's how: a[i,j] = x May 13, 2026 at 4:49 pm
  • Editorial Team
    Editorial Team added an answer RewriteRule ^([0-9]{6})/$ /redirect.php?data=$1 [L] will match any string of 6… May 13, 2026 at 4:49 pm

Related Questions

During my apprenticeship, I have used NHibernate for some smaller projects which I mostly
I have some database table and need to process records from it 5 at
In the Zend Framework Quickstart , there has been a change from models that
I have some code in my application that looks something like this: char *hash

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.