Melkier Jordán
Melkier Jordán

Reputation: 11

Data Type Qualifiers Definition PostgreSQL

How would I go about defining a table with a language specific (qualified) attribute?

For example:

ID| object |description (english)|description (french)| size | color (english) | color (french)

in the above example we have 3 'normal' fields and 2 language qualified fields : description and color.

What is best practice for defining these type of fields within one table?

Upvotes: 1

Views: 67

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269763

There are different ways of doing this. But a method for your specific data is to have another table with one row per language. Such as table would have:

  • objectLanguageId (serial column to identify the row)
  • objectId (reference to a table with one row per object)
  • language
  • description
  • color

Then the "object" table would have

  • objectId
  • objectName
  • size

Note: This is definitely not the only approach. If you need everything in your system translated, then you want a more sophisticated and generic mechanism. You may also need to take into account things like French sizes are different from sizes in other countries -- even countries that speak the same language.

Upvotes: 1

Related Questions