0

I'm looking to set up a favorites table properly for a system where the favorited user's id is added to the table when the "add to favorites" button is clicked.

If each user only ever had 1 favorite it would be simple, but since each user would have multiple favorites I can't figure out how to make that work.

I have a USERS table with columns for User_ID, Username, Email Address, Password. I'd like to be able to add another user as a "Favorite" and be able to go to "My Favorites" page where they show up as a list.

Any help much appreciated. Thank you.

4

2 回答 2

3

您只需要一个表格,我们将调用User_Favorites,其中包含列User_IDFavored_User。这两个字段一起将是表的 PK,每个字段分别是返回到Users.

这允许您拥有一个“收藏”系统中所有其他用户的用户

于 2013-09-17T17:42:18.443 回答
0

创建另一个表,作为联结表。许多用户有许多书签

Surrogate Key|UserWithBookmarkID(USER_ID)|UserThatIsBookmarkID(USER_ID)
于 2013-09-17T17:42:02.650 回答