Re: [SQL] multiple PK with a non UNIQUE field

2005-06-26 Thread davide
if you need a multi column fk don't use the "references" keyword on your create table, instead use the "FOREIGN KEY" keyword for the table, see the "create table" help. so for example (untested) change CREATE TABLE appalto ( cod_op int not null references Opere, cod_co

Re: [SQL] assorted problems with intarray and other GiST contribs.

2005-06-26 Thread Michael Fuhr
On Sun, Jun 26, 2005 at 06:48:42PM +0200, PFC wrote: > > SELECT int_array_aggregate(id) FROM (SELECT id FROM shop.products LIMIT X) > as foo; > > This one works fine if X <= 512 and crashes postgres if X > 512. > ie. if the aggregate accumulates more than 512 values it crashes. I d

Re: [SQL] assorted problems with intarray and other GiST contribs.

2005-06-26 Thread PFC
Thanks for the quick response ! * int_array_aggregate crashes I don't remember this function :) You mean it's not part of intarray contrib ? I thought so ! Sorry ! Then who's responsible for maintenance of it ? int4 nlevel(ltree) - r

Re: [SQL] assorted problems with intarray and other GiST contribs.

2005-06-26 Thread Oleg Bartunov
On Sun, 26 Jun 2005, PFC wrote: Hello ! I'm using postgresql 8.0.1-r2 on gentoo linux. So, here are the problems : * int_array_aggregate crashes I don't remember this function :) * ltree First of all co

[SQL] assorted problems with intarray and other GiST contribs.

2005-06-26 Thread PFC
Hello ! I'm using postgresql 8.0.1-r2 on gentoo linux. So, here are the problems : * int_array_aggregate crashes SELECT int_array_aggregate(id) FROM (SELECT id FROM shop.products LIMIT X) as foo; This one

Re: [SQL] people who buy A, also buy C, D, E

2005-06-26 Thread PFC
The goal of my query is: given a book, what did other people who bought this book also buy? I plan the list the 5 most popular such books. You can use the table listing ordered products directly, for example : table ordered_products: order_id, product_id, quantity SELECT b.produc

Re: [SQL] multiple PK with a non UNIQUE field

2005-06-26 Thread Jim Buttafuoco
if you need a multi column fk don't use the "references" keyword on your create table, instead use the "FOREIGN KEY" keyword for the table, see the "create table" help. so for example (untested) change CREATE TABLE appalto ( cod_op int not null references Opere, cod_co

Re: [SQL] multiple PK with a non UNIQUE field

2005-06-26 Thread Mathieu Arnold
+-le 26/06/2005 16:58 +0200, davide écrivait : | CREATE TABLE appalto ( | cod_op int not null references Opere, | cod_com int not null references Opere, | scadenza date not null, | importoint not null, PRIMARY KEY (cod_op,cod_com) | );

[SQL] multiple PK with a non UNIQUE field

2005-06-26 Thread davide
Sorry, I 'm a beginner of postgres and I found a problem when I was passed from MySQL: I have to create a referential constraint table APPALTO from a table OPERE that as a composed PK(cod_op,cod_com) where cod_op ISN'T unique. in MySQL: CREATE TABLE opere ( cod_op int NOT NULL , cod_co