How to create database structure for shopping cart where multiple attributes will insert and that is not fixed?

I have to create database structure for shopping cart project where i got stuck.

Requirements :-

1.) I have one product table that is like


proId p.k.,

proName ,


and i have to maintain some properties of this product that is not fixed

like (products T-Shirt have properties colours, size, pattern etc.) these are not fixed bt i have to insert records like

       Size     Colurs    Qty

T-shirt XL Red 5

bt these properties Size, Colours are not fixed they can more or less so how can i insert them in one table?
more ▼

asked Aug 10 '12 at 06:57 AM in Default

rajnish gravatar image

20 2 2 3

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Just add the columns to the product table, make them varchar(x) date type. You have a choice of leaving them Null is there is no values, or what I like to do is place NA (for Not Applicable) in the column. The NA value helps with not having to remember to add WHERE Columnname Is Not Null or Is Null to queries.

You can see an example of this in the AdventureWorks database from CodePlex.

Thanks, Thomas
more ▼

answered Oct 17 '12 at 03:53 PM

TheSmilingDBA gravatar image

91 1 1 2

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Aug 10 '12 at 06:57 AM

Seen: 997 times

Last Updated: Oct 17 '12 at 03:53 PM