Re: variant column type - Mailing list pgsql-general

From Ben Chobot
Subject Re: variant column type
Date
Msg-id 4CDD442C-640E-4827-A8F5-161A568BDB88@silentmedia.com
Whole thread Raw
In response to variant column type  (salah jubeh <s_jubeh@yahoo.com>)
List 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.

pgsql-general by date:

Previous
From: salah jubeh
Date:
Subject: Re: variant column type
Next
From: John R Pierce
Date:
Subject: Re: variant column type