1 / 26

Web Programming Week 2

Web Programming Week 2. Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein <mklein@cs.odu.edu> 09/07/10. Defining the Web / HTTP. HTTP was originally defined by Request for Comments (RFCs)1945, 2068, 2616

Download Presentation

Web Programming Week 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web ProgrammingWeek 2 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein <mklein@cs.odu.edu> 09/07/10

  2. Defining the Web / HTTP • HTTP was originally defined by Request for Comments (RFCs)1945, 2068, 2616 • and several others for defining URLs, URIs, etc. • While RFC 2616 remains canonical for HTTP, we have a new document for the “Web” (URIs + protocols + formats), we have a slightly revisionist but ultimately useful unifying document: • The Architecture of the World Wide Web, Volume One. • http://www.w3.org/TR/webarch/

  3. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119. 1. MUST This word, or the terms "REQUIRED" or "SHALL", mean that the definition is an absolute requirement of the specification. 2. MUST NOT This phrase, or the phrase "SHALL NOT", mean that the definition is an absolute prohibition of the specification. 3. SHOULD This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item, but the full implications must be understood and carefully weighed before choosing a different course. 4. SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean that there may exist valid reasons in particular circumstances when the particular behavior is acceptable or even useful, but the full implications should be understood and the case carefully weighed before implementing any behavior described with this label. 5. MAY This word, or the adjective "OPTIONAL", mean that an item is truly optional. One vendor may choose to include the item because a particular marketplace requires it or because the vendor feels that it enhances the product while another vendor may omit the same item. An implementation which does not include a particular option MUST be prepared to interoperate with another implementation which does include the option, though perhaps with reduced functionality. In the same vein an implementation which does include a particular option MUST be prepared to interoperate with another implementation which does not include the option (except, of course, for the feature the option provides.) How To Read RFCs(quoting from RFC 2119)

  4. Examples from RFC 2616 10.4.6 405 Method Not Allowed The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource. 10.4.4 403 Forbidden The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. 10.4.9 408 Request Timeout The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.

  5. Reading the W3C Arch • Principles • fundamental “rule” or “law” that is widely applicable • Constraints • definitions imposed by the architects of the Web • “MUST”, “SHALL” • Good Practice • things you should be doing, but they can’t / shouldn’t be defined as constraints • “SHOULD”, “RECOMMENDED”

  6. Principle: Global Identifiers • Principle: Global Identifiers • Global naming leads to global network effects.

  7. Good practice: Identify with URIs • Good practice: Identify with URIs • To benefit from and increase the value of the World Wide Web, agents should provide URIs as identifiers for resources.

  8. Constraint: URIs Identify a Single Resource • Constraint: URIs Identify a Single Resource • Assign distinct URIs to distinct resources.

  9. Uniform Resource Identifiers URI RFC 3986 (2396) RFC 1738 URL RFC 2141 URN

  10. URI Schemes foo://username:password@example.com:8042/over/there/index.dtb;type=animal?name=ferret#nose \ / \________________/\_________/ \__/ \___/ \_/ \_________/ \_________/ \__/ | | | | | | | | | | userinfo hostname port | | parameter query fragment | \_______________________________/ \_____________|____|____________/ scheme | | | | | authority |path| | | | | path interpretable as filename | ___________|____________ | / \ / \ | urn:example:animal:ferret:nose interpretable as extension taken from: http://en.wikipedia.org/wiki/URI_scheme

  11. Important Web Architecture Concepts (As defined by the Web Architecture) • remember: • URIs identify Resources • Representations represent • Resources • When URIs are dereferenced, • they return representations • (i.e., a resource is never returned) taken from: http://www.w3.org/TR/webarch/

  12. W3C Web Architecture URI Represents Resource Represents Content Negotiation Representation 2 Representation 1 Identifies • The tools we have to solve the interoperability problem are: • Resource • URI • Representation slide from Herbert Van de Sompel

  13. LAMP • Chapters 3, 10 of textbook • more info: http://dev.mysql.com/doc/ • Quick review of relational databases • normalization • referential integrity • Basic MySQL commands

  14. “Graphic Novel” Super Heroes (from chapter 10) What if we need to add a super hero with more than 3 powers?

  15. 1st Normal Form • Eliminate repeating columns • Add primary key to table • Unique • Must not change • Maintain “atomicity“ • Each cell is atomic, has only one item of data

  16. 1NF • add primary key to tables • eliminate repeating columns • each attribute is atomic What if John Smith changes his name?

  17. 2nd Normal Form • Honor 1st Normal Form • Create separate tables for data duplicated across rows • Be aware of relationships! • 1:1 • 1:m • m:n

  18. 2NF • satisfy 1NF • create separate tables for data duplicated across rows Are “city“ and “state“ directly related to the lairs?

  19. 3rd Normal Form • Honor 1st & 2nd Normal Form • Create separate tables for any transitive or partial dependencies

  20. 3NF • satisfy 2NF • create separate tables for any transitive or partial dependencies see note on p. 283 on why good/evil is not in a separate table

  21. That’s About as Far As We’ll Go • Other normal forms are possible (BCNF, 4NF, 5NF) • take a database class if you’re interested • Referential integrity • a foreign key (“link”) into another table is no longer valid • “404 Errors” are bad in databases and should not happen • how bad is a function of the data itself…

  22. MySQL Hierarchy server=mln-web.cs.odu.edu database=tennisplayers database=superheroes table 1 table 2 table 1 table 2 table 3 table 3

  23. Manipulating Tables & Databases • CREATE - create new databases, tables • ALTER - modify existing tables • DELETE - erase data from tables • DESCRIBE - show structure of tables • INSERT INTO tablename VALUES - put data in table • UPDATE - modify data in tables • DROP - destroys table or database (values + structure) more: http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html

  24. Native MySQL Data Types • Unlike Perl, PHP and other civilized languages, MySQL is big into data types: • http://dev.mysql.com/doc/refman/5.0/en/data-types.html • many examples in chapter 3, 10

  25. SQL Query Form SELECT [fieldnames] FROM [tablenames] WHERE [criteria] ORDER BY [fieldname to sort on] [DESC] LIMIT [offset, maxrows] more: http://dev.mysql.com/doc/refman/5.0/en/select.html look at chapters 3 and 10 for code examples

More Related