Re: Fwd: Re: Referencing

Поиск
Список
Период
Сортировка
От lucas@presserv.org
Тема Re: Fwd: Re: Referencing
Дата
Msg-id 20051028130720.jxoth8izb468k44s@www.presserv.org
обсуждение исходный текст
Ответ на Re: Fwd: Re: Referencing  (Daryl Richter <daryl@brandywine.com>)
Ответы Re: Fwd: Re: Referencing
Список pgsql-sql
Quoting Daryl Richter <daryl@brandywine.com>:
> It's hard to say without knowing more precisely what you are trying 
> to model, but I think this push you in the right direction:
>
>   -- This table takes the place of both SEND and BUY
>   create table activity(
>      id          serial primary key,
>      product_id  integer,     --references....
>      value       money
>   );
>
>   create table financial(
>     id          serial primary key,
>     cred_deb    smallint,
>     value       money,
>     activity_id integer references activity
>   );
>
>   create table output(
>     id            serial primary key,
>     client        integer,                 --references clientes,
>     fiscal_number varchar(30),
>     print_date    date,
>     activity_id   integer  references activity
>   );
>
>   create table input(
>     id           serial     primary key,
>     supplier     integer,                       -- references suppliers,
>     employee     varchar(30),
>     activity_id  integer    references activity
>   );
>
> And then you do the following:
>
>   create view buy
>   as
>   select
>       a.id,
>       b.id  as "input_id",
>       a.product_id,
>       a.value
>   from
>         activity a
>   join  input    b on b.activity_id = a.id;
>

Okay, but references between (output/input) and ACTIVITY tables is 1 to N.
OUTPUT/INPUT - 1
to
ACTIVITY - N.
And not N to 1 how the example.
Then the reference field need to be on "ACTIVITY (send/buy)" table.



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

Предыдущее
От: Abhishek
Дата:
Сообщение: Re: combining records from a single table and presenting them as one record
Следующее
От: Muralidharan Ramakrishnan
Дата:
Сообщение: Re: Complex Query - Data from 3 tables simultaneously