if you have a many to many relationship in your tables, you should implement this like this:
restaurants table:
restaurant_id | other fields
locations table:
location_id | other fields
features table:
feature_id | other fields
cuisines table:
cuisine_id | other fields
Now the mapping of the restaurants to other stuff is done like this
restaurant2location table:
restaurant_id | location_id
restaurant2feature table:
restaurant_id | feature_id
restaurant2cuisine table:
restaurant_id | cuisine_id
Modeled like this any restaurant can have any number of features, locations, cuisines. You can now retrieve all the information you want with simple joins using the restaurant_id with 2 tables ( restaurant2XXX + XXX )
Code:
SELECT whatever_fields_you_want FROM XXX AS t1, resturant2XXX AS t2 WHERE XXX.XXX_id=restaurant2XXX.restaurant_id AND restaurant2XXX.restaurant_id = 'ID'
Where XXX = location(s) or feature(s) or cuisine(s) <-- (s) for the table names only!
You can probably get all the information of a single restaurant in a single very big query but at least your information is properly normalized in the DB and you can do it with 3 small queries as a subset.
Bookmarks