Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gu2CR-0002J0-J1 for pgsql-general@arkaria.postgresql.org; Wed, 13 Feb 2019 21:36:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gu2CP-0004Ra-VJ for pgsql-general@arkaria.postgresql.org; Wed, 13 Feb 2019 21:36:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gu2CO-0004RS-7l for pgsql-general@lists.postgresql.org; Wed, 13 Feb 2019 21:36:09 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gu2CK-0002Mh-JP for pgsql-general@postgresql.org; Wed, 13 Feb 2019 21:36:06 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 72A5F24399; Wed, 13 Feb 2019 16:36:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 13 Feb 2019 16:36:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=A X2gqGQ4A02JdwXsy6unNN0txHs2f3MLIbUqVnDhzzs=; b=aR5Hhs/D9d6i9Xqry 9PZq0p3Kc7/n+BuyNOB4wams4MzUSmefOmLrF1niTFw8h/CjnVgK4Z6S4+zZOmGU PlbNHXpnasad/OpwHTE4N9XuymL0JaJrRrbf+VpFK//V03eFWqn4p+CzjkwDZuL3 bw7Nu8nZOu3KSCz/FwuYQwon8cuJ2qQ9Oigda9E53sO4W91m4VdjQsETT3Zhiorx CFIJUMFF5vyeo716u43XQz/Wz4s149JntDxNg5lq7Rjq71TzcKMcG8fKgIZNiRjV fTs7eHrwBC5xFZ6zk7sgV/25wfjkrnWI6aDNgoBEsDj/tD954KDDKBNviRqtNIoT ba5Yw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=AX2gqGQ4A02JdwXsy6unNN0txHs2f3MLIbUqVnDhz zs=; b=YfJDmc+JrC4BFV+77a8Nyrtmm7oE1x3IeQSMAEB7Rd5k28qelzpUr4QZE OQf7+RSbnEtaekyLPXu9XPYAcuIwPOMNhxPAEx09I5GNac780QFdatZ//unCgpJv ZhCcg/O1YIzslu3YfT2tYwAFZhZO5qe+4F0i2BtJTc+Cqh2uoO9G98Jdi3LzQ1rV d/7Ybh8WyUOcsJ1FGVd5QvULGDb4A+dp6hQ4qUXZMogP8yPmbL0E9PEb6xrggNJX pYWRX8IC+SCeHElY2NP6Bytjr7frlNyqvhgweiFctu3D9fLLtRvhHGtjSDFgcTnU P7WGeVLdQShb24l4Zj3zdbGbjXCeA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledruddtfedgudehfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeehnecuhfhroh hmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgr vhgvrhdrtghomheqnecuffhomhgrihhnpegtrdhiugdptgdrnhgrmhgvnecukfhppeejud drvdduvddrudehtddrvddtvdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghn rdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.4] (unknown [71.212.150.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 9960E10312; Wed, 13 Feb 2019 16:36:02 -0500 (EST) Subject: Re: Postgrest over foreign data wrapper To: adrien ruffie , "pgsql-general@postgresql.org" References: From: Adrian Klaver Message-ID: <79930a4d-5bc6-aa79-288f-77171bb738ce@aklaver.com> Date: Wed, 13 Feb 2019 13:36:01 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 , c.id FROM contract c > JOIN ft_contractline ft_c ON 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