Re: Implementing product attributes

From: Thomas Muller <ttm_at_nextra.com>
Date: 2000/03/22
Message-ID: <xG1C4.20775$6b1.371497_at_news1.online.no>#1/1


Raimundo Lozano <rlozano_at_medicina.ub.es> wrote in message news:38D88D42.D8A06D92_at_medicina.ub.es... [snip]
> The problem with Thomas Muller's approach is the type of an attibute in
 order to check the
> value, perform queries (value > ...), etc. If you use an unique varchar
 field to store the
> value, you need to indicate the type of the attribute in another one. The
 alternative can be to
> have a field for every type you expect, like value_char, value_int, etc.
 With both you need
> complex validation rules.
>
> Any suggest to solve that?
>

I assumed simple string values for the attributes. There are several approaches which applies to the allowance of multiple types. One is to add a field 'encoding' or 'type' to the attribute-table, and handle the attribute-value according to the value of this. All encoding-schemes are translatable to a varchar field, but in most databases this datatype has a limited length (in Oracle 2000), so for maximum flexibility a BLOB should be used. The value_char, value_int approach you suggest is quite poor, I think.

Depending of the abstraction-layer approach, you may skip the 'encoding' or 'type' field in the attribute-table. In a OO aproach, all "things" in the database should map to a class, and the the "thing" should inherently know how to handle it's attributevalues, thus enforcing validation checks on insertions and extractions.

--

Thomas
Received on Wed Mar 22 2000 - 00:00:00 CET

Original text of this message