Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1loB8s-0004Yh-H1 for pgsql-general@arkaria.postgresql.org; Tue, 01 Jun 2021 20:37:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1loB8r-0004lK-3A for pgsql-general@arkaria.postgresql.org; Tue, 01 Jun 2021 20:37:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1loB8q-0004lC-OB for pgsql-general@lists.postgresql.org; Tue, 01 Jun 2021 20:37:36 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1loB8o-0000BP-Qk for pgsql-general@lists.postgresql.org; Tue, 01 Jun 2021 20:37:36 +0000 Received: by mail-il1-x133.google.com with SMTP id x9so9147188ilp.4 for ; Tue, 01 Jun 2021 13:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=K9rJwKMPECob/CwmSG/u7yxs0mzm6+EcRJpie4cHfe4=; b=gvgSatsHVc0eIU8caUl+V+pxhyLuQ0Bl/zrmu0AsR3DosRkrVryiecXApddoSbpc6k edysOqsBTifPhp2PMdjkj0s+MbnEj0OQrEOg7xINTLvEhqn8B4zIwnYOQNMWFMpuMWao QD2O0VYhhdsiQpGCZYKv/VjEQQlVx7XxxwzfSu8TVusvrIcO1bGszXmC+PLB7Db6JSnR ukJkMeONzwm6D7t5X90vJCx/kQyDqiAvtVchp37PEc2jFMOXK/rku0FHTxRRCLmEcvm/ edJPELxhZv6ESo9Kh7pbbiKf83EuJlKzOT12ymM5SSTosPfifBfVmJMxA4HPkvAogND5 48LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=K9rJwKMPECob/CwmSG/u7yxs0mzm6+EcRJpie4cHfe4=; b=iNfjVDBKRZhG2uLtz2LL/tFrN+23X8p2NFOoB2clilhLOz+UU/9m6SWs90tsb/k3Jm PPS04HBQW3fmfnxBBdzqrjy63pHOhAsHLW1SfJZmd6yhQ/aV4hx/p6CIxkTJPJRhsXBJ Xe42YCfe4AuO0jvBRdl6uddteNGMT9Vyisr36EtjB/dkMt5Eg2PBmoJks7grlhI1mBMX fAhJSO7xLHjPKG7xTz/RqakJ4UKpdhdyn+F/IvPQtAw+0n9E1hq7atxGWtpAScXb6GoI 6c1HG6sX4xaKWwK4yAEcrJzXjgs2L5nI3yAA8PyWtHB4nP4TfIvVRRuNgrfMffuf97Kh 7RRQ== X-Gm-Message-State: AOAM530FrOCJ2iV39j4p7t1Tt2oDfFLJQbxGCESTyu8gRxMKnefJ55bq 0ngaIKneBMUmQW+VTgdt5mTDBBK0xuFNEQ== X-Google-Smtp-Source: ABdhPJzNIG9CBLYgIqbLPs9wdDRRCnCIjxUPLs8PTtZCxvBMhYQx5vlxrzfJ1K/hB7g4gH70IXoBzQ== X-Received: by 2002:a92:d5c4:: with SMTP id d4mr10264624ilq.71.1622579852723; Tue, 01 Jun 2021 13:37:32 -0700 (PDT) Received: from ?IPv6:2601:681:5500:dde0:fd72:66b:4802:5fe5? ([2601:681:5500:dde0:fd72:66b:4802:5fe5]) by smtp.gmail.com with ESMTPSA id e15sm10309639ile.63.2021.06.01.13.37.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Jun 2021 13:37:32 -0700 (PDT) Subject: Re: Internationalisation (i18n) with Postgres as backend To: pgsql-general@lists.postgresql.org References: From: Rob Sargent Message-ID: <9d7ea0e1-99b2-192f-b63d-94868c2a158d@gmail.com> Date: Tue, 1 Jun 2021 14:37:31 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-CA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/1/21 2:09 PM, Laura Smith wrote: > Hi, > > I'm creating a Postgres backend for an internal tool which is essentially a very simple implementation of multi-lingual CMS. > > So far my thoughts are along the lines of the below, but I would appreciate a second (or more !) pair of eyes from some Postgresql gurus. I am especially interested in feedback and suggestions in relation to the following questions: > > (a) Is this going to work as expected (i.e. have I missed some obvious foot-guns ?) > > (b) Is this manner of doing things reasonably efficient or are there better ways I should be thinking of ? (bear in mind the schema is not set in stone, so completely out of the box suggestions welcome !). > > The basic design concept (oversimplified) is: For each page, you have one or more objects and those objects may have content in one or more languages. > > create table langtest( > pageid text not null, > objectid text not null , > objectlang text not null, > objectdata text not null); > > create unique index on (pageid,objectid,objectlang); > > insert into langTest(pageID,objectID,objectLang,objectData) values ('zzz','abc','en','Lorem ipsum dolor sit amet'); > insert into langTest(pageID,objectID,objectLang,objectData) values ('zzz','abc','de','Amet sit dolor ipsum lorem'); > insert into langTest(pageID,objectID,objectLang,objectData) values ('zzz','def','en','Dolor ipsum amet sit lorem'); > > select distinct on(objectid)objectid,objectlang,pageid,objectdata from langTest where pageid='zzz' and objectLang = any('{de,en}'::text[]) order by objectid,array_position('{de,en}'::text[],objectLang); > > (The idea being that the select query will be wrapped into a function which the frontend will call, passing a list of elegible languages as input) > > Thanks ! > > Laura > What is your notion of "object".  I first assumed it was akin to "document" but then pages have objects.