Design Database that Keeps Favorite Posts for Every User - Sugesstion Needed
Offer: offerID, title, thread ...
Wanted: wantedID, title, thread ... Member: memberID, username ...
A member can pick many topics as favorite which will be put in a UI list. How can i design the db for it?
My Solution:
Favorite:
favoriteID (PK)
memberID - FK
offerID - FK
wantedID - FK
Many to ma开发者_高级运维ny relationship. However, there always be NULL either in offerID or wantedID, is this ok?
You say you're allowing multiple favorites per user, right?
Why don't you just use two tables then?
1) favoriteOffers
favoriteOfferID (PK)
memberID - FK
offerID - FK
2) favoriteWanted
favoriteWantedID (PK)
memberID - FK
wantedID - FK
You get the same functionality (maybe even more) with clear clean structure.
精彩评论