constraints-2011

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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Reading Ullman and Widom: Chapter 2.5 2
Background image of page 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.
Background image of page 3

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

View Full DocumentRight Arrow Icon
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.
Background image of page 4
5 5 Expression Tree: Bars Sells σ addr = “Maple St.” σ price<3 AND beer=“Bud” π name ρ R(name) π bar
Background image of page 5

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

View Full DocumentRight Arrow Icon
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.”
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
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 )
Background image of page 8
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’;
Background image of page 9

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

View Full DocumentRight Arrow Icon
* 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 *
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/13/2011 for the course CSCE 520 taught by Professor Farkas during the Spring '11 term at South Carolina.

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 Right Arrow Icon
Ask a homework question - tutors are online