pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
To: postgre <pgsql-general@lists.postgresql.org>
Subject: Re: Internationalisation (i18n) with Postgres as backend
Date: Wed, 02 Jun 2021 10:43:42 +0200
Message-ID: <a882f82d55fccfd060aad00dc02f58168e443a92.camel@cybertec.at> (raw)
In-Reply-To: <ZtTGYllWD9vYhCPVI5KZIfyKSOg2D-TVyYUrOHjswrN8D6SOl5cG0yLByyGtPUpHINvesXTNljWxSGLxJ1cuVaMMAI7KctzMILmH3x_UTYg=@protonmail.ch>
References: <ZtTGYllWD9vYhCPVI5KZIfyKSOg2D-TVyYUrOHjswrN8D6SOl5cG0yLByyGtPUpHINvesXTNljWxSGLxJ1cuVaMMAI7KctzMILmH3x_UTYg=@protonmail.ch>

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






view thread (9+ messages)

Message-ID: <a882f82d55fccfd060aad00dc02f58168e443a92.camel@cybertec.at>
Permalink:  ../a882f82d55fccfd060aad00dc02f58168e443a92.camel@cybertec.at/
Also on:    postgresql.org/message-id/a882f82d55fccfd060aad00dc02f58168e443a92.camel@cybertec.at

 · 

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-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, n5d9xq3ti233xiyif2vp@protonmail.ch
  Subject: Re: Internationalisation (i18n) with Postgres as backend
  In-Reply-To: <a882f82d55fccfd060aad00dc02f58168e443a92.camel@cybertec.at>
  References: <ZtTGYllWD9vYhCPVI5KZIfyKSOg2D-TVyYUrOHjswrN8D6SOl5cG0yLByyGtPUpHINvesXTNljWxSGLxJ1cuVaMMAI7KctzMILmH3x_UTYg=@protonmail.ch> <a882f82d55fccfd060aad00dc02f58168e443a92.camel@cybertec.at>

* 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