Re: concepts?

Поиск
Список
Период
Сортировка
От D.C.
Тема Re: concepts?
Дата
Msg-id f282c986f46187d508e802de421582d3@yahoo.fr
обсуждение исходный текст
Ответ на Re: concepts?  (<operationsengineer1@yahoo.com>)
Список pgsql-novice
Le 16 mai 05, à 17:38, <operationsengineer1@yahoo.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.

В списке pgsql-novice по дате отправления:

Предыдущее
От: Razvan Costea-Barlutiu
Дата:
Сообщение: Re: Problem with Out-of-resources error?
Следующее
От: "Hal Shearer"
Дата:
Сообщение: BAD SU operator at Postgresql startup (during boot)