From: | Pushpendra Singh Thakur <thakur(at)corexprts(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Cc: | wchouse(at)bellsouth(dot)net |
Subject: | Re: optional reference |
Date: | 2010-01-24 10:00:53 |
Message-ID: | d6a413081001240200p34710c25w30683c53fbf14049@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
create a third table to store your relations only.
Relation table C
create table C(
a_col1 char(8) references a(column_1),
b_col1 char(8) references b(column_1))
Both the tables will be independent (a and b) i mean they will not have any
direct relations.
2010/1/24 bill house <wchouse(at)bellsouth(dot)net>
> Hello,
>
> What is a technique to reference some (but not all) rows from table a to a
> row in table b?
>
> For example:
>
> ---------------------------
>
> DROP TABLE a;
> DROP TABLE b;
>
>
> CREATE TABLE a (
> column_1 character(8),
> column_2 character(2),
> column_3 character(40)
> );
>
> INSERT INTO a VALUES
> ('20901234', '01', 'This is a the first row'),
> ('20901234', '01', 'This is the second row'),
> ('20901234', '01', 'This is the third row'),
> ('20901235', '01', 'This is the fourth row'),
> ('20901236', '01', 'This is the fifth row'),
> ('20901236', '01', 'This is the sixth row'),
> ('20901237', '01', 'This is the seventh row'),
> ('20901238', '01', 'This is the eighth row');
>
> CREATE TABLE b (
> column_1 character(8),
> column_2 character(2),
> column_3 character(40),
> PRIMARY KEY (column_1, column_2)
> );
>
> INSERT INTO b VALUES
> ('20901234', '01', 'Footnote #1'),
> ('20901234', '02', 'other stuff'),
> ('20901237', '01', 'Footnote #2');
>
> --------------------------------------
>
> Table a rows 1, 2 & 3 should point to table b row 1.
>
> Table a row 7 should point to table b row 3.
>
> Any guidance would be appreciated.
>
> Thanks,
>
> Bill House
>
>
>
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>
--
Pushpendra Singh Thakur
COREEXPERTS Technologies Private Limited
Business Process Automation & IT Support Services
http://www.corexprts.com
Phone - 91-761-4070036
Fax - 91-761-4010530
SMS - 91-799-66554
From | Date | Subject | |
---|---|---|---|
Next Message | Rikard Bosnjakovic | 2010-01-24 10:08:48 | Comparing times to "now + 45 seconds" |
Previous Message | Andreas Kretschmer | 2010-01-24 07:45:38 | Re: 8.5 beta manual |