Re: foreign keys on multiple parent table

2023-06-23 Thread Lorusso Domenico
ehm.. I'm not sure I understood correctly :-D in which way do you generate column? Il giorno mer 21 giu 2023 alle ore 09:47 Dominique Devienne < ddevie...@gmail.com> ha scritto: > On Tue, Jun 20, 2023 at 10:47 PM Lorusso Domenico > wrote: > >> Could work, but is there a way to set a reference ke

Re: foreign keys on multiple parent table

2023-06-23 Thread Lorusso Domenico
Thank you Les for the link, it's a very good example, unfortunately my need is more applicative (we need to store user of application, not the on pg, proces who start etc), but for sure I can take advantage of it. Il giorno mar 20 giu 2023 alle ore 23:01 Les ha scritto: > . >> > > >> From progra

Re: foreign keys on multiple parent table

2023-06-21 Thread Dominique Devienne
On Tue, Jun 20, 2023 at 10:47 PM Lorusso Domenico wrote: > Could work, but is there a way to set a reference key over the uuid of all > the tables? > Yes, it's possible. We do it. There are several ways to emulate what I call "polymorphic" FKs. All approaches have pros and cons, the one we use

Re: foreign keys on multiple parent table

2023-06-20 Thread Les
> > . > > From programming point of view and also to reduce the number of objects in > DB could be convinient create just an audit table with a structure like: > >- auditi id >- reference_uuid (the key of the main table) >- table_name >- list of audit data > > Could work, but is t

Re: foreign keys on multiple parent table

2023-06-20 Thread David G. Johnston
On Tuesday, June 20, 2023, Lorusso Domenico wrote: > > Could work, but is there a way to set a reference key over the uuid of all > the tables? > A foreign key in PostgreSQL is between two, and only two, tables. The PK side of which must be uniquely constrained. You can write custom triggers i

foreign keys on multiple parent table

2023-06-20 Thread Lorusso Domenico
Hello guys, I've many tables representing as many concepts. For each record of each table I need to store extra information (think to audit information, but more complex than a simple text) The relation is 1:N, for each record there could be many audit records. >From programming point of view an