Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Programming Week 2 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 09/07/10.

Similar presentations


Presentation on theme: "Web Programming Week 2 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 09/07/10."— Presentation transcript:

1 Web Programming Week 2 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 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 How To Read RFCs (quoting from RFC 2119) 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.)

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 –Global naming leads to global network effects.

7 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 –Assign distinct URIs to distinct resources.

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

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_schemehttp://en.wikipedia.org/wiki/URI_scheme

11 Important Web Architecture Concepts http://www.cs.odu.edu/~mklein/ URIs Identify Represent Martin Klein -- Old Dominion University … Representations As defined by the Web Architecture http://www.w3.org/TR/webarch/

12 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/ Important Web Architecture Concepts (As defined by the Web Architecture)

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

14

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

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

17 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

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

19 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

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

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

22 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

23 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…

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

25 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.htmlhttp://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html

26 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.htmlhttp://dev.mysql.com/doc/refman/5.0/en/data- types.html –many examples in chapter 3, 10

27 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.htmlhttp://dev.mysql.com/doc/refman/5.0/en/select.html look at chapters 3 and 10 for code examples


Download ppt "Web Programming Week 2 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 09/07/10."

Similar presentations


Ads by Google