i want to know what is the right way to do it .
We have area which can be northamerica, southamerica
we have goelocations which can be slc, murry, peru, mexico
so, one area can have many geolocations.
table for this is
ID Area Geolocation
1 NA slc
2 NA murry
3 SA peru
4 SA mexico
If number of area and geolocation are very limited and not expected to grow do you see a problem in this type of design vs table with FK like below
Area table
ID Area
1 NA
2 SA
Geolocation table
ID Geolocation AreaID
1 slc 1
2 mexico 2
3 peru 2
which one will be easy to query and use in a php application?
Even though denormalization doesn’t cost a lot because, as you say, the geolocation set is small and stable, it’s still worth having a normalized table (as with your second option). You may decide to add (say)
centralamericaor other regions. Or you may need to change the encoding used. The whole point of normalization is to make it easier to deal with changes you did not expect, not just the ones you can foresee.The performance penalty for lookups is very small (if there is any at all). Updates will be easier and the data base will probably be smaller with an FK-based schema.