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 1loMTc-0006FO-Iu for pgsql-general@arkaria.postgresql.org; Wed, 02 Jun 2021 08:43:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1loMTb-0007Q2-Im for pgsql-general@arkaria.postgresql.org; Wed, 02 Jun 2021 08:43:47 +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 1loMTb-0007Pu-9t for pgsql-general@lists.postgresql.org; Wed, 02 Jun 2021 08:43:47 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1loMTY-0005xU-SJ for pgsql-general@lists.postgresql.org; Wed, 02 Jun 2021 08:43:46 +0000 Received: by mail-wr1-x42b.google.com with SMTP id h8so1403388wrz.8 for ; Wed, 02 Jun 2021 01:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=NyRphds5QflW4r7pLwy5VA5rzKGqYjekHETW2d7g+zk=; b=uBxWvewkcjbtZaGr+BHx7YVjlBodf1vzk8xjAgv22cxzU3W4QBRIfik/BT9Mf1A1lt NesWTyVaA6d5cMzuiowGbOnLmD+9UrJbvv2JBeUZaVn3YXEqQY3iC2WzlD5y6sGrumaf XSnzjHBaPm/w0uGJJCRxkowiB3itbAky1zGPNzVqm4BaJ37jGunm74H/p5P9kAQRNTqW FcorYCA9s2ArkHymcIt1gzmYuiZ/liGXqeGRQJsCAJAb5lnbe58Tj6AxjhRjKJJLJdJ4 o/XGfenWY10vVnhVuasdM8IeIoaxd1OnuzmeWaGuKExbQd7ZafUEnVkTAQTfYWQKSkLV XI8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=NyRphds5QflW4r7pLwy5VA5rzKGqYjekHETW2d7g+zk=; b=KvxCt4SG0oXw0OdrrU4XbblgE/5uIyzVKWR+WRV+SdjSOqStGqvpmFz+ggKtYdGWda RwL/HFwXY57ygtTLvgClEzfgmHSLnVJK55I0mKujYFgUfMv4U476dKAl1nXcxX01Fl5r khVFg56ZW35fvzGKy5hSadG/JynhurnDKlbSf2E1rfHAwv0pZXC/dadrtusHLzbBV+7L 7pjYENz4frpkR+58dWxzwmoeNeC6O98utbss1fYBynyf8OD4TBAUCoRCGMZGAztQp2EQ TYTZHyk3vrHLcWfMb1ebK4NzlqRHd7AoqNw9sby9ESeeeh3gHftlWbZH+JDttmXDpmj8 WrQw== X-Gm-Message-State: AOAM531ylfT0dGXbAncyf1uXdUibLOYqVwXCQNVh8ao1cr3QCMfPpfG4 r8Uu59urnhUijki9nZhjGreX4g== X-Google-Smtp-Source: ABdhPJwSJyhDvQzhmhCtscMm/exu0Bm264LJ0scni7tixlySKl48PAGDA4qdG1HhXrlQ54quaURBQw== X-Received: by 2002:a5d:49c7:: with SMTP id t7mr105372wrs.289.1622623423634; Wed, 02 Jun 2021 01:43:43 -0700 (PDT) Received: from localhost.localdomain (217-149-171-76.nat.highway.telekom.at. [217.149.171.76]) by smtp.gmail.com with ESMTPSA id a1sm6563253wrg.92.2021.06.02.01.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 01:43:43 -0700 (PDT) Message-ID: Subject: Re: Internationalisation (i18n) with Postgres as backend From: Laurenz Albe To: Laura Smith , postgre Date: Wed, 02 Jun 2021 10:43:42 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2021-06-01 at 20:09 +0000, Laura Smith wrote: > I'm creating a Postgres backend for an internal tool which is essentially a very simple implementation of multi-lingual CMS. > > 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); > > 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); That looks ok, except you should remove "objectid" from the index. That column makes that the index cannot be used for "objectlang" effectively. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com