pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: adrien ruffie <adriennolarsen@hotmail.fr>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Postgrest over foreign data wrapper
Date: Wed, 13 Feb 2019 13:36:01 -0800
Message-ID: <79930a4d-5bc6-aa79-288f-77171bb738ce@aklaver.com> (raw)
In-Reply-To: <VI1P191MB031904C360CDD65B751944CBA9660@VI1P191MB0319.EURP191.PROD.OUTLOOK.COM>
References: <VI1P191MB03195E809F9AA5D644CF67CAA9660@VI1P191MB0319.EURP191.PROD.OUTLOOK.COM>
	<CADK3HHJ-tpiNXAfCaHs9Rcmx=kSW5s796ScxDBBQ1Sjo3httYQ@mail.gmail.com>
	<VI1P191MB031904C360CDD65B751944CBA9660@VI1P191MB0319.EURP191.PROD.OUTLOOK.COM>

On 2/13/19 1:04 PM, adrien ruffie wrote:
>     we have a tricky problem with my colleague.
>     We have to database db1 and db2 linked by a foreign data wrapper
>     connection.
>     1 table "contractline" in db1 and "contract" in db2.
> 
>     We use postgrest in order to request db2 via CURL.
>     But we want to add a link between previous tables.
> 
>     In db2 we have a foreign table ft_contractline
>     example:
> 
>          Column    |           Type           | Collation | Nullable |
>     Default | FDW options | Storage  | Stats target | Description
>     --------------+--------------------------+-----------+----------+---------+-------------+----------+--------------+-------------
>       id           | character varying(1024)  |           | not null |  
>            |             | extended |              |
>       ccode      | text                     |           |          |    
>          |             | extended |              |
>       status       | text                     |           |          |  
>            |             | extended |              |
> 
>     We want to add for example, the following constraint:
>     ALTER TABLE contract ADD CONSTRAINT contractline_ft_contract_fkey
>     FOREIGN KEY (contractid) REFERENCES ft_contractline(ccode);
> 
>     in order to use the following query (via CURL on db2):
>     SELECT c.name <http://c.name;, c.id <http://c.id; FROM contract c
>     JOIN ft_contractline ft_c ON c.id <http://c.id; = ft_c.ccode WHERE
>     c.type = 'business'

You don't need a FK to use the above query, just to enforce referential 
integrity between the tables. Do you want RI between the tables?


> 
>     but we saw, isn't possible to add a foreign key on 'contract' table
>     of db2 to 'ft_contractline' foreign table ...
> 
>     Do you know way to do it ?
> 
>     Thank all and best regards.
> 
>     Adrien
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (7+ messages)  latest in thread

Message-ID: <79930a4d-5bc6-aa79-288f-77171bb738ce@aklaver.com>
Permalink:  ../79930a4d-5bc6-aa79-288f-77171bb738ce@aklaver.com/
Also on:    postgresql.org/message-id/79930a4d-5bc6-aa79-288f-77171bb738ce@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: adrian.klaver@aklaver.com, adriennolarsen@hotmail.fr, pgsql-general@postgresql.org
  Subject: Re: Postgrest over foreign data wrapper
  In-Reply-To: <79930a4d-5bc6-aa79-288f-77171bb738ce@aklaver.com>
  References: <VI1P191MB03195E809F9AA5D644CF67CAA9660@VI1P191MB0319.EURP191.PROD.OUTLOOK.COM> <CADK3HHJ-tpiNXAfCaHs9Rcmx=kSW5s796ScxDBBQ1Sjo3httYQ@mail.gmail.com> <VI1P191MB031904C360CDD65B751944CBA9660@VI1P191MB0319.EURP191.PROD.OUTLOOK.COM> <79930a4d-5bc6-aa79-288f-77171bb738ce@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox