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 1h8ocu-0005il-G0 for pgsql-general@arkaria.postgresql.org; Tue, 26 Mar 2019 16:08:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h8oct-0005fY-4N for pgsql-general@arkaria.postgresql.org; Tue, 26 Mar 2019 16:08:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h8ocs-0005fR-SL for pgsql-general@lists.postgresql.org; Tue, 26 Mar 2019 16:08:34 +0000 Received: from evolu-s.it ([94.23.66.144] helo=smtp.evolu-s.it) by magus.postgresql.org with smtp (Exim 4.89) (envelope-from ) id 1h8ocq-0002wK-Kt for pgsql-general@postgresql.org; Tue, 26 Mar 2019 16:08:34 +0000 Received: from [192.168.1.129] ([79.6.30.247]) by smtp.evolu-s.it ; Tue, 26 Mar 2019 17:08:29 +0100 Subject: Re: Key encryption and relational integrity To: Adrian Klaver , PostgreSQL mailing lists References: <094bf875-5b49-8d3c-1fa3-97c07246b890@evolu-s.it> <082fdd45-a12b-161b-8386-70ee8528361e@aklaver.com> From: Moreno Andreo Message-ID: <514fb642-bba4-7a14-b412-d953f1b8b7e7@evolu-s.it> Date: Tue, 26 Mar 2019 17:08:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 In-Reply-To: <082fdd45-a12b-161b-8386-70ee8528361e@aklaver.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 8bit Content-Language: it List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Il 26/03/2019 15:24, Adrian Klaver ha scritto: > On 3/26/19 7:19 AM, Moreno Andreo wrote: >> Hello folks :-) >> >> Is there any workaround to implement key encryption without breaking >> relational integrity? > > This is going to need more information. OK, I'll try to be as clearer as I can > For starters 'key' has separate meanings for encryption and RI. I > could make some guesses about what you want, but to avoid false > assumptions a simple example would be helpful. In a master-detail relation, I need to encrypt one of master table PK or detail table FK, in order to achieve pseudonimization, required by GDPR in Europe when managing particular data Imagine I have Table users id   surname    last name 1    John            Doe 2    Jane            Doe 3    Foo             Bar Table medications id    user_id    med 1     1                Medication 2     1                Ear check ... ... medications.user_id is FK on users.id we should achieve Table medications id    user_id        med 1    sgkighs98    Medication 2    sghighs98    Ear check or the opposite (users.id encryption and medications.user_id kept plain) At a first glance, it IS breaking relational integrity, so is there a way to manage this encryption internally so RI is kept safe? Thanks Moreno.-