Re: variant column type

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: variant column type
Дата
Msg-id 009d01cc4bbe$b59804d0$20c80e70$@yahoo.com
обсуждение исходный текст
Ответ на variant column type  (salah jubeh <s_jubeh@yahoo.com>)
Ответы Re: variant column type
Список pgsql-general

 

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.

В списке pgsql-general по дате отправления:

Предыдущее
От: Filippos
Дата:
Сообщение: heavy load-high cpu itilization
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Re: variant column type