2

User A joined the group DBA

The table responsible for users x groups is "Following" table.

    user_id      group_id
       1             1
       1             2
       2             1

And in my app I have a table Comments. the foreign key of it is polimorphic, because comments can happen inside posts, photos, etc..

      text       parent_type      parent_id  
     "cool"         Post             1
     "nice pic"     Photo            2
     "welcome!"     Following        3
 

It is a good schema? The following table has_many comments?

And a more complex one would be: "How to comment on a set of people joining?"

enter image description here

2

I think if you want to be able to comment on someone joining a group, then "join a group" must be an entity that can be referenced by other records. You might want to have another "parent_type" called "event" and one of the event types would be "joined a group". That would let you reference it from your comments table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.