4. SQL - CSCI 2541 Databases

4. SQL

CSCI 2541 Database Systems & Team Projects

Wood & Chaufournier

Slides adapted from Prof. Bhagi Narahari; Silberschatz, Korth, and Sudarshan; and Ramakrishnan, Gerhke, and Lawrence

Last time...

Relational Model & Algebra

SQL DDL

SQL DML

this time...

2

SQL: Structured Query Language

The standard language for relational data

Invented by folks at IBM, esp. Don Chamberlin

Actually not a great language...

Beat a more elegant competing standard, QUEL, from

Berkeley

Separated into a DML & DDL

Data Definition (DDL) ? to define schema/tables

Define Schema

Define Constraints

Data Manipulation (DML) component based on relational algebra & calculus

GW CSCI 2541 Databases: Wood & Chaufournier

3

SQL Hello World

Create a table

CREATE TABLE Instructor ( id INT, name VARCHAR(50),

I department VARCHAR(5),

office DECIMAL(4), PRIMARY KEY (id) );

GW CSCI 2541 Databases: Wood & Chaufournier

4

SQL Hello World

Create a table

CREATE TABLE Instructor ( id INT, name VARCHAR(50), department VARCHAR(5), office DECIMAL(4), PRIMARY KEY (id)

);

Insert a row

INSERT INTO Instructor (id, name, department, office) VALUES (2, 'Roberto Finlaison', 'CIVIL', 185);

Haw

GW CSCI 2541 Databases: Wood & Chaufournier

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download