RE: Storing dynamic attribute data in a db

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday, January 18, 2007 3:51 PM Chris <mailto:dmagick@xxxxxxxxx>
said:

Hey Chris,

> If you have to write a 6 page document to explain what's going on,
> that's probably bad.. because in 6 months time if you need to revisit
> it, you're going to have issues.

hehe I wouldn't say that my other emails were 6 pages(!) but I tend to
ramble on sometimes. And not only that, sometimes complicated problems
are difficult to explain simply. As I think we've discovered. :P

> Why do you think you need to use a tree? I'm sure it's just a case of
> me not understanding something..
>
> Anyway I'd move the attributes to another table (pseudo-sql):
[snip]
> Then you can get all attributes easily:
> 
> select * from attributes where productid='X';

Consider this. You have three attributes: Color, Size, Collar.

Colors:

Red
Green
Blue

Sizes:

Small
Medium
Large

Collars:

V-Neck
Plain
Turtleneck

If the manufacturer allowed me to order any combination of the above
attributes (and their options) I would need to create only three tables
to organize it: products, products_attributes, and
products_attributes_options. This would allow me to do basically what
your SQL from above does.

1. Give me all the attributes for product 'X'.
2. Then give me all the options for all the attributes returned in Step
1.
3. Display three dropdown boxes.

But the complication comes when the manufacturer says:

1. You can only order a turtleneck if the shirt is green.
2. You can only order red shirts in small and medium.

At this point there is a breakdown in the data.

With the three table setup how can I indicate these requirements in the
data? I don't think I can, but I'm not positive.

On the other hand, if I use a hierarchical dataset I can make the
following tree:

(Copy and paste this into Notepad if it doesn't appear aligned
properly.)
Root
|-Red
| |-Small
| | |-V-Neck
| | |-Plain
| |-Medium
|   |-V-Neck
|   |-Plain
|-Green
| |-Small
| | |-V-Neck
| | |-Plain
| | |-Turtleneck
| |-Medium
| | |-V-Neck
| | |-Plain
| | |-Turtleneck
| |-Large
|   |-V-Neck
|   |-Plain
|   |-Turtleneck
|-Blue
  |-Small
  | |-V-Neck
  | |-Plain
  |-Medium
  | |-V-Neck
  | |-Plain
  |-Large
    |-V-Neck
    |-Plain

The reason I am writing to the list is to see if there is an easier way
to do this or if I'm heading in the right direction.

> No idea what price modifier is or if it applies to specific attributes
> but if it does, move it as well.

I should have left this part out... It's just the amount the price of a
product will change for that option. Example: Large green shirts are +$5
while all small shirts are -$2.



Chris.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux