pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Lorusso Domenico <domenico.l76@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Composite type: Primary Key and validation
Date: Mon, 05 Jun 2023 16:02:12 +0200
Message-ID: <ae41cf7917a17d8399478035e98c65ba91b35e9f.camel@cybertec.at> (raw)
In-Reply-To: <CAJMpnG44dti-iEai5d3=XUt=eV27dgBeZd2AhKvisMXR33HWYg@mail.gmail.com>
References: <CAJMpnG44dti-iEai5d3=XUt=eV27dgBeZd2AhKvisMXR33HWYg@mail.gmail.com>

On Mon, 2023-06-05 at 11:49 +0200, Lorusso Domenico wrote:
> I've a couple of questions about composite type.
> Suppose this composite type:
> CREATE TYPE my_type AS (
>     user_ts_start My_start_timestamp,
>     user_ts_end My_end_timestamp,
>     db_ts_start My_start_timestamp,
>     db_ts_end My_end_timestamp,
>     audit_record jsonb
> );
> My_start_timestamp is a domain of timestamp with default as now().
> My_end_timestamp is a domain of timestamp with default as infinite
> 
>    1. May I use user_ts_start and/or db_ts_start has part of Primary Key of a table that contains a field of my_type?
>    2. to add an overall check constraint on the entire composite type, could be a valid
>       approach to create a domain based on my_type and add a custom function to validate it? (check_my_type(VALUE)).
>       In this way I've a dominan of composite type that contain others domain... what do you think?

Avoid using composite types as data types for a table column.
It adds complexity for no clear gain.

Yours,
Laurenz Albe





view thread (11+ messages)  latest in thread

Message-ID: <ae41cf7917a17d8399478035e98c65ba91b35e9f.camel@cybertec.at>
Permalink:  ../ae41cf7917a17d8399478035e98c65ba91b35e9f.camel@cybertec.at/
Also on:    postgresql.org/message-id/ae41cf7917a17d8399478035e98c65ba91b35e9f.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, domenico.l76@gmail.com
  Subject: Re: Composite type: Primary Key and validation
  In-Reply-To: <ae41cf7917a17d8399478035e98c65ba91b35e9f.camel@cybertec.at>
  References: <CAJMpnG44dti-iEai5d3=XUt=eV27dgBeZd2AhKvisMXR33HWYg@mail.gmail.com> <ae41cf7917a17d8399478035e98c65ba91b35e9f.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox