I have 1 table for posts. And my columns are Id | id_language | lang

I want to achieve, that there is a second autoincrement id for its language. For example the 80.post is the 5.post written in english language. I need separate index number for sef url. Is it possible


It sounds like you're saying you have the same posts available in different languages. Assuming that's the case, I'd split the table in two.

post would have the basic info about the post that is not language dependent:

  • the unique ID for that post's content
  • the ID of the user who wrote the post
  • the date the post was created
  • ...

post_language would be the content for each specific post, translated into a specific language:

  • post_lang_id - unique ID for this post_language row
  • post_id - foreign key to post; identifies the underlying post that his has content for
  • language (or language_id): This can either be the name of the language this content is written in, or a foreign key to a language table, with all the languages you've got content in. I'd be inclined to use language_id, but it's up to you.
  • post_title
  • post_content
  • ...

In the post table, post_id would be the primary key, and an auto-increment value. In post_language, post_lang_id` would be the primary key, and an auto-increment value.

| improve this answer | |

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.