DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 7/8 Structured Query.

Slides:



Advertisements
Similar presentations
Relational Database and Data Modeling
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Chapter Eight: Database Redesign Database Processing: Fundamentals, Design, and Implementation.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 David M. Kroenke’s Chapter Eight: Database Redesign Database Processing:
Fundamentals, Design, and Implementation, 9/e Chapter 8 Database Redesign.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 9-1 COS 346 Day 20.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 David M. Kroenke’s Chapter Eight: Database Redesign Database Processing:
Concepts of Database Management Sixth Edition
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 2 Introduction to Database Development.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 2 Introduction to Database Development.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 10 Database Application Design.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 6-1 David M. Kroenke Database Processing Chapter 6 Transforming Data.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Prentice Hall © COS 346 Day Agenda Questions? Assignment 7 Corrected –4 A’s and 4 B’s Assignment 8 posted –Due April 6 Quiz 2 next class.
Getting Started (Excerpts) Chapter One DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
© 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 8-1 COS 346 Day 17.
Fundamentals, Design, and Implementation, 9/e Chapter 7 Using SQL in Applications.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 COS 346 Day 11.
Concepts of Database Management Sixth Edition
Database Systems More SQL Database Design -- More SQL1.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
David M. Kroenke and David J
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 7 Structured Query Language.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
Thomas Connolly and Carolyn Begg’s
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
Chapter 2 Introduction to Database Development Database Processing David M. Kroenke © 2000 Prentice Hall.
Chapter 4 The Relational Model Pearson Education © 2014.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
CSE314 Database Systems More SQL: Complex Queries, Triggers, Views, and Schema Modification Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
Database Technical Session By: Prof. Adarsh Patel.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
©2003 Prentice Hall Business Publishing, Accounting Information Systems, 9/e, Romney/Steinbart 4-1 Accounting Information Systems 9 th Edition Marshall.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 11-1 David M. Kroenke’s Chapter Eleven: Managing Databases with SQL Server.
Chapter 10 Database Application Design David M. Kroenke Database Processing © 2000 Prentice Hall.
IS 230Lecture 6Slide 1 Lecture 7 Advanced SQL Introduction to Database Systems IS 230 This is the instructor’s notes and student has to read the textbook.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 8/1 Copyright © 2004 Please……. No Food Or Drink in the class.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 9 Structured Query Language.
Fundamentals, Design, and Implementation, 9/e Chapter 8 Database Redesign.
Introduction to Databases Three File Processing Systems DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 1-2.
David M. Kroenke and David J. Auer Database Processing: F undamentals, Design, and Implementation Chapter Seven: SQL for Database Construction and Application.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Eight: Database Redesign.
Chapter 4 The Relational Model Pearson Education © 2009.
SQL Triggers, Functions & Stored Procedures Programming Operations.
CH 10 DB Application Design n 10.1 Functions n 10.2 Case Application n 10.3 Creating, Reading, Updating, Deleting View n 10.4 Form Design n 10.5 Report.
CSC314 DAY 9 Intermediate SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall USING AND DEFINING VIEWS  Views provide users controlled.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
David M. Kroenke and David J
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 4 The Relational Model Pearson Education © 2009.
Database Processing: David M. Kroenke’s Chapter Seven:
Session #, Speaker Name Views 1/2/2019.
Chapter 4 The Relational Model Pearson Education © 2009.
Database Processing: David M. Kroenke’s Chapter Seven:
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 8 Database Redesign
Database Systems: Design, Implementation, and Management Tenth Edition
© 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke
Presentation transcript:

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 7/8 Structured Query Language III

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-2 A View A view is a structured list of data attributes from the entities or semantic objects defined in the data model A view is a virtual table whose contents are defined by a query A view can be materialized or formatted as an on-line form or a hard-copy report

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-3 Why Views? 1.Security User authorized access 2.Query Simplicity Multi-table queries become single-table results 3.Structural Simplicity User personalized access 4.Insulation from Change Presents consistent image of DB 5.Data Integrity Data access, entry via view can be checked via DBMS

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-4 Why Not? 1.Performance 2.Update Restrictions 3.Views are not backups!

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-5 Creating Views Must have permission If columns specified, query select must match Data type, length & constraints derived from source tables

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-6 Types of Views Horizontal Vertical Row/Column Subset Grouped Joined

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-7 Horizontal Views CREATE VIEW viewname AS query; Show Eastern region salespeople DROP VIEW eastreps; CREATE VIEW eastreps AS select * from salesreps where rep_office in ( select office from offices where region = ‘Eastern’);

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-8 Joined Views Show the orders and amounts, but with names of employees & customers instead of numbers. DROP VIEW order_info; CREATE VIEW order_info AS select order_num, name, company, amount from orders, salesreps, customers where rep=empl_num and cust=cust_num;

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-9 Update of View also updates underlying table, but view must meet certain conditions: Must have update privileges View must be 1:1 w/underlying table One table only Updating a View

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-10 Insert into Eastreps (empl_num, name, rep_office, hire_date) values (113, ‘Jake Kimball’, 11, ’14-apr-2003’); Insert into Order_Info (order_num, name, company, amount) values (999999, ‘New Rep’, ‘New Co’, 50000); Updating a View

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-11 Triggers Triggers are stored procedures that are invoked at a given time based on an action. –Time: Before, After, Instead Of –Actions: Insert, Delete, Update Advantages: Auditing, Cascade, Enforce Relationships, Procedure Invocation Disadvantages: Performance

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-12 Triggers create trigger after_insert_bkup after insert on orders begin insert into ordersbkup select * from orders where not exists (select * from ordersbkup where ordersbkup.order_num = orders.order_num); end ;

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-13 Correlated Subquery A correlated subquery looks similar to a regular subquery A regular subquery can be processed from the bottom up For a correlated subquery, the processing is nested, i.e., a row from an upper query statement is used in comparison with rows in a lower-level query Useful in checking for duplicates

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-14 Database Redesign Three principles for database redesign: –Measure twice and cut once: understand the current structure and contents of the database before making any structure changes –Test the new changes on a test database before making real changes –Create a complete backup of the operational database before making any structure changes Technique: Reverse Engineering (RE)

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-15 Reverse Engineering (RE) Reverse engineering (RE) is the process of reading and producing a data model from a database schema A reverse engineered (RE) data model: –Provides a basis to begin the database redesign project –Is neither truly a conceptual nor an internal schema as it has characteristics of both –Should be carefully reviewed because it almost always has missing information

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-16 Database Backup and Test Databases Before making any changes to an operational database: –A complete backup of the operational database should be made –Any proposed changes should be thoroughly tested Three different copies of the database schema used in the redesign process: –A small test database for initial testing –A large test database for secondary testing –The operational database

DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-17 Database Redesign Changes Changing tables and columns –Changing table names –Adding and dropping table columns –Changing data type or constraints –Adding and dropping constraints Changing relationships –Changing cardinalities –Adding and deleting relationships –Adding and removing relationship for de- normalization