Re: variant column type

From: Ben Chobot <bench(at)silentmedia(dot)com>
To: salah jubeh <s_jubeh(at)yahoo(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: variant column type
Date: 2011-07-26 17:37:39
Message-ID: 4CDD442C-640E-4827-A8F5-161A568BDB88@silentmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2011-07-26 17:45:27 Re: variant column type
Previous Message salah jubeh 2011-07-26 17:17:10 Re: variant column type