SlideShare a Scribd company logo
A Guide to SQL, Ninth Edition
Chapter Seven
Database Administration
Objectives
• Understand, create, 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
2
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Objectives (continued)
• Create, use, and drop an index
• Understand and obtain information from the
system catalog
• Use integrity constraints to control data entry
3
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Introduction
• Database administration
– Process of managing a database
• Database administrator
– Person or entire group in a business
organization charged with managing the
database
4
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Creating and Using Views
• View
– A 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
5
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Creating and Using Views
(continued)
• 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
6
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Creating and Using Views
(continued)
• Created by a defining query
– Indicates rows and columns to include
• Use CREATE VIEW command
– CREATE VIEW, followed by name of view, AS, and
then defining query
7
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Creating and Using Views
(continued)
8
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-1: Creating the TOYS view
Creating and Using Views
(continued)
9
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-2: TOYS view
Creating and Using Views
(continued)
• Data shown in 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
10
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Creating and Using Views
(continued)
11
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-3: Maria’s view of the ITEM table
Creating and Using Views
(continued)
12
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-4: Using the TOYS view
Creating and Using Views
(continued)
13
SELECT ITEM_NUM, DESCRIPTION, ON_HAND, PRICE
FROM ITEM
WHERE CATEGORY =‘TOY’
AND PRICE > 100;
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
• Actual query executed by SQL
Creating and Using Views
(continued)
• 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
14
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Creating and Using Views
(continued)
15
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-5: Renaming columns when creating a view
Creating and Using Views
(continued)
16
• Defining query of view can be any valid SQL query
• View can join two or more tables
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-7: Creating the REP_CUST view
Creating and Using Views
(continued)
17
• A view can involve statistics
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-9: Creating the CRED_CUST view
Creating and Using Views
(continued)
• Benefits of views
– Provide data independence
• Can often be used even after database structure
changes
– Different users can view same data differently
• Customize display to meet each user’s needs
– A view can contain only those columns required
by a given user
• Simplifies user’s perception of database
• Provides a measure of security
18
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
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
19
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Updating Row-and-Column Subset
Views
20
• Can update (usually) if view contains primary key
• Cannot update when primary key is not included
No primary key
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Updating Views Involving Joins
• 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
21
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Updating Views Involving Statistics
• Most difficult to update
• Cannot add rows to a view that includes
calculations
22
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
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
23
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
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
24
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
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
25
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Security (continued)
• Database administrator uses REVOKE
command to remove privileges from users
• Format is similar to GRANT command
26
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Indexes
• Speeds up the searching of tables
• Similar to an index in a book
27
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-19: Index for the CUSTOMER table on the CUSTOMER_NUM column
Indexes (continued)
28
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-20: Indexes for the CUSTOMER table on the CREDIT_LIMIT and REP_NUM columns
Indexes (continued)
• SQL manages indexes
• User determines columns on which to
build indexes
• Disadvantages
– Index occupies disk space
– DBMS must update index as data is entered
29
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Creating an Index
• Use CREATE INDEX command
– Name the index
– Identify the table
– Identify the column or columns
30
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Creating an Index (continued)
31
Index on a single column
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-21: Creating the BALIND index on the BALANCE column
Creating an Index (continued)
32
Index on two columns
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-22: Creating the REP_NAME index on the LAST_NAME and FIRST_NAME columns
Dropping an Index
• Use DROP INDEX to delete an index
– DROP INDEX followed by name of index to drop
• Permanently deletes index
33
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
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
34
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
System Catalog
• Contains information about tables in database;
also called data dictionary
• Use SYSTABLES to list all tables in database
• Use SYSCOLUMNS to list all columns in a table
• Use SYSVIEWS to list information about views
35
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
System Catalog (continued)
• In Oracle, use:
– DBA_TABLES to list information about tables
– DBA_TAB_COLUMNS to list information
about columns
– DBA_VIEWS to list information about views
36
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Update of the System Catalog
• DBMS updates automatically when
– Create, alter, drop tables
– Create or drop indexes
• Users should not update catalog directly
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 37
Integrity Constraints in SQL
• Rule for the data in the database
– Examples in TAL Distributors
• A sales rep’s number must be unique
• The sales rep number for a customer must match
an exiting sales rep number
• Categories for items must be GME, TOY, or PZL
38
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Integrity Constraints in SQL
(continued)
• Integrity support is 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
39
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Integrity Constraints in SQL
(continued)
• Primary keys
– Use ADD PRIMARY KEY clause on ALTER TABLE
command to add after creating a table
• Foreign keys
– A 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
40
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Integrity Constraints in SQL
(continued)
41
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-24: Adding a foreign key to an existing table
Integrity Constraints in SQL
(continued)
• After creating a foreign key, DBMS rejects any
update that violates the foreign key constraint
– 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
42
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Integrity Constraints in SQL
(continued)
43
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-27: Adding an integrity constraint to an existing table
Integrity Constraints in SQL
(continued)
44
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as
permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Figure 7-28: Update that violates the integrity constraint
Summary
• Views
– CREATE VIEW command
– Benefits
– Update issues
– DROP VIEW command
• Security features
– GRANT
– REVOKE
45
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Summary (continued)
• Indexes
– Make data retrieval more efficient
– CREATE INDEX
– DROP INDEX
• System catalog information
– SYSTABLES, SYSCOLUMNS, SYSVIEWS
– DBA_TABLES, DBA_TAB_COLUMNS,
DBA_VIEWS
46
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
Summary (continued)
• Integrity constraints
– ADD PRIMARY KEY
– ADD FOREIGN KEY
– CHECK
47
©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in
a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.

More Related Content

Similar to Sql9e ppt ch07

Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7
Steve Guinan
 
Access 2016 module 2 ppt presentation
Access 2016 module 2 ppt presentationAccess 2016 module 2 ppt presentation
Access 2016 module 2 ppt presentation
dgdotson
 
Data Structures and CAATTs for Data Extraction
Data Structures and CAATTs for Data ExtractionData Structures and CAATTs for Data Extraction
Data Structures and CAATTs for Data Extraction
204025
 
Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4 Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4
Steve Guinan
 
Power point 2016 module 1 ppt presentation
Power point 2016 module 1 ppt presentationPower point 2016 module 1 ppt presentation
Power point 2016 module 1 ppt presentation
dgdotson
 
Access 2016 module 4 ppt presentation
Access 2016 module 4 ppt presentationAccess 2016 module 4 ppt presentation
Access 2016 module 4 ppt presentation
dgdotson
 
Coronel_DatabaseSystems_13e_ch02.pptx
Coronel_DatabaseSystems_13e_ch02.pptxCoronel_DatabaseSystems_13e_ch02.pptx
Coronel_DatabaseSystems_13e_ch02.pptx
rmzx1989
 
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
Anson Han
 
Management chapter 6 organization structure.pptx
Management chapter 6 organization structure.pptxManagement chapter 6 organization structure.pptx
Management chapter 6 organization structure.pptx
MuhammadAdeel321
 
Debate Initial Post and Response Rubric Student Name .docx
Debate Initial Post and Response Rubric Student Name     .docxDebate Initial Post and Response Rubric Student Name     .docx
Debate Initial Post and Response Rubric Student Name .docx
simonithomas47935
 
ch01.pptx
ch01.pptxch01.pptx
ch01.pptx
TommyCat7
 
BSAD 372 SPRING 2017 CH 8
BSAD 372 SPRING 2017 CH 8BSAD 372 SPRING 2017 CH 8
BSAD 372 SPRING 2017 CH 8
Janice Robinson
 
Leading and Learning MTI
Leading and Learning MTILeading and Learning MTI
Leading and Learning MTI
Aida Lou Cahayag
 
Access 2016 module 1 ppt presentation
Access 2016 module 1 ppt presentationAccess 2016 module 1 ppt presentation
Access 2016 module 1 ppt presentation
dgdotson
 
New Perspectives on Microsoft Access 2016Module 4Creating.docx
New Perspectives on Microsoft Access 2016Module 4Creating.docxNew Perspectives on Microsoft Access 2016Module 4Creating.docx
New Perspectives on Microsoft Access 2016Module 4Creating.docx
gibbonshay
 
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
at315244
 
Making Tableau Dashboards Shareable
Making Tableau Dashboards ShareableMaking Tableau Dashboards Shareable
Making Tableau Dashboards Shareable
Senturus
 
Intro to Web Design 6e Chapter 3
Intro to Web Design 6e Chapter 3 Intro to Web Design 6e Chapter 3
Intro to Web Design 6e Chapter 3
Steve Guinan
 
Coronel_PPT_Ch11.ppt
Coronel_PPT_Ch11.pptCoronel_PPT_Ch11.ppt
Coronel_PPT_Ch11.ppt
abdulbasetalselwi
 
Power point 2016 module 2 ppt presentation
Power point 2016 module 2 ppt presentationPower point 2016 module 2 ppt presentation
Power point 2016 module 2 ppt presentation
dgdotson
 

Similar to Sql9e ppt ch07 (20)

Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7
 
Access 2016 module 2 ppt presentation
Access 2016 module 2 ppt presentationAccess 2016 module 2 ppt presentation
Access 2016 module 2 ppt presentation
 
Data Structures and CAATTs for Data Extraction
Data Structures and CAATTs for Data ExtractionData Structures and CAATTs for Data Extraction
Data Structures and CAATTs for Data Extraction
 
Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4 Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4
 
Power point 2016 module 1 ppt presentation
Power point 2016 module 1 ppt presentationPower point 2016 module 1 ppt presentation
Power point 2016 module 1 ppt presentation
 
Access 2016 module 4 ppt presentation
Access 2016 module 4 ppt presentationAccess 2016 module 4 ppt presentation
Access 2016 module 4 ppt presentation
 
Coronel_DatabaseSystems_13e_ch02.pptx
Coronel_DatabaseSystems_13e_ch02.pptxCoronel_DatabaseSystems_13e_ch02.pptx
Coronel_DatabaseSystems_13e_ch02.pptx
 
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
 
Management chapter 6 organization structure.pptx
Management chapter 6 organization structure.pptxManagement chapter 6 organization structure.pptx
Management chapter 6 organization structure.pptx
 
Debate Initial Post and Response Rubric Student Name .docx
Debate Initial Post and Response Rubric Student Name     .docxDebate Initial Post and Response Rubric Student Name     .docx
Debate Initial Post and Response Rubric Student Name .docx
 
ch01.pptx
ch01.pptxch01.pptx
ch01.pptx
 
BSAD 372 SPRING 2017 CH 8
BSAD 372 SPRING 2017 CH 8BSAD 372 SPRING 2017 CH 8
BSAD 372 SPRING 2017 CH 8
 
Leading and Learning MTI
Leading and Learning MTILeading and Learning MTI
Leading and Learning MTI
 
Access 2016 module 1 ppt presentation
Access 2016 module 1 ppt presentationAccess 2016 module 1 ppt presentation
Access 2016 module 1 ppt presentation
 
New Perspectives on Microsoft Access 2016Module 4Creating.docx
New Perspectives on Microsoft Access 2016Module 4Creating.docxNew Perspectives on Microsoft Access 2016Module 4Creating.docx
New Perspectives on Microsoft Access 2016Module 4Creating.docx
 
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
 
Making Tableau Dashboards Shareable
Making Tableau Dashboards ShareableMaking Tableau Dashboards Shareable
Making Tableau Dashboards Shareable
 
Intro to Web Design 6e Chapter 3
Intro to Web Design 6e Chapter 3 Intro to Web Design 6e Chapter 3
Intro to Web Design 6e Chapter 3
 
Coronel_PPT_Ch11.ppt
Coronel_PPT_Ch11.pptCoronel_PPT_Ch11.ppt
Coronel_PPT_Ch11.ppt
 
Power point 2016 module 2 ppt presentation
Power point 2016 module 2 ppt presentationPower point 2016 module 2 ppt presentation
Power point 2016 module 2 ppt presentation
 

More from Dr. Ahmed Al Zaidy

Chapter 14 Exploring Object-based Programming
Chapter 14 Exploring Object-based ProgrammingChapter 14 Exploring Object-based Programming
Chapter 14 Exploring Object-based Programming
Dr. Ahmed Al Zaidy
 
Chapter 13 Programming for web forms
Chapter 13 Programming for web formsChapter 13 Programming for web forms
Chapter 13 Programming for web forms
Dr. Ahmed Al Zaidy
 
Chapter 12 Working with Document nodes and style sheets
Chapter 12 Working with Document nodes and style sheetsChapter 12 Working with Document nodes and style sheets
Chapter 12 Working with Document nodes and style sheets
Dr. Ahmed Al Zaidy
 
Chapter 11 Working with Events and Styles
Chapter 11 Working with Events and StylesChapter 11 Working with Events and Styles
Chapter 11 Working with Events and Styles
Dr. Ahmed Al Zaidy
 
Chapter 10 Exploring arrays, loops, and conditional statements
Chapter 10 Exploring arrays, loops, and conditional statementsChapter 10 Exploring arrays, loops, and conditional statements
Chapter 10 Exploring arrays, loops, and conditional statements
Dr. Ahmed Al Zaidy
 
Chapter 9 Getting Started with JavaScript
Chapter 9 Getting Started with JavaScriptChapter 9 Getting Started with JavaScript
Chapter 9 Getting Started with JavaScript
Dr. Ahmed Al Zaidy
 
Chapter 8 Enhancing a website with multimedia
Chapter 8 Enhancing a website with multimediaChapter 8 Enhancing a website with multimedia
Chapter 8 Enhancing a website with multimedia
Dr. Ahmed Al Zaidy
 
Chapter 7 Designing a web form
Chapter 7 Designing a web formChapter 7 Designing a web form
Chapter 7 Designing a web form
Dr. Ahmed Al Zaidy
 
Chapter 6 Working with Tables and Columns
Chapter 6 Working with Tables and ColumnsChapter 6 Working with Tables and Columns
Chapter 6 Working with Tables and Columns
Dr. Ahmed Al Zaidy
 
Chapter 5 Designing for the mobile web
Chapter 5 Designing for the mobile webChapter 5 Designing for the mobile web
Chapter 5 Designing for the mobile web
Dr. Ahmed Al Zaidy
 
Chapter 4 Graphic Design with CSS
Chapter 4 Graphic Design with CSSChapter 4 Graphic Design with CSS
Chapter 4 Graphic Design with CSS
Dr. Ahmed Al Zaidy
 
Chapter 3 Designing a Page Layout
Chapter 3 Designing a Page LayoutChapter 3 Designing a Page Layout
Chapter 3 Designing a Page Layout
Dr. Ahmed Al Zaidy
 
Chapter 2 Getting Started with CSS
Chapter 2 Getting Started with CSSChapter 2 Getting Started with CSS
Chapter 2 Getting Started with CSS
Dr. Ahmed Al Zaidy
 
Chapter 1 Getting Started with HTML5
Chapter 1 Getting Started with HTML5Chapter 1 Getting Started with HTML5
Chapter 1 Getting Started with HTML5
Dr. Ahmed Al Zaidy
 
Integer overflows
Integer overflowsInteger overflows
Integer overflows
Dr. Ahmed Al Zaidy
 
testing throughout-the-software-life-cycle-section-2
testing throughout-the-software-life-cycle-section-2testing throughout-the-software-life-cycle-section-2
testing throughout-the-software-life-cycle-section-2
Dr. Ahmed Al Zaidy
 
Fundamental of testing
Fundamental of testingFundamental of testing
Fundamental of testing
Dr. Ahmed Al Zaidy
 
Chapter 15 Risk Mitigation
Chapter 15 Risk MitigationChapter 15 Risk Mitigation
Chapter 15 Risk Mitigation
Dr. Ahmed Al Zaidy
 
Chapter 14 Business Continuity
Chapter 14 Business ContinuityChapter 14 Business Continuity
Chapter 14 Business Continuity
Dr. Ahmed Al Zaidy
 
Chapter 13 Vulnerability Assessment and Data Security
Chapter 13 Vulnerability Assessment and Data SecurityChapter 13 Vulnerability Assessment and Data Security
Chapter 13 Vulnerability Assessment and Data Security
Dr. Ahmed Al Zaidy
 

More from Dr. Ahmed Al Zaidy (20)

Chapter 14 Exploring Object-based Programming
Chapter 14 Exploring Object-based ProgrammingChapter 14 Exploring Object-based Programming
Chapter 14 Exploring Object-based Programming
 
Chapter 13 Programming for web forms
Chapter 13 Programming for web formsChapter 13 Programming for web forms
Chapter 13 Programming for web forms
 
Chapter 12 Working with Document nodes and style sheets
Chapter 12 Working with Document nodes and style sheetsChapter 12 Working with Document nodes and style sheets
Chapter 12 Working with Document nodes and style sheets
 
Chapter 11 Working with Events and Styles
Chapter 11 Working with Events and StylesChapter 11 Working with Events and Styles
Chapter 11 Working with Events and Styles
 
Chapter 10 Exploring arrays, loops, and conditional statements
Chapter 10 Exploring arrays, loops, and conditional statementsChapter 10 Exploring arrays, loops, and conditional statements
Chapter 10 Exploring arrays, loops, and conditional statements
 
Chapter 9 Getting Started with JavaScript
Chapter 9 Getting Started with JavaScriptChapter 9 Getting Started with JavaScript
Chapter 9 Getting Started with JavaScript
 
Chapter 8 Enhancing a website with multimedia
Chapter 8 Enhancing a website with multimediaChapter 8 Enhancing a website with multimedia
Chapter 8 Enhancing a website with multimedia
 
Chapter 7 Designing a web form
Chapter 7 Designing a web formChapter 7 Designing a web form
Chapter 7 Designing a web form
 
Chapter 6 Working with Tables and Columns
Chapter 6 Working with Tables and ColumnsChapter 6 Working with Tables and Columns
Chapter 6 Working with Tables and Columns
 
Chapter 5 Designing for the mobile web
Chapter 5 Designing for the mobile webChapter 5 Designing for the mobile web
Chapter 5 Designing for the mobile web
 
Chapter 4 Graphic Design with CSS
Chapter 4 Graphic Design with CSSChapter 4 Graphic Design with CSS
Chapter 4 Graphic Design with CSS
 
Chapter 3 Designing a Page Layout
Chapter 3 Designing a Page LayoutChapter 3 Designing a Page Layout
Chapter 3 Designing a Page Layout
 
Chapter 2 Getting Started with CSS
Chapter 2 Getting Started with CSSChapter 2 Getting Started with CSS
Chapter 2 Getting Started with CSS
 
Chapter 1 Getting Started with HTML5
Chapter 1 Getting Started with HTML5Chapter 1 Getting Started with HTML5
Chapter 1 Getting Started with HTML5
 
Integer overflows
Integer overflowsInteger overflows
Integer overflows
 
testing throughout-the-software-life-cycle-section-2
testing throughout-the-software-life-cycle-section-2testing throughout-the-software-life-cycle-section-2
testing throughout-the-software-life-cycle-section-2
 
Fundamental of testing
Fundamental of testingFundamental of testing
Fundamental of testing
 
Chapter 15 Risk Mitigation
Chapter 15 Risk MitigationChapter 15 Risk Mitigation
Chapter 15 Risk Mitigation
 
Chapter 14 Business Continuity
Chapter 14 Business ContinuityChapter 14 Business Continuity
Chapter 14 Business Continuity
 
Chapter 13 Vulnerability Assessment and Data Security
Chapter 13 Vulnerability Assessment and Data SecurityChapter 13 Vulnerability Assessment and Data Security
Chapter 13 Vulnerability Assessment and Data Security
 

Recently uploaded

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 

Recently uploaded (20)

Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 

Sql9e ppt ch07

  • 1. A Guide to SQL, Ninth Edition Chapter Seven Database Administration
  • 2. Objectives • Understand, create, 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 2 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 3. Objectives (continued) • Create, use, and drop an index • Understand and obtain information from the system catalog • Use integrity constraints to control data entry 3 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 4. Introduction • Database administration – Process of managing a database • Database administrator – Person or entire group in a business organization charged with managing the database 4 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 5. Creating and Using Views • View – A 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 5 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 6. Creating and Using Views (continued) • 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 6 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 7. Creating and Using Views (continued) • Created by a defining query – Indicates rows and columns to include • Use CREATE VIEW command – CREATE VIEW, followed by name of view, AS, and then defining query 7 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 8. Creating and Using Views (continued) 8 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-1: Creating the TOYS view
  • 9. Creating and Using Views (continued) 9 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-2: TOYS view
  • 10. Creating and Using Views (continued) • Data shown in 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 10 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 11. Creating and Using Views (continued) 11 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-3: Maria’s view of the ITEM table
  • 12. Creating and Using Views (continued) 12 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-4: Using the TOYS view
  • 13. Creating and Using Views (continued) 13 SELECT ITEM_NUM, DESCRIPTION, ON_HAND, PRICE FROM ITEM WHERE CATEGORY =‘TOY’ AND PRICE > 100; ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. • Actual query executed by SQL
  • 14. Creating and Using Views (continued) • 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 14 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 15. Creating and Using Views (continued) 15 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-5: Renaming columns when creating a view
  • 16. Creating and Using Views (continued) 16 • Defining query of view can be any valid SQL query • View can join two or more tables ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-7: Creating the REP_CUST view
  • 17. Creating and Using Views (continued) 17 • A view can involve statistics ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-9: Creating the CRED_CUST view
  • 18. Creating and Using Views (continued) • Benefits of views – Provide data independence • Can often be used even after database structure changes – Different users can view same data differently • Customize display to meet each user’s needs – A view can contain only those columns required by a given user • Simplifies user’s perception of database • Provides a measure of security 18 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 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 19 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 20. Updating Row-and-Column Subset Views 20 • Can update (usually) if view contains primary key • Cannot update when primary key is not included No primary key ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 21. Updating Views Involving Joins • 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 21 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 22. Updating Views Involving Statistics • Most difficult to update • Cannot add rows to a view that includes calculations 22 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 23. 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 23 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 24. 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 24 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 25. 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 25 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 26. Security (continued) • Database administrator uses REVOKE command to remove privileges from users • Format is similar to GRANT command 26 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 27. Indexes • Speeds up the searching of tables • Similar to an index in a book 27 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-19: Index for the CUSTOMER table on the CUSTOMER_NUM column
  • 28. Indexes (continued) 28 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-20: Indexes for the CUSTOMER table on the CREDIT_LIMIT and REP_NUM columns
  • 29. Indexes (continued) • SQL manages indexes • User determines columns on which to build indexes • Disadvantages – Index occupies disk space – DBMS must update index as data is entered 29 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 30. Creating an Index • Use CREATE INDEX command – Name the index – Identify the table – Identify the column or columns 30 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 31. Creating an Index (continued) 31 Index on a single column ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-21: Creating the BALIND index on the BALANCE column
  • 32. Creating an Index (continued) 32 Index on two columns ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-22: Creating the REP_NAME index on the LAST_NAME and FIRST_NAME columns
  • 33. Dropping an Index • Use DROP INDEX to delete an index – DROP INDEX followed by name of index to drop • Permanently deletes index 33 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 34. 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 34 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 35. System Catalog • Contains information about tables in database; also called data dictionary • Use SYSTABLES to list all tables in database • Use SYSCOLUMNS to list all columns in a table • Use SYSVIEWS to list information about views 35 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 36. System Catalog (continued) • In Oracle, use: – DBA_TABLES to list information about tables – DBA_TAB_COLUMNS to list information about columns – DBA_VIEWS to list information about views 36 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 37. Update of the System Catalog • DBMS updates automatically when – Create, alter, drop tables – Create or drop indexes • Users should not update catalog directly ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. 37
  • 38. Integrity Constraints in SQL • Rule for the data in the database – Examples in TAL Distributors • A sales rep’s number must be unique • The sales rep number for a customer must match an exiting sales rep number • Categories for items must be GME, TOY, or PZL 38 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 39. Integrity Constraints in SQL (continued) • Integrity support is 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 39 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 40. Integrity Constraints in SQL (continued) • Primary keys – Use ADD PRIMARY KEY clause on ALTER TABLE command to add after creating a table • Foreign keys – A 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 40 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 41. Integrity Constraints in SQL (continued) 41 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-24: Adding a foreign key to an existing table
  • 42. Integrity Constraints in SQL (continued) • After creating a foreign key, DBMS rejects any update that violates the foreign key constraint – 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 42 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 43. Integrity Constraints in SQL (continued) 43 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-27: Adding an integrity constraint to an existing table
  • 44. Integrity Constraints in SQL (continued) 44 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use. Figure 7-28: Update that violates the integrity constraint
  • 45. Summary • Views – CREATE VIEW command – Benefits – Update issues – DROP VIEW command • Security features – GRANT – REVOKE 45 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 46. Summary (continued) • Indexes – Make data retrieval more efficient – CREATE INDEX – DROP INDEX • System catalog information – SYSTABLES, SYSCOLUMNS, SYSVIEWS – DBA_TABLES, DBA_TAB_COLUMNS, DBA_VIEWS 46 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.
  • 47. Summary (continued) • Integrity constraints – ADD PRIMARY KEY – ADD FOREIGN KEY – CHECK 47 ©2016 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part, except for use as permitted in a license distributed with a certain product or service or otherwise on a password-protected website for classroom use.