CS174 Fall 2022Practice Midterm 1

Studying for one of my tests does involve some memorization. I believe this is an important skill. Often people waste a lot of time and fail to remember the things they are trying to memorize. Please use a technique that has been shown to work such as the method of loci. Other memorization techniques can be found off the Wiki Page for Moonwalking with Einstein. Given this, to study for the midterm I would suggest you:

  • Know how to do (by heart) all the practice problems.
  • Go over your notes at least three times. Second and third time try to see how much you can remember from the first time.
  • Go over the homework problems.
  • Try to create your own problems similar to the ones I have given and solve them.
  • If you want to study in groups, at this point you are ready to quiz each other.

The practice midterm is below. Here are some facts about the actual midterm: (a) It is closed book, closed notes. Nothing will be permitted on your desk except your pen (pencil) and test. (b) You should bring photo ID. (c) There will be more than one version of the test. Each version will be of comparable difficulty. (d) One problem (less typos) on the actual test will be from the practice test.

  1. (a) Give an example HTTP/1.1 request and response. (b) Give a notable difference between HTTP/1.1 and HTTP 2.0. (c) Give a notable difference between HTTP/2.0 and HTTP 3.0.
  2. Write a validating XHTML 5 document that: (a) makes use of the external stylesheet super_style.css from the same folder, (b) tells robots not to index links from the page, (c) has an h1 tag with name matching its title, and (d) has an ordered list on it.
  3. Briefly define and given an example of each of the following concepts (1pt each): (a) CSS Class Selector, (b) CSS Pseudo-selector, (C) fixed positioning.
  4. Briefly explain the box model used in rendering HTML elements, labeling its parts. Give stylings for each of these parts for a div tag where the sizes of the parts make use of the last digits of your student ID.
  5. Write a PHP program hours_since_coffee.php that when no request data has been sent outputs an XHTML 5 page with a form that uses method GET and no action consisting of a dropdown with options 1 through 100000 and a submit button. When submitted, the form should print the date at which coffee was lasted consumed in the format d-m-Y H:i using the PHP date function.
  6. (a) Describe the HTTP cookie protocol for setting/returning cookies. (b) Explain how it can be used to implement sessions. (c) Explain how to create and use sessions in PHP.
  7. Explain the mediating-controller MVC design pattern and give an example of code for each of its components.
  8. Briefly describe the POST-REDIRECT-GET design pattern.
  9. With regard to databases, what is a functional dependency? (1pt) What is a trivial functional dependency? (1pt). What is BCNF? (1pt) Give an example of a database schema in BCNF and one which is not in BCNF (1pt).
  10. Write a PHP program with function drawStuffTable which makes a connection to a Mysql database StuffDB running on localhost on the default port. It then retrieves all rows and columns from the Stuff table and prints then to an XHTML page.