Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-02-04 Thread Alexandre Leclerc
On Fri, 4 Feb 2005 12:48:43 -0500, Merlin Moncure <[EMAIL PROTECTED]> wrote: > > Alexandre Leclerc wrote: > > Sorry for jumping in on this thread so late -- I haven't been able to > > select * from crosstab( > >'select product_id, department_id, req_time > > from product_department_time ord

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-02-04 Thread Merlin Moncure
> Alexandre Leclerc wrote: > Sorry for jumping in on this thread so late -- I haven't been able to > select * from crosstab( >'select product_id, department_id, req_time > from product_department_time order by 1', >'select ''A'' union all select ''C'' union all select ''D''' > ) as (pro

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-28 Thread Dawid Kuroczko
On Fri, 28 Jan 2005 10:24:37 -0800, Joe Conway <[EMAIL PROTECTED]> wrote: > Alexandre Leclerc wrote: > > I'm a little bit confused on how to install this contirb. I know my > > contrib package is installed, but I don't know how to make it work in > > postgresql. (Using 7.4.5-1mdk on Mandrake Linux.

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-28 Thread Alexandre Leclerc
On Fri, 28 Jan 2005 10:24:37 -0800, Joe Conway <[EMAIL PROTECTED]> wrote: > Alexandre Leclerc wrote: > > I'm a little bit confused on how to install this contirb. I know my > > contrib package is installed, but I don't know how to make it work in > > postgresql. (Using 7.4.5-1mdk on Mandrake Linux.

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-28 Thread Joe Conway
Alexandre Leclerc wrote: I'm a little bit confused on how to install this contirb. I know my contrib package is installed, but I don't know how to make it work in postgresql. (Using 7.4.5-1mdk on Mandrake Linux.) Find the file tablefunc.sql and redirect it into your database, e.g. psql mydatabase <

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-28 Thread Alexandre Leclerc
On Fri, 28 Jan 2005 08:34:27 -0800, Joe Conway <[EMAIL PROTECTED]> wrote: > Alexandre Leclerc wrote: > >Here a normal listing of design.product_department_time: > > product_id | department_id | req_time > >+---+-- > >906 | A |

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-28 Thread Joe Conway
Alexandre Leclerc wrote: Here a normal listing of design.product_department_time: product_id | department_id | req_time +---+-- 906 | A | 3000 906 | C | 3000 906 | D | 1935 907 | A

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-28 Thread Alexandre Leclerc
On Fri, 28 Jan 2005 09:07:59 +0100, Dawid Kuroczko <[EMAIL PROTECTED]> wrote: > On Thu, 27 Jan 2005 12:43:56 -0500, Alexandre Leclerc > <[EMAIL PROTECTED]> wrote: > > On Thu, 27 Jan 2005 17:27:40 +0100, Dawid Kuroczko <[EMAIL PROTECTED]> > > wrote: > > > On Thu, 27 Jan 2005 10:23:34 -0500, Alexand

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-28 Thread Dawid Kuroczko
On Thu, 27 Jan 2005 12:43:56 -0500, Alexandre Leclerc <[EMAIL PROTECTED]> wrote: > On Thu, 27 Jan 2005 17:27:40 +0100, Dawid Kuroczko <[EMAIL PROTECTED]> wrote: > > On Thu, 27 Jan 2005 10:23:34 -0500, Alexandre Leclerc > > <[EMAIL PROTECTED]> wrote: > > > Here a normal listing of design.product_dep

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Alexandre Leclerc
On Thu, 27 Jan 2005 16:05:09 -0500, Merlin Moncure <[EMAIL PROTECTED]> wrote: > Alexandre wrote: > > like I'm doing right now, that "de-normalizing" in an array is the way > > to go. > > Only sometimes. Looping application code is another tactic. There may > be other things to do as well that do

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Merlin Moncure
Alexandre wrote: > > > > > Right. I expanding departments into columns is basically a dead end. > > First of all, SQL is not really designed to do this, and second of all > > (comments continued below) > > Ok, I got it. The basic message is to avoid making columns out of rows yes. This is wrong

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Alexandre Leclerc
On Thu, 27 Jan 2005 13:02:48 -0500, Merlin Moncure <[EMAIL PROTECTED]> wrote: > Alexandre wrote: > > On Thu, 27 Jan 2005 10:44:45 -0500, Merlin Moncure > > <[EMAIL PROTECTED]> wrote: > > > Alexandre wrote: > > > Let's start with the normalized result set. > > > > > > product_id | department_id

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Merlin Moncure
Alexandre wrote: > On Thu, 27 Jan 2005 10:44:45 -0500, Merlin Moncure > <[EMAIL PROTECTED]> wrote: > > Alexandre wrote: > > ok, you have a couple of different options here. The first thing that > > jumps out at me is to use arrays to cheat using arrays. > > Let's start with the normalized result

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Alexandre Leclerc
On Thu, 27 Jan 2005 10:44:45 -0500, Merlin Moncure <[EMAIL PROTECTED]> wrote: > Alexandre wrote: > > Here a normal listing of design.product_department_time: > > product_id | department_id | req_time > > +---+-- > > 906 | A | 3000 > >

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Alexandre Leclerc
On Thu, 27 Jan 2005 17:27:40 +0100, Dawid Kuroczko <[EMAIL PROTECTED]> wrote: > On Thu, 27 Jan 2005 10:23:34 -0500, Alexandre Leclerc > <[EMAIL PROTECTED]> wrote: > > Here a normal listing of design.product_department_time: > > product_id | department_id | req_time > > +---

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Christopher Kings-Lynne
Unfortunately we will need a rowtype with all the departaments: CREATE DOMAIN departaments AS (a int, b int, c int, d int, ...); I think you mean CREATE TYPE departments... Chris ---(end of broadcast)--- TIP 2: you can get off all lists at once with t

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Dawid Kuroczko
On Thu, 27 Jan 2005 10:23:34 -0500, Alexandre Leclerc <[EMAIL PROTECTED]> wrote: > Here a normal listing of design.product_department_time: > product_id | department_id | req_time > +---+-- > 906 | A | 3000 > 906 | C |

Re: [PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Merlin Moncure
Alexandre wrote: > Here a normal listing of design.product_department_time: > product_id | department_id | req_time > +---+-- > 906 | A | 3000 > 906 | C | 3000 > 906 | D | 1935 > 907 | A

[PERFORM] Flattening a kind of 'dynamic' table

2005-01-27 Thread Alexandre Leclerc
Good morning, I have a table that links two tables and I need to flatten one. (Please, if I'm just not in the good forum for this, tell me. This is a performance issue for me, but you might consider this as an SQL question. Feel free to direct me at the good mailling-list.) design.products ---> d