Обсуждение: Non-atomic structures instead of arrays

Поиск
Список
Период
Сортировка

Non-atomic structures instead of arrays

От
"Michael D. Klatt"
Дата:
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?


Re: Non-atomic structures instead of arrays

От
"Josh Berkus"
Дата:
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