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 ?

 

Regards 

Given "feature" and "car-feature" tables the presence of absence of an entry
in "car-feature" will accomplish your desire for true/false - i.e., "the car
has an airbag".  By abstracting just a little every "feature" can be boiled
down to a label/ID and then the added to "feature" and associated via
"car-feature".

In your example you could create a feature called "Top Speed - 240kph"

If every car is going to have a particular "feature" and only the "value"
matters you could considering adding a "car-properties" table:

car_property (car id, top_speed, etc.) and populate the top_speed column
with whatever value is applicable or leave it NULL if unknown or N/A.  The
relationship between "car" and "car_property" would be one-to-one (1-to-1)

Dave J.

Reply via email to