2

Does a database engine with native cross-cutting internationalization support exist, able to store data like this?

SET LOCALE='en'
SELECT * FROM BOOKS

+------+-----------------------+----------------+
|  ID  | TITLE                 | AUTHOR         |
+------+-----------------------+----------------+
|   1  | The Lord of The Rings | J.R.R. Tolkien |
+------+-----------------------+----------------+

SET LOCALE='it'
SELECT * FROM BOOKS

+------+-------------------------+----------------+
|  ID  | TITLE                   | AUTHOR         |
+------+-------------------------+----------------+
|   1  | Il Signore degli Anelli | J.R.R. Tolkien |
+------+-------------------------+----------------+

i.e. able to store values in a third dimension, such as a locale in this case?

Clarification

In the example above, just TITLE should be affected by SET LOCALE by a special definition in this kind of database (I imagine something like LVARCHAR); so, adding a discriminator column would not be feasable since all the non-localized columns will be duplicated.

0
3

With PostgreSQL you can simulate something like using views and environment variables.

create table books_ids(
  book_id serial not null primary key,
  author text not null);

create table books_titles (
  book_id int not null references books_ids,
  lang char(2) not null,
  title text not null,
  isbn text null,
  primary key(book_id, lang));

insert into books_ids (author) VALUES ('J.R.R. Tolkien');
insert into books_titles (book_id, lang, title)
  values (1, 'en', 'The Lord of The Rings'), (1, 'it', 'Il Signore degli Anelli');

create view books as
  select b.book_id as id, t.title, b.author
  from books_ids b
  join books_titles t on (t.book_id = b.book_id and t.lang = current_setting('my.lang'));

-- in English
set my.lang='en'; select * from books;

-- in Italian
set my.lang='it'; select * from books;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.