DOC PREVIEW
Berkeley COMPSCI 186 - Homework 6: Database Application

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS 186 Hellerstein/Olston Fall 2006 UC Berkeley - 1 - Homework 6: Database Application bearTunes Due @ 11:59:59 PM on Wednesday, December 6th Overview For this assignment, you’ll be implementing portions of a database-backed web application using Ruby on Rails. If you’ve been ignoring the buzz, Ruby on Rails is the hot new web application framework that makes development (relatively) quick and (usually) painless. After spending the first two programming assignments hacking away at the dark underbelly of PostgreSQL, you now get to take a step back and build something useful on top of it. That something is bearTunes, an application to keep track of artists, albums, and songs. Don’t worry, we’re not using the same database as the SQL homework  Why Ruby on Rails? The guiding principle of Ruby on Rails is “convention over configuration.” Based on some simple assumptions about naming conventions, it does a lot of the gross administrative junk for you, making application development much faster and more bug-free. It lets you focus on the application logic without having to get bogged down in configuration issues. To further simplify things, the Rails architecture draws clean lines between the different functional pieces of your application architecture: Model, View, and Controller (MVC). Model The Model consists of the classes representing your database tables. For each table in your database, there will be a corresponding Model class. You’ll never have to directly communicate with your database: all actions are carried out through the Model classes. Here, you can also define foreign key semantics, so that you can ensure referential integrity even when the database chooses not to. Because all accesses to the database go through the Model classes, you can optimize your database purely for speed and let your application make sure the data stays consistent. View The View controls the display of your results. In this case, that comes in the form of HTML sprinkled with embedded Ruby code. The design and layout of your web pages will all be specified here. There will be one .rhtml file for each action in the Controller classes.CS 186 Hellerstein/Olston Fall 2006 UC Berkeley - 2 - Controller The Controller is what contains your application logic. Based on user input, the code in the Controller retrieves and manipulates data from the Model, and then gives it to the View so that it can be displayed. Here is where the necessary SQL commands will be generated, though you’ll never have to write it yourself (of course, you can if you want). Each action defined in the Controller classes will compute values (or tuples) and store them in variables, and the corresponding View class can reference those variables and display them to the user. Ruby Ruby is the language you’ll be using to write the application. The syntax is very simple and easy to read; you should have no problem picking it up. The Model classes are already written for you; your task will include adding to the Controller and View classes, using both Ruby and HTML. Here are a bunch of tutorials and references for the two languages - knowing them both will look great on your resume! Ruby: http://api.rubyonrails.org/ http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=1 http://www.tutorialized.com/tutorial/Understanding-Your-Code/16240 http://www.tutorialized.com/tutorial/Beginning-Relationships-in-Rails/15353 http://www.tutorialized.com/tutorial/Learning-Ruby/11956 HTML: http://www.w3schools.com/html/html_intro.asp http://www.utexas.edu/learn/html/ http://www.davesite.com/webstation/html/ http://www.mcli.dist.maricopa.edu/tut/lessons.html Setup Before you get to work, you have to set up your environment. You should be able to do this project on any of the Solaris machines (the “shapes”: rhombus, torus, sphere, etc). For this project you’ll be running your own copy of both the database and the webserver (yay!). First, call the following command: setuphw6 This will create and fill the directory ~/hw6, so if you already have something by that name then move it first! When that finishes, call the following newly created script: ~/hw6/beartunes/runServerCS 186 Hellerstein/Olston Fall 2006 UC Berkeley - 3 - This script will start up the database and the webserver. Don’t run this script in the background! If you need access to the terminal, open another one. When you’re finished, simply press CTRL-C to close down the webserver. Accessing bearTunes When you start the webserver using runServer, you will notice the following block of text telling you which port the webserver is running on: --------------------------------- + RUNNING SERVER ON PORT: ##### + --------------------------------- If you’re sitting at the machine on which the server is running, you can simply point your favorite browser to http://localhost:##### and see bearTunes in action. However, most of you will be working remotely, so you’ll have to set up a secure tunnel to view the application. If you’re logging in through SSH Secure Shell (which you can download for free from http://software.berkeley.edu/), here are the steps to setting up a secure tunnel: 1. Select File > Profiles > Add Profile… 2. Give it a name and click Add to Profiles 3. Select File > Profiles > Edit Profiles… 4. Find the name on the left and select it 5. Click on the Tunneling tab 6. Select Outgoing tunnels, and click Add… 7. Set Display Name to anything you want 8. Set Type to TCP 9. Set Listen Port to some random number in the 2000-4000 range 10. Check the box by Allow Local Connections Only 11. Set Destination Host to the machine where the webserver is running (i.e. rhombus.cs.berkeley.edu) 12. Set Destination Port to the number that was displayed when you started the webserver Now close down the webserver with CTRL-C and log out. Now, to log back in again, select File > Profiles and find the profile you just created. Log in and start up the webserver again by running the script bearTunes/runServer. On your local machine, open up a web browser and point to the following URL: http://localhost:{PORT} Where {PORT} is the number you filled in under Listen Port when setting up the tunnel. If everything went according to plan, you should see the front page of bearTunes!CS 186 Hellerstein/Olston Fall 2006 UC Berkeley - 4 - Database schema The following is the schema of the


View Full Document

Berkeley COMPSCI 186 - Homework 6: Database Application

Documents in this Course
Load more
Download Homework 6: Database Application
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework 6: Database Application and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework 6: Database Application 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?