Re: Implementing product attributes
Date: 2000/03/22
Message-ID: <jp2C4.20830$6b1.370816_at_news1.online.no>#1/1
Thomas Muller <ttm_at_nextra.com> wrote in message
news:xG1C4.20775$6b1.371497_at_news1.online.no...
> 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.
To elaborate a little more: The model should be flexible enough to allow each product to take care of it's own attributes. Assume the attributevalues to be BLOB's, one could add a field 'handler' (BLOB) to the attribute_value table and serialize implementations of the following interface to it (Java)
public abstract interface AttributeHandler implements Serializable {
public abstract void emit(OutputStream out, Object value) throws IOException;
public Object extract(InputStream in) throws IOException; }
The handler-field allows for NULL values, in which case a default handler is used to extract the value.
When a product reads itself from the database, it associates an internal list of attributenames with the corresponding handler for rapid lookup/insertion later.
-- ThomasReceived on Wed Mar 22 2000 - 00:00:00 CET