pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alban Hertroys <haramrae@gmail.com>
To: Thomas Kellerer <shammat@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: index unique
Date: Thu, 10 Jun 2021 22:32:58 +0200
Message-ID: <5D617659-7B20-468C-9C40-51BFDD7D5767@gmail.com> (raw)
In-Reply-To: <99cf7fa9-9788-c576-cb49-3aec780168f6@gmx.net>
References: <CADX_1aYbmMHK4wqHd=p_fGsNMOgEB7oe0BY_9ZTWv3e-TQx+oA@mail.gmail.com>
	<99cf7fa9-9788-c576-cb49-3aec780168f6@gmx.net>


> On 8 Jun 2021, at 22:50, Thomas Kellerer <shammat@gmx.net> wrote:
> 
> Marc Millas schrieb am 03.06.2021 um 22:51:
>> on a table we need a primary key and to get a unique combinaison, we need 3 columns of that table:
>> 1 of type integer,
>> 1 of type text,
>> 1 of type geometry
>> 
> 
> How do you define the "uniqueness" of the geometry?

That is actually the big question here. Multiple “unique” geometries can specify the same geometry!

A geom as simple as a line from (0,0) - (1,0) can just as easily be specified as (1,0) - (0,0). That’s the simplest case, and one could argue that the point of origin is different, but the next example would be a triangle starting at the same origin but traversed in different directions. It gets harder the more vertices a polygon has.

I would argue that a geometry type is ill-suited as a primary key column candidate.

Now, of course, the OP could have a case where their geometries are guaranteed to be unique regardless, but they’d better make sure before adding them to the PK.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.






view thread (16+ messages)  latest in thread

Message-ID: <5D617659-7B20-468C-9C40-51BFDD7D5767@gmail.com>
Permalink:  ../5D617659-7B20-468C-9C40-51BFDD7D5767@gmail.com/
Also on:    postgresql.org/message-id/5D617659-7B20-468C-9C40-51BFDD7D5767@gmail.com

 · 

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: haramrae@gmail.com, shammat@gmx.net
  Subject: Re: index unique
  In-Reply-To: <5D617659-7B20-468C-9C40-51BFDD7D5767@gmail.com>
  References: <CADX_1aYbmMHK4wqHd=p_fGsNMOgEB7oe0BY_9ZTWv3e-TQx+oA@mail.gmail.com> <99cf7fa9-9788-c576-cb49-3aec780168f6@gmx.net> <5D617659-7B20-468C-9C40-51BFDD7D5767@gmail.com>

* 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