at the moment I'm doing Odin Project's Ruby on Rails track (didn't know such a resource was available until a few days ago.) and it has a few scenarios and they want you to write the appropriate data modeling plus association for them. Unfortunately from what I've been able to find, they don't have any answer key for the 4 scenarios they give you. I was just wondering if someone can look over my answers and guide me to the right direct on what I did wrong and/or right if that's not too much to ask.
These are the four scenarios from Odin Project
You are building an online learning platform (much like this!). You've got many different courses, each with a title and description, and each course has multiple lessons. Lesson content consists of a title and body text.
You are building the profile tab for a new user on your site. You are already storing your user's username and email, but now you want to collect demographic information like city, state, country, age and gender. Think -- how many profiles should a user have? How would you relate this to the User model?
You want to build a virtual pinboard, so you'll have users on your platform who can create "pins". Each pin will contain the URL to an image on the web. Users can comment on pins (but can't comment on comments).
You want to build a message board like Hacker News. Users can post links. Other users can comment on these submissions or comment on the comments. How would you make sure a comment knows where in the hierarchy it lives?
Here's what I come up with. The fourth one completely stumped me unfortunately.
1. table - course
t.string :title
t.text :description
has_many :lessons
table - lesson
t.string :title
t.text :body
belongs_to :course
foreign key :course_id
2. AddDemo_to_User city:string state:string country: string age:integer gender:string
3. table - pin
url:string
comment:text
user has_many :pins
pin belongs_to :user
foreign_key :user_id