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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:23:30+00:00 2026-05-31T02:23:30+00:00

Hello, stackoverflow community! I am working on a rather large database-driven web application. The

  • 0

Hello, stackoverflow community!

I am working on a rather large database-driven web application. The underlying database is growing in complexity as more components are being added, but so far I’ve had absolutely no trouble normalizing the data quite nicely.

However, this final component implies a table that can hold products.
Each product has a category, and depending on the category, has different fields.
Making a table for each product category doesn’t seem right, as there are currently five types, and they still have quite a lot of fields in common. (but in weird ways – a few general fields such as description and price are common to all 5 categories, but some attributes are shared between 1 and 2, others 3,4,5 and so on).

I’m trying to steer away from the EAV model for obvious performance reasons.

The thing is that according to what product type the user wants to enter into the database there is a somewhat (but not completely) different field structure – all of them have a name and general description, but other attributes such as “area covered” can be applied only to certain categories such as seeds and pesticides, but not fuel, which would have a diesel/gasoline boolean and a bunch of other fuel-related attributes.

Should I just extract the core features in a table, and make another five for each category type? That would be a bit hard to expand in the future.

My current idea would be to have the product table contain all the fields from all the possible categories, and then just have another table to describe which category from the product table has which fields.

product:        id | type | name | description | price | composition | area covered | etc.

fields:         id | name (contains a list of the fields in the above table)

product-fields: id | product_type | field_id (links a bunch of fields to the product table based on the product type)

I reckon this wouldn’t be too slow, easy to search (no need to actually join the other tables, just perform the search on the main product table based on some inputs) and it would facilitate things like form generation and data validation with just one lightweight additional query /join. (fetch a product from the db and join a concatenated list of the fields actually used in a string – split that and display the proper form fields based on what it contains, i.e. the fields actually associated with that product.

Thanks for your trouble!
Andrei Bârsan

  • 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-31T02:23:31+00:00Added an answer on May 31, 2026 at 2:23 am

    EAV can actually be quite good at storing data and fetching that databack again when you know the key. It also excels in it’s ability to add fields without changing the schema. But where it’s quite poor is when you need the equivilent of WHERE field1 = x and field2 = y.

    So while I agree the data behaviour is important (how many products share the same fields, etc), the use of that data is also important.

    • Which fields need searching, which fields are always just data storage, etc

    In most cases I’d suggest keeping all fields that need searching, in combination with each other, in the same table.

    In practice this often leads to a single table solution.

    • New fields require schema changes, new indexes, etc
    • Potential for sparsely populated data, using more space than is ‘required’
    • Allows simple queries, simple indexing and often the fastest queries
    • Often, though not always, the space overhead is marginal

    Where the sparse-data overheads reach a critical point, I would then head towards additional tables grouped by what fields they contain. More specifically, I would not create tables by product. This is on the dual assumption that most/all fields will be shared across at least some products, and that those fields will need searching.

    This gives a schema more like…

    Main_table ( PK, Product_Type, Field1, Field2, Field3 )
    Geo_table  ( PK, county, longitute, latitude )
    Value      ( PK, cost, sale_price, tax )
    etc
    

    You may also have a meta-data table describing which product types have which fields, etc.

    What this schema allows is a more densly populated set of tables, which can be easily indexed and so quickly searched, while minimising table clutter and joins by grouping related fields.

    In the end, there isn’t a true answer, it’s all a balancing act. My general rule of thumb is to stay with a single table until I actually have a real and pressing reason not to, not just a theoretical one.

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

Sidebar

Related Questions

Hello again Stackoverflow community, Today I am trying to execute an application with commandline
Hello stackoverflow community ! I am trying to figure out how to architect my
Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within a
Hello StackOverflow community, The air.swf file referenced here: http://livedocs.adobe.com/flex/3/html/help.html?content=distributing_apps_3.html used to launch AIR applications
Hello StackOverflow community, Is there any way to open a folder in Windows Explorer
Hello StackOverflow community, Is there any way to package the installer for an Adobe
Hello StackOverflow community, I have run into a problem that quite frankly is baffling
Hello people from stackoverflow I have found more IE7 problems (tested in compatibility mode
Hello StackOverflow Community, <plist> <dict> <key>Non Random Key</key> <dict> <key>Random Key</key> <dict> <key>Hello</key> <string>Hey</string>
Hello Stackoverflow community, for a little game I need to display an octagon (

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.