Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7715749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:27:56+00:00 2026-06-01T02:27:56+00:00

I need to store different versions of not very long strings for different languages

  • 0

I need to store different versions of not very long strings for different languages (2-4 languages) in a Postgres table.

What is the best way of doing that? Array or JSON or something like that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:27:57+00:00Added an answer on June 1, 2026 at 2:27 am

    First make sure that the database locale can deal with different languages. Use a UTF-8 server-encoding. Optionally, set LC_COLLATE = 'C' to be on neutral ground, or use the collation of your main language to have a default sort order. Start by reading the chapter Collation Support in the manual.

    I would strongly suggest to use the latest version of Postgres (9.1 at time of writing) for superior collation support.

    As for the table structure: keep it simple. It sounds like there is a low, fixed number of languages to deal with. You could just have a column for each language then:

    CREATE TABLE txt (
      txt_id serial PRIMARY KEY
    , txt    text NOT NULL -- master language NOT NULL?
    , txt_fr text -- others can be NULL?
    , txt_es text
    , txt_de text
    );
    

    This is pretty efficient, even with many languages. NULL storage is very cheap.
    If you have a varying number of languages to deal with, or many updates for individual language strings, a separate table might be the better solution. This solution assumes that you have a "primary language", where the string is always present:

    CREATE TABLE txt (
      txt_id serial PRIMARY KEY
    , txt    text NOT NULL -- master language NOT NULL?
    );
    
    CREATE TABLE lang (
      lang_abbr text PRIMARY KEY -- de, es, fr, ...
    , lang      text NOT NULL
    , note      text
    );
    
    CREATE TABLE txt_trans (
      txt_id    int  REFERENCES txt(txt_id) ON UPDATE CASCADE ON DELETE CASCADE
    , lang_abbr text REFERENCES lang(lang_abbr) ON UPDATE CASCADE
    , txt       text NOT NULL -- master language NOT NULL?
    , CONSTRAINT txt_trans_pkey PRIMARY KEY (txt_id, lang_abbr)
    );
    

    Not treating the master language special and keeping all language variants in the same table might make handling in your app simpler. But it really depends on requirements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a database table to store different changelog/auditing (when something was
I need to store user entered changes to a particular table, but not show
I'm not sure what I'm doing wrong, but two versions of code that should
I need to store the summer time (daylight saving time) change-over rules for different
I need to create a table in MySQL which stores the different currency symbols
I have id values for products that I need store. Right now they are
I need to store phone numbers in a table. Please suggest which datatype should
I am developing an application that is required to store previous versions of database
I need to read different values stored in a file one by one. So
I need to store products for an e-commerce solution in a database. Each product

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.