Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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