How to structure database(s) for multi-lingual website (PHP)
I'm going to be building a multilingual website. I'm not quite sure how to structure the database(s). Should I have one database and have tables like this:
markets_en
materials_en
...
markets_es
materials_es
...
Or should I have a database for each language with开发者_如何转开发 all of the tables having names without the language extension (markets, materials, etc)? In short, I'm not sure whether it's wiser to switch databases and have all of the structures be parallel, or just have identical tables with different languages in them, all in one database.
I suggest multiple databases with parallel table structures, it means you are only modifying the connection string and not every query
Without knowing your specific situation, it seems to me that DRY principles would suggest you just have one database with one table storing all languages and not break it out by language. That just doesn't scale. Instead, just encode/store all entries using UTF-8 or something similar, and then handle encoding at the user level. (We had a database storing customers worldwide, with encodings ranging from the latins to the japanese encodings.) So, in the user table (or somewhere else if it makes sense) create a column for encoding that's based on however you determine what language they're using. Then, as you store and retrieve records for a given user, check their encoding and roll. You'll save yourself lots of headaches, IMO.
hope that helps.
精彩评论