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’

Slides:



Advertisements
Similar presentations
Chapter 23 Database Security and Authorization Copyright © 2004 Pearson Education, Inc.
Advertisements

Introduction to Structured Query Language (SQL)
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
De-normalize if… Performance is unsatisfactory Table has a low update rate –(sacrifice flexibility) Table has a high query rate –(speed up retrieval)
Introduction to Structured Query Language (SQL)
Concepts of Database Management, 4th Edition, Pratt & Adamski
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
View Sen Zhang. Views are very common in business systems users view of data is simplified a form of security - user sees only the data he/she needs to.
Concepts of Database Management Sixth Edition
Introduction to Structured Query Language (SQL)
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
Introduction to DBMS and SQL Introduction to DBMS and SQL GUIDED BY : MR. YOGESH SAROJ (PGT-CS) MR. YOGESH SAROJ (PGT-CS) Presented By : JAYA XII –COM.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
With Microsoft Access 2007 Volume 1© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access 2007 Volume 1 Chapter.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
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.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Introduction to SQL.
Introduction to SEQUEL. What is SEQUEL? Acronym for Structural English Query Language Acronym for Structural English Query Language Standard language.
1 Database Administration. 2 Objectives  Understand, create, and drop views  Grant and revoke users’ privileges  Understand and obtain information.
Chapter 6 Database Administration
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.
Maintaining a Database Access Project 3. 2 What is Database Maintenance ?  Maintaining a database means modifying the data to keep it up-to-date. This.
1 CSE 2337 Introduction to Data Management Access Book – Ch 1.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Week 5 Lecture 2 Data Integrity Constraints. Learning Objectives  Learn the types and the uses of constraints  Examine the syntax and options for creating.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Database Programming Sections 11 & 12 –Sequences, Indexes, and Synonymns.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
DBAdmin D D D D D a a a a a t t t t t a a a a a b b b b b a a a a a s s s s s e e e e eAdministration / Embedded SQL by: Glen Orsburn Chapter 6.
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
Session 1 Module 1: Introduction to Data Integrity
Chapter 4 Indexes. Indexes Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage; composed.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
A Guide to MySQL 6. 2 Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT command.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
SQL Basics Review Reviewing what we’ve learned so far…….
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Controlling User Access
TABLES AND INDEXES Ashima Wadhwa.
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
SQL Creating and Managing Tables
SQL Creating and Managing Tables
Chapter 8 Working with Databases and MySQL
SQL Creating and Managing Tables
Chapter 4 Indexes.
CH 4 Indexes.
Chapter 2 Views.
SQL DATA CONSTRAINTS.
A Guide to SQL, Eighth Edition
CH 4 Indexes.
Chapter 2 Views.
IST 318 Database Administration
Presentation transcript:

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’ database privileges Understand the purpose, advantages, and disadvantages of using an index

A Guide to MySQL 3 Objectives (continued) Create, use, and drop an index Understand and obtain information from the system catalog Use integrity constraints to control data entry

A Guide to MySQL 4 Defining and Using Views View: an application program’s or individual user’s picture of the database Base tables: existing, permanent tables in a relational database View is a derived table because data in it is retrieved from the base table

A Guide to MySQL 5 Defining and Using Views (continued) Not supported in MySQL 4.1; is supported in MySQL 5.0 Usually includes less information than full database: –Simplifies data processing for the user –Provides a measure of security by omitting sensitive information  unavailable to user

A Guide to MySQL 6 Defining and Using Views (continued) Created by a defining query: i ndicates rows and columns to include Uses CREATE VIEW command: CREATE VIEW, followed by name of view, AS, and then query

A Guide to MySQL 7 Defining and Using Views (continued)

A Guide to MySQL 8 Defining and Using Views (continued)

A Guide to MySQL 9 Defining and Using Views (continued) Data shown Figure 7-2 does not exist in this form Not a temporary table To query a view, merge query that created view with query to select specific data

A Guide to MySQL 10 Defining and Using Views (continued)

A Guide to MySQL 11 Defining and Using Views (continued)

A Guide to MySQL 12 Can assign column names in view that are different than base table Include new column names in parentheses, following the name of the view Output will display new column names Defining and Using Views (continued)

A Guide to MySQL 13 Defining and Using Views (continued)

A Guide to MySQL 14 Defining query of view can be any valid SQL query View can join two or more tables Defining and Using Views (continued)

A Guide to MySQL 15 Defining and Using Views (continued)

A Guide to MySQL 16 Defining and Using Views (continued)

A Guide to MySQL 17 Defining and Using Views (continued)

A Guide to MySQL 18 Benefits of views: –Provide data independence –Can often be used even after database structure changes –Different users can view same data differently –A view can contain only those columns required by a given user Defining and Using Views (continued)

A Guide to MySQL 19 Using a View to Update Data Benefits of views are for retrieval purposes only Updating data through a view is dependent on type of view

A Guide to MySQL 20 Updating Row-and-Column Subset Views Can update (usually) if view contains primary key Cannot update when primary key not included

A Guide to MySQL 21 No primary key Updating Row-and-Column Subset Views (continued)

A Guide to MySQL 22 Updating Views Involving Joins

A Guide to MySQL 23 Updating Views Involving Joins (continued)

A Guide to MySQL 24 Updating Views Involving Joins (continued) Can update when a view is derived by joining two tables on primary key of each table Cannot update when view involves joining by matching the primary key of one table with a column that is not the primary key Encounter more severe problems if neither of the join columns is a primary key

A Guide to MySQL 25 Updating Views Involving Statistics Most difficult to update Cannot add rows to a view that includes calculations

A Guide to MySQL 26 Dropping a View Remove a view that is no longer needed with DROP VIEW command The DROP VIEW command removes only the view definition; base table and data remain unchanged

A Guide to MySQL 27 Security Prevention of unauthorized access to a database: –Some users may be able to retrieve and update anything in database –Other users may be able to retrieve data but not change data –Other users may be able to access only a portion of data

A Guide to MySQL 28 Security (continued) GRANT command: main mechanism for providing access to database Database administrator can grant different types of privileges to users and revoke them later Privileges include rights to select, insert, update, index, and delete table data

A Guide to MySQL 29 Security (continued) Database administrator uses REVOKE command to remove privileges from users Format is similar to GRANT command

A Guide to MySQL 30 Indexes Speeds up the searching of tables Similar to an index in a book

A Guide to MySQL 31 Indexes (continued)

A Guide to MySQL 32 Indexes (continued) MySQL manages indexes User determines columns on which to build indexes Disadvantages: –Index occupies disk space –DBMS must update index as data is entered

A Guide to MySQL 33 Creating an Index Use CREATE INDEX command: –Name the index –Identify the table –Identify the column or columns

A Guide to MySQL 34 Creating an Index (continued)

A Guide to MySQL 35 Dropping an Index Use DROP INDEX to delete an index: DROP INDEX followed by name of index to drop Permanently deletes index

A Guide to MySQL 36 Creating Unique Indexes To ensure uniqueness of non-primary key data, you can create a unique index; use CREATE UNIQUE INDEX command A unique index will reject any update that would cause a duplicate value in the specified column

A Guide to MySQL 37 System Catalog Contains information about tables in database; also called data dictionary Use SHOW TABLES command to list all tables in database Use SHOW COLUMNS command to list all columns in a table Use SHOW INDEX command to list all indexes in a table Use SHOW GRANTS command to list privileges

A Guide to MySQL 38 System Catalog (continued)

A Guide to MySQL 39 System Catalog (continued)

A Guide to MySQL 40 System Catalog (continued)

A Guide to MySQL 41 System Catalog (continued)

A Guide to MySQL 42 Integrity Constraints in SQL Rule for the data in the database Examples in Premiere Products: –A sales rep’s number must be unique –The sales rep number for a customer must match an exiting sales rep number –Item classes for parts must be AP, HW, or SG

A Guide to MySQL 43 Integrity Constraints in SQL (continued) Integrity support: process of specifying integrity constraints for the database Clauses to support integrity constraints can be specified within a CREATE TABLE or ALTER TABLE command: –ADD PRIMARY KEY –ADD FOREIGN KEY

A Guide to MySQL 44 Integrity Constraints in SQL (continued) Primary keys: use ADD PRIMARY KEY clause on ALTER TABLE command to add after creating a table Foreign keys: column in one table whose value matches the primary key in another Legal values: the CHECK clause ensures only legal values are allowed in a given column

A Guide to MySQL 45 Integrity Constraints in SQL (continued)

A Guide to MySQL 46 Integrity Constraints in SQL (continued) Error messages refer to parent and child When specifying a foreign key, table containing foreign key is the child Table referenced by foreign key is parent

A Guide to MySQL 47 Summary Views (purpose, creation, and use) Security features (GRANT, REVOKE) Indexes (purpose, creation, and use) Dropping indexes System catalog information Integrity constraints