Re: [SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Igor Neyman
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Wolfgang Keller > Sent: Tuesday, April 30, 2013 2:19 PM > To: pgsql-sql@postgresql.org > Subject: Re: [SQL] Correct implementation of 1:n relationship with n>0? > > > It hi

Re: [SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Wolfgang Keller
> (there is nothing wrong in getting your hands dirty with pl/pgsql btw) The point is that I would have expected that problem to be solved within the past four decades since relational databases have been invented. Or at least in the past two decades since PostgreSQL has been developed. >;-> Aft

Re: [SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Wolfgang Keller
> It hit me today that a 1:n relationship can't be implemented just by a > single foreign key constraint if n>0. I must have been sleeping very > deeply not to notice this. > > E.g. if there is a table "list" and another table "list_item" and the > relationship can be described as "every list has

Re: [SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Vik Fearing
On 04/30/2013 04:39 PM, Wolfgang Keller wrote: > It hit me today that a 1:n relationship can't be implemented just by a > single foreign key constraint if n>0. I must have been sleeping very > deeply not to notice this. > > E.g. if there is a table "list" and another table "list_item" and the > rel

Re: [SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Misa Simic
2013/4/30 Anton Gavazuk > Hi, > > Can you explain what you are trying to achieve because it's not clear... > > There are 2 types of relationships which might be used in your case: > > 1) unidirectional relationship from list_item to list through foreign > key on list > 2) bidirectional relationsh

Re: [SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Anton Gavazuk
Hi, Can you explain what you are trying to achieve because it's not clear... There are 2 types of relationships which might be used in your case: 1) unidirectional relationship from list_item to list through foreign key on list 2) bidirectional relationship implemented through join table which c

Re: [SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Misa Simic
2013/4/30 Wolfgang Keller > It hit me today that a 1:n relationship can't be implemented just by a > single foreign key constraint if n>0. I must have been sleeping very > deeply not to notice this. > > E.g. if there is a table "list" and another table "list_item" and the > relationship can be de

Re: [SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Achilleas Mantzios
On Ôñé 30 Áðñ 2013 16:39:05 Wolfgang Keller wrote: > It hit me today that a 1:n relationship can't be implemented just by a > single foreign key constraint if n>0. I must have been sleeping very > deeply not to notice this. > > E.g. if there is a table "list" and another table "list_item" and the

[SQL] Correct implementation of 1:n relationship with n>0?

2013-04-30 Thread Wolfgang Keller
It hit me today that a 1:n relationship can't be implemented just by a single foreign key constraint if n>0. I must have been sleeping very deeply not to notice this. E.g. if there is a table "list" and another table "list_item" and the relationship can be described as "every list has at least one