Building the Database (Tue Sep 26, lecture 10)

Homework due for today

Legend: : Participation | : Early | : PDF | : Portfolio | : Zipped

  1. RORT: Read Ruby on Rails Tutorial ([RORT]) Chapter 3. While we are working towards having a web site with dynamically generated web pages, a good place to start is with static pages, which is what this chapter is about. As you recall, at the most basic level, a web server receives an http request including a URL, and responds with html which is then displayed in the browser. Also we are first introduced to writing unit tests. There is a lot to learn in this chapter so take your time, and ideally type in the examples and get them to work! Take your time and see if you can make it all the way to the end and get it all to work. You will hit snags. Use your resources: the TAs, the class mailing list, stack overflow, google and push through to success! When you are done, go to Latte and answer these warmup questions:

    • In the context of this chapter, what is a static page, and what is a dynamic page?
    • What does the statement “render html: “Hello world” do? (Listing 3.4 of the chapter)
    • How would you modify the sample app from the chapter, to have one more page, which would be “FAQ” page?
    • Are there one or two things you are still confused by? If not, what one or two things were the most memorable about your reading? Deliverable: Do the warmup in Latte and submit by 8am on the day of class.
  2. Rails PA 1: Continue working on PA Rails 1
  3. Project Teams: You should be working or completed steps GIT, DOCUMENTATION, PLANSKEL, SHEMASKEL, BUILDSKEL, STORYSDV, PAPERSDV, SCHEMASDV.

Homework Discussion

  • Lets talk about stuff you just didn’t understand.
  • Lets take a quick tour of a rails app and do some experimenting


  • Term comes from “MVC” - model, view, controller
  • Model is a concept describing a subsystem or part of your overall application
  • Often it is a collection of Classes (ruby or otherwise)
  • What does the Model do?
    • It encapsulates the application state
    • It responds to queries about the state and requests to update the state
    • It validates those requests to keep the state consistent
    • It contains (almost) no “business logic”
    • It doesn’t interact directly with the user or the outside world
  • Where does the model keep the state
    • Most often in a database
    • but not always
  • “If you don’t know the schema of your app, you don’t know your app” - Said one of our outside reviewers over lunch today
  • ORM means we have to keep the database and the Objects “in sync”
  • What happens if in release 2 I have to modify the database?


  • When you discover you need a new column or table, you can modify the database
  • E.g.break the “name” field into a “first name” and “last name”
  • Data Migration
    • How do I move over all the user records that were already there?
  • Logic Migration
    • What has to change in the server code to accomodate this change?
  • Does this mean that migration is bad?
    • It’s not good nor bad: it’s unavoidable
    • It’s much more painful when you are ‘in production’

Look at next class