Fwd: Re: Referencing

From: lucas(at)presserv(dot)org
To: pgsql-sql(at)postgresql(dot)org
Subject: Fwd: Re: Referencing
Date: 2005-10-28 13:59:08
Message-ID: 20051028105908.onaegu44ynnog8os@www.presserv.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Ok,
But the problem is becouse the "buy" and "send" tables referencing with other
father table, wich is different.
I shoud not create a spent table to put the "buy" and "send" values
becouse the
entire database is more complex than it. look:

create table output(
id serial primary key,
client integer references clientes,
fiscal_number varchar(30),
print_date date,
...
);
create table SEND(
id serial primary key,
output integer references input,
product_id integer,--references....
value money
);
create table input(
id serial primary key,
supplier integer references suppliers,
employee varchar(30),
...
);
create table BUY(
id serial primary key,
input integer references input,
product_id integer,--references....
value money
);

---and---

create table financial(
id serial primary key,
cred_deb smallint,
value money,
references integer references ???, --<<-HERE IS THE PROBLEM, it will
reference
to buy OR send table
);

How looked, the "buy" and the "send" table is identical except the father
references (INPUT or OUTPUT)... Then I shoud not create ONE table (spent) wich
has these informations.
And now my question: Is there a way to references (financial) with two
diferents
tables in the some row? Or need I create two diferents rows???

Thanks. (sorry for my english).

Quoting William Leite Araújo <william(dot)bh(at)gmail(dot)com>:

> Maybe you need is a table "spent" that has all fields of
> buy/send and one more, a flag to say is the field is a "buy" or a
> "send".
>
>
> 2005/10/27, lucas(at)presserv(dot)org <lucas(at)presserv(dot)org>:
>> Hi.
>> Is there a way to references dynamic tables? I.E:
>> I have a table called "buy" that create some records in "financial"
>> table, but
>> there is other table called "send" that create other records in "financial".
>> "Financial" table have the moneys' movements and needs to be
>> referenciable by
>> "buy or send". IE:
>> create table buy (
>> id serial primary key,
>> product_id integer,--references....
>> value money
>> );
>> create table send (
>> id serial primary key,
>> product_id integer, --references...
>> value money
>> );
>> create table financial(
>> id serial primary key,
>> cred_deb smallint,
>> value money,
>> references integer, --<<-HERE IS THE PROBLEM, it will reference to
>> buy OR send
>> table
>> );
>> Well, I dont know if I was clean.
>> Thank you.
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 1: if posting/reading through Usenet, please send an appropriate
>> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>> message can get through to the mailing list cleanly
>>
>
>
> --
> William Leite Araújo
>

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Daryl Richter 2005-10-28 15:40:17 Re: Fwd: Re: Referencing
Previous Message Andrew Sullivan 2005-10-28 13:34:30 Re: why vacuum