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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:48:34+00:00 2026-06-03T02:48:34+00:00

I am looking to create a MySQL shop that is capable of handling multiple

  • 0

I am looking to create a MySQL shop that is capable of handling multiple categories. I have all of the category facility etc sorted but the bit I am not getting anywhere with is this..

Each item can have multiple options, for example a T-Shirt should have the options ‘Colour’ and ‘Size’. I then need to create a number of variations/ derived products from the parent product specifying that an Extra Large Blue T-Shirt has 20 in stock (for example). The problem is, it’s not just clothes being sold, it could be any number of things. So I also need this schema to be able to handle an infinite number of variants such as ‘6mm‘ ‘Large‘ Birthday Card with ‘Sports Car‘ design. 6mm, Large, and ‘Ace’ being the variables. This way I am able to ensure that we do not have any stock control issues. If it is any use to you, below is my current site structure.

Existing Database Schema http://www.hallwaystudios.com/screenshots/uploads/g5B7SNKU.png

I hope you understand what I mean and that someone has an answer to my problem! Many thanks in advance (and after of-course)

  • 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-06-03T02:48:35+00:00Added an answer on June 3, 2026 at 2:48 am

    Not too sure what the problem is here… I’d probably create four tables:

    -- a table of item types (t-shirt, birthday card, etc.)
    CREATE TABLE ItemTypes (
      TypeID      INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      TypeName    VARCHAR(20) NOT NULL
    );
    
    -- a table of associated properties
    CREATE TABLE TypeProperties (
      PropertyID  INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      TypeID      INT NOT NULL,
      PropName    VARCHAR(20) NOT NULL,
      INDEX(Property, TypeID),
      FOREIGN KEY(TypeID) REFERENCES ItemTypes(TypeID)
    );
    
    -- a table of specific items (XL Blue t-shirt, large bday card w/sports car, etc.)
    CREATE TABLE Items (
      ItemID      INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      TypeID      INT NOT NULL,
      ItemName    VARCHAR(100) NOT NULL,
      ItemPrice   DECIMAL UNSIGNED NOT NULL,
      ItemStock   INT UNSIGNED NOT NULL,
      INDEX(ItemID, TypeID),
      FOREIGN KEY(TypeID) REFERENCES ItemTypes(TypeID)
    );
    
    -- the dictionary of property values
    CREATE TABLE ItemProperties (
      ItemID      INT NOT NULL,
      TypeID      INT NOT NULL,
      PropertyID  INT NOT NULL,
      Value       VARCHAR(20) NOT NULL,
      PRIMARY KEY(ItemID, Property),
      INDEX(ItemID,     TypeID),
      INDEX(PropertyID, TypeID),
      FOREIGN KEY(            TypeID) REFERENCES ItemTypes     (            TypeID),
      FOREIGN KEY(ItemID,     TypeID) REFERENCES Items         (ItemID,     TypeID),
      FOREIGN KEY(PropertyID, TypeID) REFERENCES TypeProperties(PropertyID, TypeID)
    );
    

    It ought to be fairly obvious, but just in case, the example data would look something like:

    INSERT INTO ItemTypes (TypeID, TypeName) VALUES
      (1, 'T-Shirt'      ),
      (2, 'Birthday Card'),
      (3, 'Balloon'      );
    
    INSERT INTO TypeProperties(PropertyID, TypeID, PropName) VALUES
      (51, 1, 'Colour' ), (52, 1, 'Size'),
      (53, 2, 'Size/mm'), (54, 2, 'Size'), (55, 2, 'Design'),
      (56, 3, 'Colour' );
    
    INSERT INTO Items (ItemID, TypeID, ItemName, ItemPrice, ItemStock) VALUES
      (101, 1, 'Extra Large Blue T-Shirt',                       10.99, 20),
      (102, 2, '6mm Large Birthday Card with Sports Car Design',  2.99, 17),
      (103, 1, 'Extra Large Black T-Shirt',                      10.99,  5),
      (104, 3, 'Pink balloon',                                    0.10, 60);
    
    INSERT INTO ItemProperties (ItemID, TypeID, PropertyID, Value) VALUES
      (101, 1, 51, 'Blue'       ),
      (101, 1, 52, 'Extra Large'),
      (102, 2, 53, '6'          ),
      (102, 2, 54, 'Large'      ),
      (102, 2, 55, 'Sports Car' ),
      (103, 1, 51, 'Black'      ),
      (103, 1, 52, 'Extra Large'),
      (104, 3, 56, 'Pink'       );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to create an application that uses a remote mysql database, takes
I have a mysql database and some php that allows you to create an
Looking for a tool that will automatically create a graphical representation of a MySQL
I have a MySQL table and I am looking to create a stats page
I am looking for a javascript plugin that will let users create MySQL tables
I'm looking to create a read-only table, and MYSQL permissions, I think, are the
Possible Duplicate: How I can create installer for website. PHP mysql I'm looking to
I looking to create a custom calender with Zend Framework, I am hoping that
Im looking to create a control that would look like comic baloon. In WPF
I'm looking to create something like in this image. Each block would have an

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.