Re: DB design: How to store object properties?

From: "Douglas McNaught" <doug(at)mcnaught(dot)org>
To: "Maxim Khitrov" <mkhitrov(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: DB design: How to store object properties?
Date: 2008-02-17 23:09:08
Message-ID: 5ded07e00802171509w3cc18663l6d4b6509a36e5b4d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/17/08, Maxim Khitrov <mkhitrov(at)gmail(dot)com> wrote:
> The simplest design would be to create two tables, one for nodes
> another for edges, and create a column for every possible property.
> This, however, is huge waste of space, since there will not be a
> single node or edge that will make use of all the defined properties.
> There may be hundreds of properties, but each node may use ten on
> average. That's the question - how do you represent this information
> in the database in a space-efficient manner. We still have to be able
> to search for specific nodes given their properties. For example –
> find all the nodes located within radius z of coordinate x,y. PostGIS
> will handle the special bit, but there has to be an efficient way of
> accessing this information/property for each node that has it.

If you have a lot of columns but most of them are NULL for a given
record, the tuple size won't actually be that big. PG stores a bitmap
in each tuple telling which columns are NULL, and then only stores the
non-NULL column vales. So this approach may end up being reasonably
efficient for you.

-Doug

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Staubo 2008-02-17 23:12:27 Re: DB design: How to store object properties?
Previous Message Chris 2008-02-17 22:57:16 Re: using DROP in a transaction