Hi
I have a message model and message_participants table.
message_participants table because same message goes to various
recipients.
Messaging between either company to users OR user to company. So an
initial design of tables made like
messages table
-----------
+-------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| subject | varchar(255) | YES | | NULL | |
| message_thread_id | int(11) | YES | | NULL | |
| message | text | YES | | NULL | |
| company_id | int(11) | YES | | NULL | |
+-------------------+--------------+------+-----+---------+----------------+
message_participants table
----------------------------
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| direction_in | tinyint(1) | YES | | NULL | |
| direction_out | tinyint(1) | YES | | NULL | |
| type | varchar(255) | YES | | NULL | |
| company_id | int(11) | YES | | NULL | |
| user_id | int(11) | YES | | NULL | |
| message_id | int(11) | YES | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
Here about ''type'' field I am not sure. My question is
should I treat
message_participants like STI or polymorphic? I can''t decide it.
Relation is
message has_many message_participants
message_participants belongs_to message
Please guide
Thanks
Tom
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Tom Mac wrote:> Hi > I have a message model and message_participants table. > message_participants table because same message goes to various > recipients. > Messaging between either company to users OR user to company.[...]> Here about ''type'' field I am not sure. My question is should I treat > message_participants like STI or polymorphic? I can''t decide it.STI: single-table *inheritance*. Does User inherit from Company, or Company from User? Probably not. So no inheritance is involved, and you probably want a polymorphic association. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.