Umm.. not really. I mean I would say splitting something from 1-table into 2-tables, and have the same data anyway, you end up actually with more data. As you have to specify a meta_key field, and the meta_value is again duplicated.
On your example just now you have duplicates:
- user_id => shown 3 times => 3(city, state, country) x 4bytes(Int) = 12 bytes (for each user)
- meta_key 'city' => let's say 1000 users are from same city => 1000 x 1 byte(varchar 255) => 1000 bytes ~ 1MB
- for a specific
city you also have a state and country so you end up with ~ 3 MB for 1000 users.
So the growth of your user_meta table is now virtually Infinite
What I meant is, you should split the data so there are no Duplicates. In your case above:
-
users => id | email | first_name | last_name | phone | city_id
-
cities => id | name | state_id
-
states => id | name | country_id
-
countries => id | name
The growth of these 3 tables is Finite. There is a limit to Cities, States and Countries. And you just connect this data to the users table as needed through city_id.
You are not even required to specify state and country as they are related to cities and thus you can access them through that.
Now, if you want to access the data, after you have defined the relations:
-
user->city->name
-
user->city->state->name
-
user->city->state->country->name
You can also use the city_id, on any other tables you may have as well, as this is simply data which you can connect and reuse elsewhere.
There is no reason to split data, like phone from users table. The drawback of having a lot of data on users table is when you select all() fields. Like: User::all(); But if this is getting out of hand (if you have hundreds of columns) then you can just select them specifically like User::select('first_name', 'last_name', 'email')->get()