Welcome Guest, Not a member yet? Register   Sign In
Model for a multilingual site
#1

Hello! Just started using CodeIgniter 4 and started developing a multilingual site. For database structure, I decided to go with a table that keeps the shared information and a secondary table that keeps the translations.
For example, a news page - table news with fields: id, published_by, created_at, updated_at, deleted_at and the secondary table news_translation with fields: news_id, language_code, title, article. I have a composite key of news_id and language_code and a foreign key on news_id to news.id.
Now the thing that I can't think of how to do best is how should I structure the model/models? Should I use separate models and entities for the news table and news_translation table and if I do, how would I join the news_translation when showing a list of news if every model/entity represents one table? Also, how would you go with the model of the news_translation table which have a composite key instead of a primary key on one column?
The second way that comes to mind is a manual creation of a single news model that handles both tables.
Which would be the best way to go?
Thank you for your time!
Reply


Messages In This Thread
Model for a multilingual site - by lptr - 07-09-2022, 04:17 PM
RE: Model for a multilingual site - by lptr - 07-13-2022, 05:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB