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] UNNEST result order vs Array data

2013-06-20 Thread Vik Fearing
On 06/20/2013 12:40 PM, gmb wrote: > Hi all > I just want to confirm something regarding UNNEST function used with arrays. > I cannot see that it is specifically mentioned in the documentation , but > maybe because it is obvious. > > Is the order of the result guaranteed to be the order of the arra

Re: [SQL] UNNEST result order vs Array data

2013-06-20 Thread Vik Fearing
On 06/20/2013 01:00 PM, gmb wrote: > Can you please give me an example of how the order is specified? > I want the result of the UNNEST to be in the order of the array field > E.g. > SELECT UNNEST ( ARRAY[ 'abc' , 'ggh' , '12aa' , '444f' ] ); > Should always return: > > unnest > > abc >

Re: [SQL] Unquoted column names fold to lower case

2013-07-03 Thread Vik Fearing
On 07/03/2013 11:12 AM, Dev Kumkar wrote: > All unquoted identifiers are assumed by PostgreSQL to be lower case by > default. This means > - SELECT MY_COLUMN FROM my_table > - SELECT my_column FROM my_table > - SELECT my_column as MY_COLUMN FROM my_table > All refer to my_column and has column name

Re: [SQL] table constraint on two columns

2013-07-22 Thread Vik Fearing
On 07/22/2013 04:05 PM, ldrlj1 wrote: > Postgres 9.2.4. > > I have two columns, approved and comments. Approved is a boolean with no > default value and comments is a character varying (255) and nullable. > > I am trying to create a constraint that will not allow a row to be entered > if approved i