Since a city has_many pictures this tell you that the pictures table
has a city_id foreign key in it.
There isn''t a nice way to do it the other way around.
On Sat, Sep 20, 2008 at 5:43 PM, Pod Caster
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> Hi, I have a basic question about how to setup my models and DB
> structure.
>
> I will have an app that allow users to upload pictures. Pictures are
> related to cities. Users can upload pictures for many cities.
>
> The visitors can view the pictures based on the city they are visiting.
> So when they do a search obviously the search scope on the DB should be
> at city level.
>
> I might end up with many many records and my questions are targeting DB
> efficiency.
>
> 1- Should I have a Pictures table that has a City column on it?
> 2- Should I have a City table that has a Pictures column on it?
>
> What users will search and view are pictures not cities so I''m not
sure
> what will be best if amount of records would be high.
>
> I guess it would be good to use some indexing on Cities also (?)...
>
> As you can see I''m not experienced with DB, any suggestions will
be
> appreciated.
>
> Cheers.
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--
Ramon Tayag
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---