Beruflich Dokumente
Kultur Dokumente
CS 186, Spring 2007, Lecture 2 Cow book Section 1.5, Chapter 3 Mary Roth
Administrivia
Homework 0
Due next Tuesday, Jan 23 10 p.m. Submission instructions added to homework description Class account forms here if you need them
Outline
What we learned last time
What is and what good is a DBMS anyway? Components of a DBMS
New stuff
A brief history of databases The relational data model
Buffer Management
Disk Space Management
DB
DB
Relational Operators
Access Methods Buffer Management Disk Space Management
2.
Graphically compose queries, look at data
3.
Embed database access in a program
4.
Embed database access in a web application
Web browser
Command line
GUI
JDBC/ODBC app
DBMS
Homework 5
Homework 3 (Pencil-work)
Homework 4 Homework 2 Homework 1 Provided for you
DB
Intermission
Get up and stretch Ask a quick question Get a drink of water
Ted Codd won the Turing award in 1981 Larry Ellison became a gillionaire
So whats the big deal about the relational data model? What is the first benefit of a DBMS?
Data independence
Student (sid: string, name: string, login: string, age: integer, gpa:real)
1010111101
If the data layout changed, the application had to change If you wanted to change the layout, you often had to bring the whole system down Changes had to occur over scheduled system down time.
Slow! Annoying! Expensive!
You can think of a relation as a set of rows or tuples. (Its basically a spread sheet!)
i.e., all rows are distinct
Cardinality = 3, arity = 5 , all rows distinct Do all values in each column of a relation instance
have to be distinct?
SQL Overview
CREATE TABLE <name> ( <field> <domain>, )
Can delete all tuples satisfying some condition (e.g., name = Smith):
Keys
Keys are a way to associate tuples in different relations
Enrolled
sid 53666 53666 53650 53666 cid grade Carnatic101 C Reggae203 B Topology112 A History105 B
Students
sid 53666 53688 53650 name login Jones jones@cs Smith smith@eecs Smith smith@math age 18 18 19 gpa 3.4 3.2 3.8
FOREIGN Key
PRIMARY Key
53688
Smith
smith@eecs 18 3.2
CS186
IMS requires
A change to add a field for CS186 A change to Smiths record to have him point to the new field
Enrolled
sid 53666 53666 53650 53666 53688 cid grade Carnatic101 C Reggae203 B Topology112 A History105 B CS186 A
Students
sid 53666 53688 53650 name login Jones jones@cs Smith smith@eecs Smith smith@math age 18 18 19 gpa 3.4 3.2 3.8
Write a SQL query (DML) that returns the names and account balances for all customers that have an account balance > 2500. Write a SQL query (DML) that withdraws $300 from Frodos account.