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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:19:53+00:00 2026-05-20T05:19:53+00:00

So, not having come from a database design background, I’ve been tasked with designing

  • 0

So, not having come from a database design background, I’ve been tasked with designing a web app where the end user will be entering products, and specs for their products. Normally I think I would just create rows for each of the types of spec that they would be entering. Instead, they have a variety of products that don’t share the same spec types, so my question is, what’s the most efficient and future-proof way to organize this data? I was leaning towards pushing a serialized object into a generic “data” row, but then are you able to do full-text searches on this data? Any other avenues to explore?

  • 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-20T05:19:54+00:00Added an answer on May 20, 2026 at 5:19 am

    split products and specifications into two tables like this:

    products
    id name
    
    specifications
    id name value product_id
    

    get all the specifations of a product when you know the product id:

    SELECT  name,
            value
    FROM    specifications
    WHERE   product_id = ?;
    

    add a specification to a product when you know the product id, the specification’s name and the value of said specification:

    INSERT INTO specifications(
        name,
        value,
        product_id
    ) VALUES(
        ?,
        ?,
        ?
    );
    

    so before you can add specifications to a product, this product must exist. also, you can’t reuse specifications for several products. that would require a somewhat more complex solution 🙂 namely…

    three tables this time:

    products
    id name
    
    specifications
    id name value
    
    products_specifications
    product_id specification_id
    

    get all the specifations of a product when you know the product id:

    SELECT  specifications.name,
            specifications.value
    FROM    specifications
    JOIN    products_specifications
    ON      products_specifications.specification_id = specifications.id
    WHERE   products_specifications.product_id = ?;
    

    now, adding a specification becomes a little bit more tricky, cause you have to check if that specification already exists. so this will be a little heavier than the first way of doing this, since there are more queries on the db, and there’s more logic in the application.

    first, find the id of the specification:

    SELECT  id
    FROM    specifications
    WHERE   name = ?
    AND     value = ?;
    

    if no id is returned, this means that said specification doesn’t exist, so it must be created:

    INSERT INTO specifications(
        name,
        value
    ) VALUES(
        ?,
        ?
    );
    

    next, either use the id from the select query, or get the last insert id to find the id of the newly created specification. use that id together with the id of the product that’s getting the new specification, and link the two together:

    INSERT INTO products_specifications(
        product_id,
        specification_id
    ) VALUES(
        ?,
        ?
    );
    

    however, this means that you have to create one row for every specific specification. e.g. if you have size for shoes, there would be one row for every known shoe size

    specifications
    id name value
    1  size 7
    2  size 7½
    3  size 8
    

    and so on. i think this should be enough though.

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

Sidebar

Related Questions

We were having a problem with our build server not checking out modifications from
I'm having a problem running a VS 2005 app on some machines and not
I'm interfacing with a payment gateway and not having any luck with Net::SSLeay and
Having not done ASP.NET since v1.1, and now blitzing through the Wrox Pro ASP.NET
After having a search around I could not find exactly what I want, I
I am having problems with text with multiple lines not reformatting properly when I
I'm having an error where I am not sure what caused it. Here is
I'm still having a hard time not wanting to use Tables to do my
I'm having an issue with a Flash/Flex erroring in Firefox but not IE. I
Not too practical maybe, but still interesting. Having some abstract question on matrix multiplication

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.