On Jul 26, 2011, at 10:02 AM, salah jubeh wrote:
Hello,
suppose the following scenario
the car speed is 240
the car has an airbag
Here the first value is integer and the second value is boolean. Consider that I have this table structure
feature (feature id feature name)
car (car id, .... )
car_feature (car id, feature id, value). the value attribute might have different domains. How can I model this using postgres and using ANSI compliant design ?
You haven't been very clear but it sounds like maybe you're asking how to get both EAV "flexibility" and type safety? There isn't any good way to do that but you might consider something ugly, like:
car (id, ...)
car_boolean_features (car_id, ....)
car_int_features (car_id, ...)
A better thing to consider, of course, is how you might avoid the need for anything like EAV in the first place.