Take the 2-minute tour ×
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. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.