My problem: What I would like to accomplish is add the ability for the user to link their menu with another user. Allowing any changes to menu from either user show for both users.
My current thought process: I added a field for "joined user" but that doesn't look right. Would it be better to make a separate table for menus then have it pulled from there? Or is there a more proper/efficient way to accomplish this?
CodePudding user response:
Instead of putting menu_user
in the menu
table, create a relationship table that relates all the users sharing a menu:
CREATE TABLE menu_users (
id INT(10) PRIMARY KEY AUTO_INCREMENT,
user_id INT(10),
menu_id INT(10),
UNIQUE INDEX (user_id, menu_id),
FOREIGN KEY (user_id) REFERENCES users (id),
FOREIGN KEY (menu_id) REFERENCES menu (id)
);