U of MN Ruby/Rails course quiz

See overview for INET 3350: Ruby, Rails, and Web Development
See syllabus for tentative schedule

Learning to create web applications integrates three major skills:

  1. Programming with a language such as Ruby, C#, Java, PHP, etc.
  2. Editing HTML pages (or templates) so that the application can present information to the user, and facilitate the collection of input. More generally, it helps to know a bit about HTTP (the protocol used on the web).
  3. Manipulating data in a database (typically a relational database, such as MySQL, PostgreSQL, Oracle, or Microsoft SQL Server).

A framework such as Ruby on Rails is designed to make all of these things easier; but to learn web development, it helps to have some knowledge of items 2 and 3 (we’ll teach you item 1). In past experience, students can do well if they already have some knowledge of either HTML/HTTP, SQL, or both. Students who take a course like this with nothing at all for both items may struggle; students with deficits in both areas will have to listen strenuously and be an active learner: Such students may need to use external resources to understand the coverage of Ruby on Rails.

Here are some questions that will help you assess your knowledge of HTML/HTTP and SQL.

For both sections, knowing the answer isn’t as important as feeling that the questions aren’t unexpected or unusual: consider yourself passing if most of the questions and answers make sense and feel obvious.

The answers are here: answers

HTML/HTTP

  1. What does the “H” in HTML and HTTP stand for?

  2. What is this, and what is it for?

    <form>
      Address1 <input name="address[address1]" />
      Address2 <input name="address[address2]" />
      City <input name="address[city]" />
      State <input name="address[state]" />
      Zip <input name="address[zip]" />
      <input type="submit" />
    </form>
    
  3. When a web pages displays with no errors (i.e., when an HTTP response is returned with no errors), what HTTP status code is returned?

  4. In an HTML form, what is the default HTTP method that is used to send data back to the server? Hint: Not GET

  5. (A bit of a trick question) Do you think the following HTML is valid? What are some of the things you’d want to think about regarding a page’s validity?

    <!DOCTYPE HTML>
    <html>
      <head>
        <title>Example<title>
      </head>
      <body>
        Hi there!
      </body>
    </html>
    

SQL / Relational databases

  1. What does this do?

    create table addresses (
      id integer primary key,
      address1 varchar,
      address2 varchar,
      state varchar,
      city varchar,
      zip varchar
    );
    
  2. What would happen if we inserted two rows into addresses with the same value for id?

  3. Suppose an application was searching for all addresses with zipcode ‘02138’, but it seemed to be slow. What would you do?

  4. George defines his database with the following commands:

    drop table if exists addresses;
    create table addresses (
      id integer primary key,
      address1 varchar,
      address2 varchar,
      state varchar,
      city varchar,
      zip varchar
    );
    drop table if exists subscribers;
    create table subscribers (
      id integer primary key,
      first_name varchar,
      last_name varchar,
      address_id integer
    );
    
    insert into addresses (id, address1, address2, state, city, zip)
    values (1, '1 Broadway', '', 'Cambridge', 'MA', '02138');
    
    insert into subscribers (id, first_name, last_name, address_id)
    values (1, 'John', 'Norman', 1);
    insert into subscribers (id, first_name, last_name, address_id)
    values (2, 'Ali', 'Khan', null);
    

    Then he executes the following query:

    select last_name, city from subscribers
      left join addresses on addresses.id = subscribers.address_id;
    

    Here are two options A and B for the result. What does he get, and why does it matter?

    (A)

    last_name | city
    -----------+------
    Norman    | MA
    (1 row)
    

    (B)

    last_name | city
    -----------+------
    Norman    | MA
    Khan      |
    (2 rows)
    
  5. George has designed an application where there are two tables, subscribers and addresses. He added a foreign key to subscribers called address_id. By this means, each subscriber can have a single address. He recently found out that some subscribers have two or more addresses. How should he change his schema?