pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas <maps.on@gmx.net>
To: Fernando Hevia <fhevia@ip-tel.com.ar>
Cc: pgsql-sql@postgresql.org
Subject: Re: design of tables for sparse data
Date: Tue, 13 Nov 2007 03:10:44 +0100
Message-ID: <473907A4.4060400@gmx.net> (raw)
In-Reply-To: <0c8501c82575$bd3cf830$8f01010a@iptel.com.ar>
References: <0c8501c82575$bd3cf830$8f01010a@iptel.com.ar>

Fernando Hevia schrieb:
>> --- Andreas Wrote: ---
>> ...
>>
>> MY QUESTIONS:
>>     
>
> Your questions have a strong "home-work" look. 
>   

Yes but I didn't want to bother everyone with my project's details.
It's more like a CRM.
Up until now I just tried to manage somehow with the sql basics and now 
I like to get better.
One interesting thing are crosstabs because I could use them in the 
reporting module.

I used this schoolbook scenario because it's such an easy example.   ;)


>> 1)   How would I SELECT a report that looks like the first version of
>> the pupil table out of the 3 table design?
>> There must be a nontrivial SELECT statement that combines all 3 tables.
>>     
>
> You should check out the JOIN clause in select statements. 
> Simple example:
>
> Select t1.col1, t2.col1, t2.col2
> >from t1 inner join t2 b on (t1.col1 = t2.col1)
>   

A simple JOIN won't do the trick.
That would give me something like:
(42, Frank Miller,  Maths)
(42, Frank Miller,  English)
(42, Frank Miller,  Sports)
(43, Suzy Smith,  Maths)
(43, Suzy Smith,  History)

But I want it turned around and a bit interpreted like:

Column heads = (ID, Name, Maths, English, Sports, History)
(42, Frank Miller, yes, yes, yes, no )
(43, Suzy Smith, yes, no, no, yes)


Regards
Andreas




view thread (4+ messages)  latest in thread

Message-ID: <473907A4.4060400@gmx.net>
Permalink:  ../473907A4.4060400@gmx.net/
Also on:    postgresql.org/message-id/473907A4.4060400@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: maps.on@gmx.net, fhevia@ip-tel.com.ar
  Subject: Re: design of tables for sparse data
  In-Reply-To: <473907A4.4060400@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox