I have three tables where the bold attribute(s) is the primary key
- Restaurants(restaurant_ID, name, ...)
resturant_ID, name, ...
1, Macdonalds
2, Hubert
3, Dorsia
... ...
- Identifier(restaurant_ID, food_ID)
restaurant_ID, food_ID, ...
1, 1
1, 4
2, 1
2, 7
... ...
- Food(food_ID, name, ...)
food_ID food_name
1 Chips
2 Burgers
3 Salmon
... ...
Using postgres I want to list out all restaurants (restaurant_id and name - 1 row per restaurant) that have share the exact same set of foods with at least one other restaurant.
For example, let's say
- Restaurant with ID "1" has only associated food_id's 1 and 4 as shown in
Identifier - Restaurant with ID "3" has only associated food_id's 4 and 1 as shown in
Identifier - Restaurant with ID "7" has only associated food_id's 6 as shown in
Identifier - Restaurant with ID "9" has only associated food_id's 6 as shown in
Identifier - Then output
Restaurant_id name
1 name1
3 name3
7 ...
9 ...
Any help would be greatly appreciated!
Thank you