Extra slides, week 9

CSE 190 M (Web Programming) Spring 2008

University of Washington

References: SQL syntax reference, w3schools tutorial

Except where otherwise noted, the contents of this presentation are © Copyright 2008 Marty Stepp, Jessica Miller, and Amit Levy, and are licensed under the Creative Commons Attribution 2.5 License.

Valid XHTML 1.1 Valid CSS!

Entities and relationships

ER diagram

The SQL INSERT statement

INSERT INTO table
VALUES (value, value, ..., value);
INSERT INTO Student 
VALUES (789, "Nelson", "muntz@fox.com");

The SQL UPDATE statement

UPDATE table
SET column = value,
    ...,
    column = value
WHERE column = value;
UPDATE Student
SET    email = "lisasimpson@gmail.com"
WHERE  SID = 888;

The SQL CREATE TABLE statement

CREATE TABLE name (
    columnName type constraints,
    ...
    columnName type constraints
);
CREATE TABLE Student (
    SID INTEGER UNSIGNED NOT NULL PRIMARY KEY,
    name VARCHAR(20),
    email VARCHAR(32)
);

SQL data types