DOC PREVIEW
UT Dallas CS 6360 - Ch05

This preview shows page 1-2-3-19-20-39-40-41 out of 41 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 41 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

PowerPoint PresentationChapter 5 OutlineMore Complex SQL Retrieval QueriesComparisons Involving NULL and Three-Valued LogicComparisons Involving NULL and Three-Valued Logic (cont’d.)Slide 6Nested Queries, Tuples, and Set/Multiset ComparisonsNested Queries (cont’d.)Slide 9Slide 10Slide 11Correlated Nested QueriesThe EXISTS and UNIQUE Functions in SQLExplicit Sets and Renaming of Attributes in SQLJoined Tables in SQL and Outer JoinsJoined Tables in SQL and Outer Joins (cont’d.)Slide 17Aggregate Functions in SQLAggregate Functions in SQL (cont’d.)Grouping: The GROUP BY and HAVING ClausesResults of GROUP BYResults of GROUP BY and HAVINGSlide 23Grouping: The GROUP BY and HAVING Clauses (cont’d.)Discussion and Summary of SQL QueriesSpecifying Constraints as Assertions and Actions as TriggersSpecifying General Constraints as Assertions in SQLIntroduction to Triggers in SQLViews (Virtual Tables) in SQLSpecification of Views in SQLSpecification of Views in SQL (cont’d.)View Implementation, View Update, and Inline ViewsView ImplementationView Implementation (cont’d.)View Update and Inline ViewsView Update and Inline Views (cont’d.)Schema Change Statements in SQLThe DROP CommandThe ALTER CommandThe ALTER Command (cont’d.)SummaryCopyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-WesleyChapter 5More SQL: Complex Queries, Triggers, Views, and Schema ModificationCopyright © 2011 Ramez Elmasri and Shamkant NavatheChapter 5 OutlineMore Complex SQL Retrieval QueriesSpecifying Constraints as Assertions and Actions as TriggersViews (Virtual Tables) in SQLSchema Change Statements in SQLCopyright © 2011 Ramez Elmasri and Shamkant NavatheMore Complex SQL Retrieval QueriesAdditional features allow users to specify more complex retrievals from database:Nested queries, joined tables, outer joins, aggregate functions, and groupingCopyright © 2011 Ramez Elmasri and Shamkant NavatheComparisons Involving NULLand Three-Valued LogicMeanings of NULLUnknown valueUnavailable or withheld valueNot applicable attributeEach individual NULL value considered to be different from every other NULL valueSQL uses a three-valued logic:TRUE, FALSE, and UNKNOWNCopyright © 2011 Ramez Elmasri and Shamkant NavatheComparisons Involving NULLand Three-Valued Logic (cont’d.)Copyright © 2011 Ramez Elmasri and Shamkant NavatheComparisons Involving NULLand Three-Valued Logic (cont’d.)SQL allows queries that check whether an attribute value is NULLIS or IS NOT NULLCopyright © 2011 Ramez Elmasri and Shamkant NavatheNested Queries, Tuples,and Set/Multiset ComparisonsNested queriesComplete select-from-where blocks within WHERE clause of another queryOuter queryComparison operator INCompares value v with a set (or multiset) of values V Evaluates to TRUE if v is one of the elements in VCopyright © 2011 Ramez Elmasri and Shamkant NavatheNested Queries (cont’d.)Copyright © 2011 Ramez Elmasri and Shamkant NavatheNested Queries (cont’d.)Use tuples of values in comparisons Place them within parenthesesCopyright © 2011 Ramez Elmasri and Shamkant NavatheUse other comparison operators to compare a single value v = ANY (or = SOME) operator •Returns TRUE if the value v is equal to some value in the set V and is hence equivalent to INOther operators that can be combined with ANY (or SOME): >, >=, <, <=, and <>Nested Queries (cont’d.)Copyright © 2011 Ramez Elmasri and Shamkant NavatheNested Queries (cont’d.)Avoid potential errors and ambiguitiesCreate tuple variables (aliases) for all tables referenced in SQL queryCopyright © 2011 Ramez Elmasri and Shamkant NavatheCorrelated Nested QueriesCorrelated nested query Evaluated once for each tuple in the outer queryCopyright © 2011 Ramez Elmasri and Shamkant NavatheThe EXISTS and UNIQUE Functions in SQLEXISTS function Check whether the result of a correlated nested query is empty or notEXISTS and NOT EXISTS Typically used in conjunction with a correlated nested querySQL function UNIQUE(Q)Returns TRUE if there are no duplicate tuples in the result of query QCopyright © 2011 Ramez Elmasri and Shamkant NavatheExplicit Sets and Renaming of Attributes in SQLCan use explicit set of values in WHERE clauseUse qualifier AS followed by desired new nameRename any attribute that appears in the result of a queryCopyright © 2011 Ramez Elmasri and Shamkant NavatheJoined Tables in SQL and Outer JoinsJoined tablePermits users to specify a table resulting from a join operation in the FROM clause of a queryThe FROM clause in Q1A Contains a single joined tableCopyright © 2011 Ramez Elmasri and Shamkant NavatheJoined Tables in SQL and Outer Joins (cont’d.)Inner joinDefault type of join in a joined tableTuple is included in the result only if a matching tuple exists in the other relationCopyright © 2011 Ramez Elmasri and Shamkant NavatheJoined Tables in SQL and Outer Joins (cont’d.)LEFT OUTER JOIN Every tuple in left table must appear in resultIf no matching tuple•Padded with NULL values for attributes of right tableRIGHT OUTER JOINEvery tuple in right table must appear in resultIf no matching tuple•Padded with NULL values for the attributes of left tableFULL OUTER JOINCopyright © 2011 Ramez Elmasri and Shamkant NavatheAggregate Functions in SQLUsed to summarize information from multiple tuples into a single-tuple summaryBuilt-in aggregate functions COUNT, SUM, MAX, MIN, and AVGFunctions can be used in the SELECT clause or in a HAVING clauseGrouping Create subgroups of tuples before summarizingCopyright © 2011 Ramez Elmasri and Shamkant NavatheAggregate Functions in SQL (cont’d.)NULL values discarded when aggregate functions are applied to a particular columnCopyright © 2011 Ramez Elmasri and Shamkant NavatheGrouping: The GROUP BY and HAVING ClausesPartition relation into subsets of tuplesBased on grouping attribute(s)Apply function to each such group independentlyGROUP BY clause Specifies grouping attributesIf NULLs exist in grouping attribute Separate group created for all tuples with a NULL value in grouping attributeCopyright © 2011 Ramez Elmasri and Shamkant NavatheResults of GROUP BYCopyright © 2011 Ramez Elmasri and Shamkant NavatheResults of GROUP BY and HAVINGCopyright © 2011 Ramez Elmasri and Shamkant NavatheResults of GROUP BY and


View Full Document

UT Dallas CS 6360 - Ch05

Documents in this Course
Ch22(1)

Ch22(1)

44 pages

Ch21

Ch21

38 pages

Ch19

Ch19

46 pages

Ch18

Ch18

25 pages

Ch17

Ch17

21 pages

Ch15

Ch15

42 pages

Ch09

Ch09

42 pages

Ch05

Ch05

34 pages

Ch22

Ch22

45 pages

Ch21

Ch21

38 pages

Ch19

Ch19

48 pages

Ch18

Ch18

24 pages

Ch17

Ch17

22 pages

Ch16

Ch16

17 pages

Ch15

Ch15

42 pages

Ch09

Ch09

42 pages

Ch08

Ch08

39 pages

Ch07

Ch07

34 pages

Ch06

Ch06

43 pages

Ch05

Ch05

34 pages

Ch04

Ch04

39 pages

Ch03(2)

Ch03(2)

36 pages

Ch02

Ch02

33 pages

Ch08

Ch08

28 pages

Ch07

Ch07

31 pages

Ch06

Ch06

43 pages

Ch05

Ch05

39 pages

Ch04(1)

Ch04(1)

39 pages

Ch03(1)

Ch03(1)

38 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch24

Ch24

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

48 pages

Ch18

Ch18

24 pages

Ch17

Ch17

22 pages

Ch03(1)

Ch03(1)

38 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch24

Ch24

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

48 pages

Ch18

Ch18

24 pages

Ch17

Ch17

22 pages

Ch08

Ch08

28 pages

Ch07

Ch07

31 pages

Ch06

Ch06

43 pages

Ch05

Ch05

39 pages

Ch04(1)

Ch04(1)

39 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04

Ch04

43 pages

Ch03

Ch03

41 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch18

Ch18

24 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04

Ch04

43 pages

Ch03

Ch03

41 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch18

Ch18

24 pages

Ch17

Ch17

25 pages

lab-manual

lab-manual

215 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch04

Ch04

43 pages

Ch03

Ch03

41 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch17

Ch17

25 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch18

Ch18

24 pages

Ch17

Ch17

25 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04

Ch04

43 pages

Ch03

Ch03

41 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Ch04(1)

Ch04(1)

43 pages

Ch07

Ch07

40 pages

Ch03

Ch03

42 pages

Ch01

Ch01

36 pages

Ch02

Ch02

38 pages

Ch05

Ch05

41 pages

Ch06

Ch06

47 pages

Ch08

Ch08

39 pages

Ch17

Ch17

25 pages

Ch18

Ch18

24 pages

Ch09

Ch09

42 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch21

Ch21

54 pages

Ch19

Ch19

51 pages

Ch18

Ch18

24 pages

Ch17

Ch17

25 pages

Ch09

Ch09

42 pages

Ch08

Ch08

39 pages

Ch07

Ch07

40 pages

Ch06

Ch06

47 pages

Ch05

Ch05

41 pages

Ch04(1)

Ch04(1)

43 pages

Ch03

Ch03

42 pages

Ch02

Ch02

38 pages

Ch01

Ch01

36 pages

Load more
Download Ch05
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Ch05 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Ch05 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?