Re: Non-atomic structures instead of arrays - Mailing list pgsql-novice

From Josh Berkus
Subject Re: Non-atomic structures instead of arrays
Date
Msg-id web-151245@davinci.ethosmedia.com
Whole thread Raw
In response to Non-atomic structures instead of arrays  ("Michael D. Klatt" <mdklatt@ou.edu>)
List pgsql-novice
Michael,

> The documentation implies that you can have a non-atomic field other
> than a
> simple array, perhaps something like a C structure of different
> types.  Is
> this possible, and if so, how?

First off, you need to evaluate your reasons for wanting an non-atomic
field.  As you may know, non-atomic fields violate relational integrity
and lead to development, maintainence, and normalization problems.
Also, it is nearly impossible to index them effectively, resulting in
poor performance.

Frankly, I have yet to hear a case for a custom non-atomic field that
was not better solved by seperating the data in to several fields of
different datatypes.

That being said, the way you create a non-atomic field is by creating a
custom data type.  This is no simple task.  See:

http://www.postgresql.org/idocs/index.php?sql-createtype.html

Please note that you will have to write functions for input, display,
and transmission of this custom data type, as well as manually defining
any operators (+, ||, etc.) that you want to use with the custom data
type.

-Josh Berkus



______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problem with createdb & case (7.1.3)
Next
From: "Brett W. McCoy"
Date:
Subject: Re: Connect to pg via tcpip