Re: Need schema design advice

From: Ben Chobot <bench(at)silentmedia(dot)com>
To: Martin Gainty <mgainty(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Need schema design advice
Date: 2008-10-13 01:10:05
Message-ID: 01074800-FA61-403A-A9D7-FD645A2E8958@silentmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Oct 12, 2008, at 5:51 PM, Martin Gainty wrote:

> could you provide a brief explanation of EAV ?

Instead of:

create table vehicles
(
kind text primary key,
wheels int
);
insert into vehicles (kind, wheels) values ('car',4);
insert into vehicles (kind, wheels) values ('bike',2);

create table boats
(
kind text primary key,
displacement int
);
insert into boats (kind,displacement) values ('small boat',1000);
insert into boats (kind,displacement) values ('big boat',300000);

... in an EAV model you would do something like:

create table eav
(
kind text primary key,
attr text,
value text
);
insert into eav (kind, attr, value) values ('car','wheels','4');
insert into eav (kind, attr, value) values ('bike','wheels','2');
insert into eav (kind, attr, value) values ('small
boat','displacement','1000');
insert into eav (kind, attr, value) values ('big
boat','displacement','300000');

>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo E. De León Plicet 2008-10-13 02:16:04 Re: Need schema design advice
Previous Message justin 2008-10-13 00:57:59 Re: Chart of Accounts