Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old March 10th, 2008, 07:50 AM
Metaphor Metaphor is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 13 Metaphor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 12 m 52 sec
Reputation Power: 0
Different stock values to different product features

Hello,

I had already posted this question in PHP related forum but I was told to post it here. They thought it was a database question...

I'm developing a webstore in php, and I want to create the possibility of associating different stock values to different product features.

Example:

I have two t-shirts of the model A, one in green and one in white. As it is today, I can only assign a total stock ammount of 2 items (white + green).

I want to have the possibility of associating a stock value for the model A white t-shirt, and another stock value to model A green t-shirt.

I thought the solution was to change the php codes of the files that handle these features. But then i've been told that changing database tables would be much more easier and helpful.

I have a mysql database created but I'm a total newbie concerning programming, so I'd like to request assistance from this community, if possible.

Please tell me what you need to know in order to help me and I'll do it immediately.

Thanks in advance.

Reply With Quote
  #2  
Old March 10th, 2008, 08:24 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,719 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 4 m 29 sec
Reputation Power: 6
ok - what you want to do is have 3 different tables - one for the product, 1 for the attributes of products and a bridge table to link the different products to the different attributes.

Ex:
Code:
table1: Products
id  discription
1   shirt
2   pants
3   thingabob
4   domaflogy

table 2: attributes
id  value
1   white
2   green
3   plastic
4   metal

table3: Pro_to_attr
product_id   attr_id
1               1
1               2
2               2
3               3
3               4


make sense? with this method you can have as many attributes as you want on any given product.
__________________
life is a game.... Have fun
-----------------------------
http://www.phpwomen.org
strength in unity

PHPCommunity IRC
#phpc on freenode

Reply With Quote
  #3  
Old March 10th, 2008, 09:16 AM
Metaphor Metaphor is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 13 Metaphor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 12 m 52 sec
Reputation Power: 0
I think it makes sense.

Can you tell me what steps should I take to insert something like that on my database?

Reply With Quote
  #4  
Old March 10th, 2008, 04:43 PM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,719 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 4 m 29 sec
Reputation Power: 6
you need to create the tables you need - see your DB documentation on the CREATE statement syntax

for the basics on SQL see http://sqlcourse.com/ - see what you can come up with and if you need help - let us know.

Reply With Quote
  #5  
Old March 10th, 2008, 06:55 PM
Metaphor Metaphor is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 13 Metaphor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 12 m 52 sec
Reputation Power: 0
Quote:
Originally Posted by lig
you need to create the tables you need - see your DB documentation on the CREATE statement syntax

for the basics on SQL see http://sqlcourse.com/ - see what you can come up with and if you need help - let us know.


Ok I'll work on that.

Thanks!

Reply With Quote
  #6  
Old March 11th, 2008, 11:01 AM
Metaphor Metaphor is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 13 Metaphor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 12 m 52 sec
Reputation Power: 0
I already have a Products table.

On it there's a Features (attributes) field. It also has a Stock field (it's working but only like a total stock, not a stock for each feature)

So I can set different features to the same product.

Now what I need is a table that tells me that I can have different stock values (product quantities) for different attributes of the same product.

It's getting difficult to find help on this on the web...

Any help on this from anyone?

Thx a lot.

Reply With Quote
  #7  
Old March 11th, 2008, 11:12 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,719 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 4 m 29 sec
Reputation Power: 6
sounds like time for another table - quantities - with the product and attribute primary keys as its primary key.

normalization++

Reply With Quote
  #8  
Old March 11th, 2008, 01:31 PM
Metaphor Metaphor is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 13 Metaphor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 12 m 52 sec
Reputation Power: 0
Quote:
with the product and attribute primary keys as its primary key


Can you tell me how to do this?

I'm trying to learn but it's all too fast!

Thx once more for your patience.

Reply With Quote
  #9  
Old March 11th, 2008, 01:47 PM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,719 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 4 m 29 sec
Reputation Power: 6
what database are you using? Assuming you are using MySQL you can do it a couple of ways.

1) add it to the CREATE statement for the table
Ex:
Code:
mysql> CREATE TABLE test (a INT NOT NULL AUTO_INCREMENT,
    ->        PRIMARY KEY (a));


2) alter the table that is already made to have it
Ex:
Code:
mysql> ALTER TABLE test ADD PRIMARY KEY (a);


if you have more then one column that you want to be the primary key, just list the columns in the order you want comma seperated.

Reply With Quote
  #10  
Old March 11th, 2008, 02:52 PM
Metaphor Metaphor is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 13 Metaphor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 12 m 52 sec
Reputation Power: 0
I forgot to mention that I'm working on a mysql database online, i don't have it running locally.

So I'm working through The MySQL Database Admin v1.5.5.

From what see there's no need to use programming with that, there are shortcuts and buttons to work things out.

I'm having some difficulty but I'm on it...

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Different stock values to different product features


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway