340 likes | 349 Views
Learn about relational set operators, advanced SQL JOIN operator syntax, subqueries and correlated queries, views, triggers, stored procedures, embedded SQL, and date and string manipulation functions.
E N D
Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel
In this chapter, you will learn: • About the relational set operators UNION, UNION ALL, INTERSECT, and MINUS • How to use the advanced SQL JOIN operator syntax • About the different types of subqueries and correlated queries • How to use SQL functions to manipulate dates, strings, and other data Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
In this chapter, you will learn (continued): • How to create and use updatable views • How to create and use triggers and stored procedures • How to create embedded SQL Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Relational Set Operators • UNION • INTERSECT • MINUS • Work properly if relations are union-compatible • Names of relation attributes must be the same and their data types must be identical Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
UNION • Example query: • SELECT CUS_LNAME, CUS_FNAME, CUS_INITIAL, CUS_AREACODE, CUS_PHONEFROM CUSTOMERUNIONSELECT CUS_LNAME, CUS_FNAME, CUS_INITIAL, CUS_AREACODE, CUS_PHONEFROM CUSTOMER_2; Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
UNION (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
UNION ALL • Example query: • SELECT CUS_LNAME, CUS_FNAME, CUS_INITIAL, CUS_AREACODE, CUS_PHONEFROM CUSTOMERUNION ALLSELECT CUS_LNAME, CUS_FNAME, CUS_INITIAL, CUS_AREACODE, CUS_PHONEFROM CUSTOMER_2; Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
UNION ALL (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
INTERSECT Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
MINUS Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Syntax Alternatives Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Syntax Alternatives (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
SQL Join Operators Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Cross Join • Syntax: • SELECT column-list FROM table1 CROSS JOIN table2 Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Natural Join Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
JOIN USING Clause Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
JOIN ON Clause Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Outer Joins • Returns not only matching rows, but also rows with unmatched attribute values for one table or both tables to be joined • Three types • Left • Right • Full Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Outer Joins (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Outer Joins (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Outer Joins (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Subqueries and Correlated Queries Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
WHERE Subqueries Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
IN Subqueries Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
HAVING Subqueries Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Multirow Subquery Operators: ANY and ALL Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
FROM Subqueries Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Attribute List Subqueries Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Attribute List Subqueries (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Correlated Subqueries Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Correlated Subqueries (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Date and Time Functions Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Date and Time Functions (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel
Date and Time Functions (continued) Database Systems: Design, Implementation, & Management, 7th Edition, Rob & Coronel