x

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

tblProduct

proId p.k.,

proName ,

Qty

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, 2012 at 06:57 AM in Default

rajnish gravatar image

rajnish
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, 2012 at 03:53 PM

TheSmilingDBA gravatar image

TheSmilingDBA
91 1 1 3

(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

By RSS:

Answers

Answers and Comments

SQL Server Central

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

Topics:

x108

asked: Aug 10, 2012 at 06:57 AM

Seen: 1197 times

Last Updated: Oct 17, 2012 at 03:53 PM