Best DB structure - any advice?

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.

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 C.
[email protected] wrote:

As you can see I’m not experienced with DB, any suggestions will be
appreciated.

Cheers.

Posted via http://www.ruby-forum.com/.


Ramon T.