I want to allow users on my site to follow other users and topics on my site but I'm unsure how to combine them both. Think about how quora allows you to follow users, topics, questions, edits,etc..
To follow users I was going to keep it extremely simple:
user_id: int
followers_id: int
but this is only good for users so I thought about how:
user_id: int
date: Date
following: int(could be topic_id or user_id)
following_type: text(topic or user)
I'm a bit unsure if this is the best way to do this since I'll have to parse the type to query either the topic or user table(but the benefit is since all the data is in one table I can quickly get all following info with one query).
Is this the best way or is there a better(more efficient, scalable,etc.maybe.) way to achieve this? Should I be splitting each follower type into different tables? I'm really unsure what design I should be considering.