{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

constraints-2011

# constraints-2011 - Constraints on Relations Foreign Keys...

This preview shows pages 1–11. Sign up to view the full content.

Constraints on Relations Foreign Keys Local and Global Constraints Triggers Following lecture slides are modified from Jeff Ullman’s slides  http://infolab.stanford.edu/~ullman/dscb.html#slides   1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Reading Ullman and Widom: Chapter 2.5 2
3 What is an “Algebra” Mathematical system consisting of: Operands --- variables or values from which new values can be constructed. Operators --- symbols denoting procedures that construct new values from given values.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Core Relational Algebra Union, intersection, and difference . Usual set operations, but both operands must have the same relation schema . Selection : picking certain rows. Projection : picking certain columns. Products and joins : compositions of relations. Renaming of relations and attributes.
5 5 Expression Tree: Bars Sells σ addr = “Maple St.” σ price<3 AND beer=“Bud” π name ρ R(name) π bar

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Why SQL? SQL is a very-high-level language. Say “what to do” rather than “how to do it.” Avoid a lot of data-manipulation details needed in procedural languages like C++ or Java. Database management system figures out “best” way to execute query. Called “query optimization.”
7 SQL Statement A typical SQL query form: SELECT A 1 , A 2 , . .., A n FROM r 1 , r 2 , . .., r m WHERE C A i s represent attributes to be returned r i s represent relations C is a condition

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 Our Running Example All our SQL queries will be based on the following database schema. Underline indicates key attributes. Beers(name , manf) Bars(name , addr, license) Drinkers(name , addr, phone) Likes(drinker , beer ) Sells(bar , beer , price) Frequents(drinker , bar )
9 Example Using Beers(name, manf) , what beers are made by Anheuser-Busch? π name ( σ manf = ’Anheuser-Busch’ Beers) or SELECT name FROM Beers WHERE manf = ’Anheuser-Busch’;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
* In SELECT clauses When there is one relation in the FROM clause, * in the SELECT clause stands for “all attributes of this relation.” Example : Using Beers(name, manf) : SELECT *
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 37

constraints-2011 - Constraints on Relations Foreign Keys...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online