Hello everyone, I''ll like to hear your opinion on the following issue. I have a posts and post_comments table. Posts belong to a group, so there is a group_id column on it. I want to query for all the post_comments of a user for a specific group, so what I am doing now is a INNER JOIN between the two tables. My question is: Is it better to have a group_id column on the post_comments table for optimize search or that''s redundant? Thanks, Elioncho --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 27, 12:47 am, elioncho <elion...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello everyone, > > I''ll like to hear your opinion on the following issue. I have a posts > and post_comments table. Posts belong to a group, so there is a > group_id column on it. I want to query for all the post_comments of a > user for a specific group, so what I am doing now is a INNER JOIN > between the two tables. My question is: Is it better to have a > group_id column on the post_comments table for optimize search or > that''s redundant? > > Thanks, > > ElionchoBetter that you keep your data struct as is, IMHO. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Agree with Erol. Leave the schema as it is, and use proper DB indexes to help with performance. It is posts that belong to groups, not comments. Right? On Sep 26, 1:24 pm, Erol Fornoles <erol.forno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sep 27, 12:47 am, elioncho <elion...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello everyone, > > > I''ll like to hear your opinion on the following issue. I have a posts > > and post_comments table. Posts belong to a group, so there is a > > group_id column on it. I want to query for all the post_comments of a > > user for a specific group, so what I am doing now is a INNER JOIN > > between the two tables. My question is: Is it better to have a > > group_id column on the post_comments table for optimize search or > > that''s redundant? > > > Thanks, > > > Elioncho > > Better that you keep your data struct as is, IMHO.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---