Re: concepts?

From: D(dot)C(dot) <coughlandesmond(at)yahoo(dot)fr>
To: <operationsengineer1(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: concepts?
Date: 2005-05-17 08:48:00
Message-ID: f282c986f46187d508e802de421582d3@yahoo.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Le 16 mai 05, à 17:38, <operationsengineer1(at)yahoo(dot)com> a écrit :

>> What am I doing wrong ? :-(
>
> sounds like you still have a cartesian join. you need
> to apply another constraint. from the looks of it,
> you need to constrain the company, too.

OK, now this is one concept I need explaining: do I need to set up
'links' from one table to another when I create the tables? Here is
the 'clients' table of a new db that I've created ...

\d clients
Table "public.clients"
Column | Type | Modifiers
------------------+-----------------------+-----------
client_id | integer | not null
nom | character varying(25) | not null
prenom | character varying(25) | not null
dob | date |
courriel | character varying(25) | not null
numero_rue | numeric | not null
nom_rue | character varying(50) | not null
cp | character varying(6) | not null
ville | character varying(25) | not null
pays | character varying(10) | not null
telephone | character varying(15) | not null
date_inscription | date |
dernier_achat | date |
Indexes:
"clients_pkey" PRIMARY KEY, btree (client_id)
Check constraints:
"clients_check" CHECK (dernier_achat > date_inscription)

As you can see, there is a primary key which is the client_id. Now the
'purchases' table..

\d ventes
Table "public.ventes"
Column | Type | Modifiers
--------------+---------+-----------
vente_number | integer | not null
titre_id | integer | not null
prix_vente | numeric | not null
vendu_a | integer | not null
vendu_le | date | not null
Indexes:
"ventes_pkey" PRIMARY KEY, btree (vente_number)
Check constraints:
"ventes_vendu_le_check" CHECK (vendu_le > '2005-12-31'::date)
Foreign-key constraints:
"ventes_titre_id_fkey" FOREIGN KEY (titre_id) REFERENCES
stock(stock_id)
"ventes_vendu_a_fkey" FOREIGN KEY (vendu_a) REFERENCES
clients(client_id)

Now I have a key 'vendu_a' (which is French for 'sold to') which links
to client_id in the clients table. Is this what has to be done every
time I want to link, or can I use the where clause ?

Thanks.

D.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Buddy Shearer 2005-05-17 14:48:25 BAD SU operator at Postgresql startup (during boot)
Previous Message Razvan Costea-Barlutiu 2005-05-17 04:45:42 Re: Problem with Out-of-resources error?