Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Can any one help me to design Table for Product Attribute means a product cost will vary according to its attribute like if we talk about T-shirt then its cost will depend on Size,Color & Fabric.
Posted
Comments
Sergey Alexandrovich Kryukov 6-Aug-15 13:55pm    
"Can anyone help?.." is not a question on the topic of this forum. What kind of help do you need?
Why just one table? It rarely makes the best schema.
What have you tried so far?
—SA
Surendra0x2 6-Aug-15 14:35pm    
Sir i have designed Product table but stuck with how to manage productAttribute table as a product price will vary according to its attribute like size color and material i tried to design productOptionGroup table which contains optiongroupid and optionGroupName like 1-color 2-size 3-material and other table called Option value table which contains optionid optiongroupid option value like 1-1-Red 2-2-XL and after these two table a combination of both table Productid l Optiongroupid Optionid l Productincrement like 1001 l 1 l 1 l 30$ here 1001 is productid 1 is optiongroupid , 1 is optionid and 30$ is price increment here problem is i want to decide price according to two or multiple attributes but acording to this table structure price is varying with on attibute at a time but i want two or more attribute to decide price like productid 1001 havin in red color and xL size and in cotton then its price will increment means price can vary more than 1 attribute too. But in my table structure only one attribute can be applied to decide price but i want both size and color to vary price. Thanks

1 solution

Sounds as if the issue is with code. Specifically TSQL. Here's some. Copy and paste into SSMSE. In the case of data file, create it and make sure you've got a complete path to it (alter the path to it below before running the TSQL).
The only way to get help here in QA is to post code. Post errors when it's run; speculate on the origin of that error. Provide useful thoughts. Etc.

USE [cpqaAnswers]
GO
--CREATE SCHEMA [cpqa]
CREATE TABLE [cpqaAnswers].[cpqa].[tbl_ST_TShirt]
(
[Style] nvarchar(200),
[Description] nvarchar(300),
[Size] nvarchar(19),
[Color] nvarchar(11),
[Fabric] nvarchar(24),
[Comments] nvarchar(79),
[Price] float
)

SELECT * FROM [cpqaAnswers].[cpqa].[tbl_ST_TShirt]

INSERT INTO [cpqaAnswers].[cpqa].[tbl_ST_TShirt]
([Style],
[Description],
[Size],
[Color],
[Fabric],
[Comments],
[Price])
VALUES('crew','heavyduty','M','RED','cotton','autumnwear',29.99)

SELECT * FROM [cpqaAnswers].[cpqa].[tbl_ST_TShirt]

/*
Are not the "attributes of which you speak references to the fields in the
table?
*/

INSERT INTO [cpqaAnswers].[cpqa].[tbl_ST_TShirt]
([Style],
[Description],
[Size],
[Color],
[Fabric],
[Comments],
[Price])
VALUES('frilled','lightweight','S','BLUE','polyester','summerwear',39.55)

SELECT * FROM [cpqaAnswers].[cpqa].[tbl_ST_TShirt]

Content of bulkinsertData.txt:

crew    mediumweight    L   GREEN   cotton  yearround   44.45
crew    mediumweight    L   RED cotton  yearround   44.45
crew    lightweight L   WHITE   cotton  yearroiund  44.45


BULK INSERT [cpqaAnswers].[cpqa].[tbl_ST_TShirt] FROM bulkinsertData.txt'

SELECT * FROM [cpqaAnswers].[cpqa].[tbl_ST_TShirt]

/*

crew heavyduty M RED cotton autumnwear 29.99
frilled lightweight S BLUE polyester summerwear 39.55
crew mediumweight L GREEN cotton yearround 44.45
crew mediumweight L RED cotton yearround 44.45
crew lightweight L WHITE cotton yearroiund 44.45

*/
SELECT [Style],[Color],[Price] FROM [cpqaAnswers].[cpqa].[tbl_ST_TShirt] WHERE [Price]=44.45

/*
crew GREEN 44.45
crew RED 44.45
crew WHITE 44.45
*/
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900