Rails One To Many Lab




Data Modeling and Designing an API

Your boss wants you to design and build an API. The API is going to deliver some data about the average share prices for saleable stocks on the stock market.

You know you will be dealing with average prices and stocks, and that the two things are related.



Answer the following questions:


  • What models will you need? Why?

  • What is the relation between average prices and stocks?
  • What columns would you want for your tables?
  • Does one of your tables get a foreign key column? If so, which?

  • What controllers will you need?
  • What routes do you want your API to have?
  • What actions will your controller need, given your routes?

  • Can you make your API 'self-evident'? Meaning, your API requires little explanation for an end-user?

Bonus research:

  • Do you want nested routes?

When you think you know the answers to these questions, build your API.