How can PHP developers ensure data integrity and maintain a 1:1 relationship between content and news entries when handling multilingual content?

To ensure data integrity and maintain a 1:1 relationship between content and news entries when handling multilingual content, PHP developers can create a separate table to store the translations for each news entry. This table can have a foreign key referencing the primary key of the news entry table, ensuring that each translation is linked to the correct news entry. By querying the translation table based on the news entry ID and language code, developers can retrieve the appropriate translation for each news entry.

// Create a separate table for news entry translations
CREATE TABLE news_entry_translations (
    id INT PRIMARY KEY AUTO_INCREMENT,
    news_entry_id INT,
    language_code VARCHAR(2),
    title VARCHAR(255),
    content TEXT,
    FOREIGN KEY (news_entry_id) REFERENCES news_entries(id)
);

// Query the translation table based on news entry ID and language code
SELECT title, content
FROM news_entry_translations
WHERE news_entry_id = :news_entry_id
AND language_code = :language_code;