flexible approach [message #581] |
Tue, 30 January 2007 10:21 |
interop
Messages: 45 Registered: October 2006
|
Member |
|
|
I'm trying to use aspects of the "flexible approach" (http://www.tonymarston.net/php-mysql/control-data.html) to store attributes of my equipment. I have an equipment table, an attribute table (eqp_attrib) and a link table (eqp_data). eqp_data.value is a varchar(255) and I'd like to change the type (for display only) of the eqp_data.value based on the attribute type. My problem is when I want to add a new entry to eqp_data I cannot change the type of the value because I do not know the attribute type being entered. Has anyone encounted and solved a problem like this?
thanks
|
|
|
Re: flexible approach [message #582 is a reply to message #581] |
Wed, 31 January 2007 03:51 |
AJM
Messages: 2370 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
In the first place you have misunderstood when to apply the contents of that article. It is used to replace a single record with a large number of fields with a separate record for each field, but all still on the same table.
In the second place the arrows on your diagram are going in the wrong direction, which is confusing. The direction should be from ONE to MANY, primary key to foreign key.
I do no understand what you mean by "change the type of value". Table EQP_DATA has VALUE and EQP_ATTRIB_ID, and EQP_ATTRIB_ID supplies a value for EQP_ATTRIB_TYPE_ID. This means that a value is applied to an attribute, and an attribute has a type. A value is not linked directly with a type.
When you create a record on EQP_DATA you must supply a value for EQP_ATTRIB_ID which in turn supplies a value for EQP_ATTRIB_TYPE_ID. You therefore cannot change to a different EQP_ATTRIB_TYPE_ID without changing EQP_ATTRIB_ID.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|