I'm making my first Rails app (actually it's my first programming experience) and I have a few questions about models and associations.
My first app is blog.
Blog have users. Users have posts.
One post have one category.
Post also can have tags.
One tag have one category (just like the post).
For example:
Category "Work" have tags "sql", "analytics", "excel" etc.
Category "Personal" have tags "travel", "photo", "surfing" etc.
http://img18.imageshack.us/img18/2213/3m1.png
Here's the sketch of database structure with associations.
And here's the list of my questions:
How can I optimize this structure of models? Or it's ok? (I have a strange feeling about Category model)
Is these associations for models written correct?
Do I need to use :foreign_key and :dependent with associations?
What's gonna happen with associated posts when I'll destroy Category (if :dependent not declared)?
Do I need to have foreign keys on database side?
Thanks for the answers!