When creating a multi-language website, we often wonder if we need a separate table for each language. The answer is a firm NO.
Why use only one table?
Using a single table brings key advantages, as shown below:
| Advantage | Description |
|---|---|
| Data Integrity | You change data in only one place. |
| Easy Maintenance | The same SQL query works for all languages. |
Practical Example: "stranke" Table
Below is the SQL code to create a universal table:
CREATE TABLE IF NOT EXISTS stranke (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
address VARCHAR(100),
house_number VARCHAR(10),
city VARCHAR(50),
zip_code VARCHAR(10)
);
In PHP code, we simply change the table headers (e.g., "Ime" in Slovenian and "First Name" in English), while the data remains the same.