Re: Schema design question

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Ben <bench(at)silentmedia(dot)com>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Schema design question
Date: 2008-03-28 17:51:10
Message-ID: 47ED300E.2090302@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ben wrote:

> create table attrs (id serial primary key, name text);
> create table obj (id serial primary key, name text);
> create table att (oid int references obj.id, aid int references attrs.id,
> value_int int, value_float float, value_text text, value_bool bool,
> value_date date);

I think I saw mention here of the DB using a bitmap in the tuple header
to avoid storing NULL fields.

If that's the case (don't trust my word on it), then combined with a
CHECK constraint that ensures that at most one of your typed fields may
be not null, this option might at least prove to be the most efficient.
However, it won't be fun to query.

Storing them all as text won't be much fun to query, which I'd consider
another argument for the many-types tuple. '2' > '11' = 't', '002' <>
'2', etc.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2008-03-28 17:51:31 Re: PL/pgSQL Documentation, biblio, etc
Previous Message Teemu Juntunen, e-ngine 2008-03-28 17:48:12 VS: Delete after trigger fixing the key of row numbers