Re: DOMAIN/composite TYPE vs. base TYPE

From: "Gavan Schneider" <list(dot)pg(dot)gavan(at)pendari(dot)org>
To: "Joe Abbate" <jma(at)freedomcircle(dot)com>
Cc: "Rob Sargent" <robjsargent(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: DOMAIN/composite TYPE vs. base TYPE
Date: 2020-09-28 21:52:14
Message-ID: BF23556F-6785-469D-894D-F3C356654DFE@pendari.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 29 Sep 2020, at 7:31, Joe Abbate wrote:

> Hello Rob,
>
> On 28/9/20 17:17, Rob Sargent wrote:
>> just record all three fields (day, month, year) with nulls and do the
>> to-date as needed.
>
> That is not sufficient. An earlier implementation had something like
> a CHAR(8) to record YYYYMMDD, but how can you indicate, for example,
> an issue date of a bimonthly magazine, say July-Aug 2020? We can
> store 2020-07-01 in the DATE attribute, but we need another attribute
> to indicate it's really two months. Also, by storing three separate
> columns, you loose the beauty of the PG DATE abstraction.
>
This is only a partial “fix” and goes nowhere near solving the full
wrapper/abstraction problem…

Consider expressing all the component fields as a range. This allows you
the ability to be a precise as you need and still have the benefits of
well defined comparison functions.

Regards
Gavan Schneider
——
Gavan Schneider, Sodwalls, NSW, Australia
Explanations exist; they have existed for all time; there is always a
well-known solution to every human problem — neat, plausible, and
wrong. The ancients, in the case at bar, laid the blame upon the gods:
sometimes they were remote and surly, and sometimes they were kind. In
the Middle Ages lesser powers took a hand in the matter, and so one
reads of works of art inspired by Our Lady, by the Blessed Saints, by
the souls of the departed, and even by the devil. H. L. Mencken, 1920

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Abbate 2020-09-28 21:58:19 Re: DOMAIN/composite TYPE vs. base TYPE
Previous Message Ron 2020-09-28 21:49:55 Re: DOMAIN/composite TYPE vs. base TYPE