Using PostgreSQL hstore for i18n

I am just modeling a PostgreSQL database for a new project that needs localization support. I wonder if hstore can be a good way to localize certain data fields.

For example: let's take a simplified table for blog posts with post_titleand fields post_content. Using the hstore type of the key type, you can add several translations to these fields, identified by the language code as the key:

id | post_title (hstore)   | post_content (hstore)
---|-----------------------|------------------------------
 1 | "en" => "Hello World",| "en" => "Content in english",
   | "de" => "Hallo Welt"  | "de" => "Inhalt auf deutsch"
---|-----------------------|------------------------------
 2 | ...                   | ...

Does anyone have any experience with this approach? It seems to be very flexible and easy to use, but maybe I am missing some significant flaws here?

+4
source share

Source: https://habr.com/ru/post/1614333/


All Articles