Re: Array of foreign key

2017-12-24 Thread Ken Tanzer
On Sat, Dec 23, 2017 at 11:11 PM, Daevor The Devoted wrote: > > This is an interesting feature you are talking about. However, I'm not > sure I properly understand the use-case(s). Could you perhaps please give > some examples to help me understand? (I don't just mean some SQL code, I > mean an e

Re: Array of foreign key

2017-12-24 Thread Peter J. Holzer
On 2017-12-23 14:40:13 -0500, Melvin Davidson wrote: > On Sat, Dec 23, 2017 at 2:27 PM, Peter J. Holzer wrote: > >If you do not understand something, please ask. > > Your response is inappropriate and offensive. I apologize for my tone. I should have calmed down before replying. I do not apolog

Re: Array of foreign key

2017-12-24 Thread Corey Taylor
On Sun, Dec 24, 2017 at 1:11 AM, Daevor The Devoted wrote: > > Le 23 déc. 2017 20:25, "Peter J. Holzer" a écrit : > > I think the OP wants something like this: > > create table features ( > id serial primary key, > name varchar not null > ); > > create table products ( > id serial pr

Re: Array of foreign key

2017-12-23 Thread Daevor The Devoted
On 23 Dec 2017 9:54 pm, "Thomas Poty" wrote: Good evening all, I have just see all the messages. Thanks for that. First, Peter Holzer has exactly understooden my need. I am à bit disappointed this feature is not implemented. It would be great. Then, I know enum is probably not the best choice b

Re: Array of foreign key

2017-12-23 Thread Thomas Poty
Good evening all, I have just see all the messages. Thanks for that. First, Peter Holzer has exactly understooden my need. I am à bit disappointed this feature is not implemented. It would be great. Then, I know enum is probably not the best choice but it is historic in our database. Like I said

Re: Array of foreign key

2017-12-23 Thread Melvin Davidson
On Sat, Dec 23, 2017 at 2:27 PM, Peter J. Holzer wrote: > On 2017-12-23 13:14:50 -0500, Melvin Davidson wrote: > > On Sat, Dec 23, 2017 at 12:49 PM, Ken Tanzer > wrote: > > > > I thought the OP was asking for this feature ("Support for Array > ELEMENT > > Foreign Keys"): > > > > http

Re: Array of foreign key

2017-12-23 Thread Peter J. Holzer
On 2017-12-23 13:14:50 -0500, Melvin Davidson wrote: > On Sat, Dec 23, 2017 at 12:49 PM, Ken Tanzer wrote: > > I thought the OP was asking for this feature ("Support for Array ELEMENT > Foreign Keys"): > > https://www.postgresql.org/message-id/flat/1343842863. > 5162.4.ca...@grey

Re: Array of foreign key

2017-12-23 Thread Peter J. Holzer
On 2017-12-23 12:24:07 -0500, Melvin Davidson wrote: > On Sat, Dec 23, 2017 at 12:09 PM, Peter J. Holzer wrote: > >...Is there a way to > >enforce foreign key constraints on the members of an array? > >At insert time you can check with a trigger of course, and maybe there > >is a way to do it in a

Re: Array of foreign key

2017-12-23 Thread Melvin Davidson
On Sat, Dec 23, 2017 at 12:49 PM, Ken Tanzer wrote: > >> I don't think you understand how Foreign Key constraints work in >> PostgreSQL. >> PostgreSQL will prevent any insert where the value of a column is not >> within the FK table. >> So you DO NOT need a check constraint or trigger. >> >> > I

Re: Array of foreign key

2017-12-23 Thread Ken Tanzer
> > > I don't think you understand how Foreign Key constraints work in > PostgreSQL. > PostgreSQL will prevent any insert where the value of a column is not > within the FK table. > So you DO NOT need a check constraint or trigger. > > I thought the OP was asking for this feature ("Support for Arra

Re: Array of foreign key

2017-12-23 Thread Melvin Davidson
On Sat, Dec 23, 2017 at 12:09 PM, Peter J. Holzer wrote: > On 2017-12-22 22:05:18 +0100, Andreas Kretschmer wrote: > > > > >Please DO NOT use EMUMs. That is old. They are hard to maintain. I > > >also know from experience that MySql does not check integrity of > > >enums. It's possible you can ha

Re: Array of foreign key

2017-12-23 Thread Peter J. Holzer
On 2017-12-22 22:05:18 +0100, Andreas Kretschmer wrote: > > >Please DO NOT use EMUMs. That is old. They are hard to maintain. I > >also know from experience that MySql does not check integrity of > >enums. It's possible you can have data in a MySql table column that > >is not valid for current enu

Re: Array of foreign key

2017-12-22 Thread Andreas Kretschmer
>Please DO NOT use EMUMs. That is old. They are hard to maintain. I also >know from experience that MySql does not check >integrity of enums. It's possible you can have data in a MySql table >column >that is not valid for current enum constraint on that column. >EG: When porting, the enum for a co

Re: Array of foreign key

2017-12-22 Thread Melvin Davidson
On Fri, Dec 22, 2017 at 3:40 PM, Thomas Poty wrote: > Actually, We are migrating from Mysql to postgresql and we have to replace > sets of Mysql. The migration we will be done in 2 steps: First, in a like > for like way. Second step will be using postgresql powerfulness > > I think the most like

Re: Array of foreign key

2017-12-22 Thread Thomas Poty
Actually, We are migrating from Mysql to postgresql and we have to replace sets of Mysql. The migration we will be done in 2 steps: First, in a like for like way. Second step will be using postgresql powerfulness I think the most like for like way to migrate sets is using enum array. Thank you A

Re: Array of foreign key

2017-12-22 Thread Andreas Kretschmer
On 22 December 2017 20:02:43 CET, Thomas Poty wrote: >Hello all, > >I use postgresql 9.5 and I am looking for way to have a column which is >an >array of a foreign key. If what I read is correct it is currently not >possible... Have you any idea how to implement this feature in a safe >way Normal

Array of foreign key

2017-12-22 Thread Thomas Poty
Hello all, I use postgresql 9.5 and I am looking for way to have a column which is an array of a foreign key. If what I read is correct it is currently not possible... Have you any idea how to implement this feature in a safe way (foreign key constraints) ? I don't have another idea to have a enum