How to properly design a simple favorites and blocked table?

Posted by Nils Riedemann on Stack Overflow See other posts from Stack Overflow or by Nils Riedemann
Published on 2010-03-27T17:25:43Z Indexed on 2010/03/27 17:33 UTC
Read the original article Hit count: 162

Hey,

i am currently writing a webapp in rails where users can mark items as favorites and also block them. I came up two ways and wondered which one is more common/better way.

1. Separate join tables

Would it be wise to have 2 tables for this? Like:

users_favorites
  - user_id
  - item_id

users_blocked
  - user_id
  - item_id

2. single table

users_marks (or so)
  - users_id
  - item_id
  - type (["fav", "blk"])

Both ways seem to have advantages. Which one would you use and why?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database-design