Problem%20Session%205 - PowerPoint PPT Presentation

About This Presentation
Title:

Problem%20Session%205

Description:

Title: CS206 --- Electronic Commerce Author: Jeff Ullman Last modified by: Yusheng Yang Created Date: 3/23/2002 8:14:09 PM Document presentation format – PowerPoint PPT presentation

Number of Views:94
Avg rating:3.0/5.0
Slides: 17
Provided by: Jeff589
Category:

less

Transcript and Presenter's Notes

Title: Problem%20Session%205


1
Problem Session 5
CS145 Autumn 2007
  • Midterm Review

Yusheng Yang Stanford University 10/29/2007
2
Outline
CS145 Autumn 2007
  • Announcements
  • SQL
  • Transactions
  • DTDs
  • QA

3
Announcements
CS145 Autumn 2007
  • Project 1 due Wed 10/31
  • Gradiance one due Fri 11/2, two due Wed 11/7
  • Midterm Wed 10/31 11am-1215pm Gates B01
  • Up to and including 10/24 lecture on XPath
  • Open notes/book/laptop. Closed Internet.

4
SQL
CS145 Autumn 2007
SQL
Transactions
DTDs
SQL
5
From 2005 Midterm
CS145 Autumn 2007
Consider a table Exams(student, score). Write a
SQL query to find the student with the highest
score differential, i.e. the student with the
largest spread between his or her highest and
lowest scores, among all students with scores in
the table. Assume there is a unique student with
the highest spread and return that student only
once.
SQL
6
Sample Solution
CS145 Autumn 2007
SELECT student FROM Exams GROUP BY student HAVING
MAX(score) - MIN(score) gt ALL( SELECT
MAX(score) - MIN(score) FROM Exams WHERE score
IS NOT NULL GROUP BY student )
SQL
7
Transactions
CS145 Autumn 2007
SQL
Transactions
DTDs
Transactions
8
From Lecture
CS145 Autumn 2007
Joe_Sells(beer, price). Initially (Bud, 2.50)
and (Miller, 3). Sally BEGIN TRANSACTION S1
SELECT MAX(price) FROM Joe_Sells S2 SELECT
MIN(price) FROM Joe_Sells COMMIT Joe BEGIN
TRANSACTION S3 DELETE FROM Joe_Sells S4 INSERT
INTO Joe_Sells VALUES(Heineken,
3.50) COMMIT Suppose S1,S3,S4,Joe
commits,S2,Sally commits.
Transactions
9
Solution
CS145 Autumn 2007
  • Sally SERIALIZABLE MAX 3.00, MIN 2.50.
  • Sally REPEATABLE READ MAX 3.00, MIN 2.50.
    Sally saw a phantom tuple (Heineken, 3.50).
  • Sally READ COMMITTED MAX 3.00, MIN 3.50.
    Sally saw Joes committed deletion.
  • Sally READ UNCOMMITTED MAX 3.00, MIN
    3.50. Sally saw Joes uncommitted deletion.
  • Question What isolation level do you think
    Oracle supports as a default?
  • Answer REPEATABLE READ. Guarantees no loss of
    data.

Transactions
10
DTDs
CS145 Autumn 2007
SQL
Transactions
DTDs
DTDs
11
From 2006 Midterm
CS145 Autumn 2007
  • DTD1 lt!DOCTYPE SP
  • lt!ELEMENT SP (Project)gt
  • lt!ELEMENT Project (Title, Student)gt
  • lt!ATTLIST Project ProjNum IDgt
  • lt!ELEMENT Title (PCDATA)gt
  • lt!ELEMENT Studentgt
  • lt!ATTLIST Student StudID ID Name CDATAgt gt
  • For each project, there is
  • a) exactly one student b) at least one student
  • For each student, there is
  • a) exactly one project b) at least one project
  • Answer 1b, 2a

DTDs
12
From 2006 Midterm
CS145 Autumn 2007
  • DTD2 lt!DOCTYPE SP
  • lt!ELEMENT SP (Student)gt
  • lt!ELEMENT Student (Project)gt
  • lt!ATTLIST Student StudID ID Name CDATAgt
  • lt!ELEMENT Project (Title)gt
  • lt!ATTLIST Project ProjNum IDgt
  • lt!ELEMENT Title (PCDATA)gt gt
  • For each project, there is
  • a) exactly one student b) at least one student
  • For each student, there is
  • a) exactly one project b) at least one project
  • Answer 1a, 2a

DTDs
13
From 2006 Midterm
CS145 Autumn 2007
  • DTD3 lt!DOCTYPE SP
  • lt!ELEMENT SP (Project, Student)gt
  • lt!ELEMENT Project (Title)gt
  • lt!ATTLIST Project ProjNum ID stud IDREFgt
  • lt!ELEMENT Title (PCDATA)gt
  • lt!ELEMENT Studentgt
  • lt!ATTLIST Student StudID ID Name CDATAgt gt
  • For each project, there is
  • a) exactly one student b) at least one student
  • For each student, there is
  • a) exactly one project b) at least zero
    projects
  • Answer 1a, 2b

DTDs
14
From 2006 Midterm
CS145 Autumn 2007
  • DTD4 lt!DOCTYPE SP
  • lt!ELEMENT SP (Student, Project)gt
  • lt!ELEMENT Studentgt
  • lt!ATTLIST Student StudID ID Name CDATA proj
    IDREFSgt
  • lt!ELEMENT Project (Title)gt
  • lt!ATTLIST Project ProjNum IDgt
  • lt!ELEMENT Title (PCDATA)gt gt
  • For each project, there is
  • a) exactly one student b) at least zero students
  • For each student, there is
  • a) exactly one project b) at least one project
  • Answer 1b, 2b

DTDs
15
Midterm Topics
CS145 Autumn 2007
Relational Algebra union/intersect/difference/s
elect/project/product/join/rename SQL
select/from/where SQL multirelational queries
SQL subqueries SQL outerjoins SQL
group by/having SQL insert/delete/update
SQL constraints SQL triggers SQL
transactions SQL views SQL indexes
XML DTDs XML XML Schema XML XPath
16
Q A
CS145 Autumn 2007
  • Questions?
  • lecture notes
  • Coursework Discussion
  • Office Hours (Mon 1-2 Gates 433, Tue 1-4, 8-11pm
    Gates B24A)
  • cs145-aut0708-staff_at_lists.stanford.edu
Write a Comment
User Comments (0)
About PowerShow.com