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

The Archive Base Latest Questions

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

I am building an online shop and I have a problem. I will have

  • 0

I am building an online shop and I have a problem.
I will have products which have a direct price (for example HTC Touch 2 Smartphone: $299.00 ), but in the same time I will have products which have prices for combinations based on varieties:
for example:

product: Nike Exclusive T-Shirt 2011
varieties: 
   Sizes: L, XL
   Colors: red, blue
combinations will be: 
L white - $10
XL white - $15
L blue - $11
XL blue - $16

I need the best way (or the only one working 🙂 ) of database structure, where I can store both types of products, and if I want to list my products from a category which contains both types of products on the webpage (single price, multiple prices) i can build a mysql query to get all the products in the same query.

thanks

UPDATE

I will have for sure the following tables: [products], [varieties] (color, size), [varietyValues] (which stores what king od colors and what kind of sizes does the product have – each one is a row in the table {productId + varietyId + value (red, S, M, green, XL, etc…)} ). After this one I would have another table [combinations], with a many-to-many [n-to-m] relationship between [combinations] and [varietyValues] which will result a new table [combPrices]. Each row of this new n-to-m table will have a price.

Now the problem is I can’t figure out how to store single-price products in this data structure.


UPDATE 2

In this image you can see the database diagram, which I think would be ok for the multiple-price products:
database diagram

THE MAIN PROBLEM:
Since this is a webshop, people will put items in the shopping cart. I think the items inserted into the shopping cart should be from the same table (in our case it would be the [combinations] table, since there are the prices stored).

Here are some data for these tables, just to be more clear:

[products]

productid   |   productName
1           |   Nike T-Shirt
2           |   HTC Touch 2 Smartphone

[specifications]

specId   |   productId   |   specName
1        |   1           |   Size
2        |   1           |   Color

[specvalues]

specValueId   |   specId   |   svValue
1             |   1        |   L
2             |   1        |   XL
3             |   2        |   white
4             |   2        |   blue
5             |   2        |   red

[combinations] (items into the cart)

combinationId   |   price   |   description
1               |   10      |   White L Nike T-Shirt
2               |   15      |   White XL Nike T-Shirt
3               |   11      |   Blue L Nike T-Shirt
4               |   16      |   Blue XL Nike T-Shirt
5               |   18      |   Red XL Nike T-Shirt

[combinationParts]

nmid   |   combinationId   |   specValueId
1      |   1               |   1
2      |   1               |   3
3      |   2               |   2
4      |   2               |   3
5      |   3               |   1
1      |   3               |   4
2      |   4               |   2
3      |   4               |   4
4      |   5               |   2
5      |   5               |   5

I hope my diagram and database population does make sense 🙂 .

So the final question is how can I store the single price products (HTC Touch 2 Smartphone) so it can be added to shopping cart just like the multiple price products.

  • 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-20T14:57:54+00:00Added an answer on May 20, 2026 at 2:57 pm

    You could easily store the price next to the product and use a query like this to get the products.

    SELECT p.productid, 
           p.productname, 
           CASE 
             WHEN cb.combinationid > 0 THEN cb.price 
             ELSE p.price
           END, 
           cb.combinationid 
    FROM   products p 
           LEFT JOIN specifications sp 
             ON sp.productid = p.productid 
           LEFT JOIN specvalues spv 
             ON spv.specid = sp.specid 
           LEFT JOIN combinationparts cbp 
             ON cbp.specvalueid = spv.specvalueid 
           LEFT JOIN combinations cb 
             ON cb.combinationid = cbp.combinationid 
    WHERE  p.productid IN ( 1, 2 ) 
           AND CASE 
                 WHEN cb.combinationid > 0 THEN cb.combinationid IN ( -100, 1, 2 ) 
                 ELSE 1 = 1 
               END 
    

    this needs as input product numbers and combinations. Since the combinations can be missing, I’ve added -100 as default value

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

Sidebar

Related Questions

I am building an online shop and I have a problem. I will have
I am building a simple C# web app which will act like an online
Hoping someone can point me in the right direction. I'm building a online shop
Building an inventory system. I have lots of products and each product has three
We are building an online appointment system for a client (hospital) which is located
Here's the situation I have: I'm building an online system to be used by
I have a idea of building sort of a simple online version of Microsoft
I'm building an online shop & trying to improve performance by minimising MYSQL queries.
I currently have a simple menu_alter hook in a new module I'm building which
I am building an online shop website that lets a user buy items online.

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.