Chapter 6 Database Administration

Slides:



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

Database Management System
Chapter 8 Embedded SQL.
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 SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Concepts of Database Management Sixth Edition
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’
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.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Chapter 6: Integrity and Security Thomas Nikl 19 October, 2004 CS157B.
Database Lecture # 1 By Ubaid Ullah.
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.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Introduction to SQL.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 6: Chapter 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
1 Database Administration. 2 Objectives  Understand, create, and drop views  Grant and revoke users’ privileges  Understand and obtain information.
Using Special Operators (LIKE and IN)
Database Management COP4540, SCS, FIU Constraints and security in SQL (Ch. 8.6, Ch22.2)
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Views In some cases, it is not desirable for all users to see the entire logical model (that is, all the actual relations stored in the database.) In some.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Outline Introduction Basic SQL Setting Up and Using PostgreSQL
Chapter 2 Views. Objectives ◦ Create simple and complex views ◦ Creating a view with a check constraint ◦ Retrieve data from views ◦ Data manipulation.
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.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
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.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
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 SQL, Sixth Edition 1 Chapter 5 Updating Data.
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)
A Guide to SQL, Sixth Edition 1 Chapter 7 Reports.
SQL Basics Review Reviewing what we’ve learned so far…….
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Fundamentals of DBMS Notes-1.
TABLES AND INDEXES Ashima Wadhwa.
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Chapter 4 Indexes.
CH 4 Indexes.
Chapter 2 Views.
A Guide to SQL, Eighth Edition
CH 4 Indexes.
Chapter 2 Views.
IST 318 Database Administration
Presentation transcript:

Chapter 6 Database Administration

Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke users' database privileges Understand the purpose, advantages, and disadvantages of using an index

Objectives Create, use, and drop an index Understand and obtain information from the system catalog Use integrity constraints to control data entry

Introduction Database administration Database administrator The process of managing a database Database administrator A person or an entire group charged with managing the database

Views Base tables Existing, permanent tables in a relational database View A derived table where data is derived from a base table User interacts with the view View provides security

Views A view is defined by creating a defining query A defining query is a SQL command that indicates the rows and columns that will appear in the view To create a view definition, use the CREATE VIEW command

Views When a query involves a view, SQL changes the query to select data from the table(s) in the database that created the view

Views The use of views provides several benefits Views provide data independence The display of data can be customized to meet each user’s needs A view contains only those columns required by a given user, which has two advantages: A view greatly simplifies the user’s perception of the database Views provide a measure of security

Row-and-Column Subsets A row-and-column subset view that contains the primary key of the underlying base table is updateable Figure 6.9 illustrates a view that contains serious update problems due to the exclusion of the primary key

Row-and-Column Subsets Figure 6.9

Joins In general, views that involve joins of base tables can cause problems at update If two base tables have the same primary key and the primary key is used as the join column, updating the database is not a problem

Statistics CRED_CUST view contains the most troublesome view of all because it involves statistics calculated from one or more base tables Rows cannot be added to a view that includes calculations

Dropping a View When a view is no longer needed, remove it by using the DROP VIEW command Example: DROP VIEW HSEWRES;

Security Security is the prevention of unauthorized access to the database Two security mechanisms: Views GRANT command

Security The database administrator can grant different types of privileges to users and then revoke them later, if necessary User privileges can be granted and revoked using the GRANT and REVOKE commands, respectively

Security Problem: Solution: User Johnson must be able to retrieve data from the REP table. Solution: GRANT SELECT ON REP TO JOHNSON;

Security The privileges that can be granted are: SELECT to retrieve date UPDATE to change data DELETE to delete data INSERT to add new data INDEX to create an index ALTER to change the table structure

Security The REVOKE command is used to revoke privileges from users Problem: User Johnson is no longer allowed to retrieve data from the REP table. Solution: REVOKE SELECT ON REP FROM JOHNSON;

Indexes An index can be created for any column or combination of columns in any table After creating an index, the DBMS uses it to speed up data retrieval

Indexes Advantages Disadvantages Makes certain types of retrieval more efficient Disadvantages Occupies disk space and is technically unnecessary Must be updated whenever corresponding data in the database is updated

Creating an Index Problem: Create an index named BALIND on the BALANCE column in the CUSTOMER table. Create an index named REPNAME on the combination of the LAST_NAME and FIRST_NAME columns in the REP table. Create an index named CREDNAME on the combination of the CREDIT_LIMIT and CUSTOMER_NAME columns in the CUSTOMER table, with the credit limits listed in descending order.

Creating an Index Solution: CREATE INDEX BALIND ON CUSTOMER(BALANCE);   CREATE INDEX REPNAME ON REP(LAST_NAME, FIRST_NAME);   CREATE INDEX CREDNAME ON CUSTOMER(CREDIT_LIMIT DESC, CUSTOMER_NAME);

Dropping an Index The command used to drop (delete) an index is DROP INDEX Problem: Delete the CREDNAME index Solution: DROP INDEX CREDNAME;

Unique Indexes When a column that is not the primary key requires unique values, create a unique index A unique index is created by using the CREATE UNIQUE INDEX command

Unique Indexes Problem: Solution: Create a unique index named SSN on the SOC_SEC_NUM column of the REP table Solution: CREATE UNIQUE INDEX SSN ON REP(SOC_SEC_NUM);

System Catalog Information about tables in the database is kept in the system catalog or the data dictionary System catalog contains tables: SYSTABLES (in Oracle: DBA_TABLES) SYSCOLUMNS (in Oracle: DBA_TAB_TABLES) SYSVIEWS (in Oracle: DBA_VIEWS)

System Catalog The system catalog is a relational database Information can be retrieved by using the same types of queries which are used to retrieve data in a relational database

System Catalog The DBMS updates the system catalog automatically Users should not use SQL queries to update the catalog directly because this might produce inconsistent information

Integrity Rules in SQL An integrity constraint is a rule for the data in the database If a user enters data in the database that violates any of the integrity constraints, the database will develop serious problems

Integrity Rules in SQL Integrity support is the process of specifying integrity constraints for a database that the DBMS will enforce The types of constraints supported in SQL are: Primary keys Foreign keys Legal values

Integrity Rules in SQL In most cases, a table’s primary key is indicated when the table is created To add a primary key after creating a table, use the ADD PRIMARY KEY clause of the ALTER TABLE command

Integrity Rules in SQL A foreign key is a column in one table whose values match the primary key in another table When a table contains a foreign key, it is identified by using the ADD FOREIGN KEY clause of the ALTER TABLE command After creating a foreign key, the DBMS will reject any update that violates the foreign key constraint

Integrity Rules in SQL The CHECK clause of the ALTER TABLE command is used to ensure that only legal values satisfying a particular condition are allowed in a given column If a user enters data that violates the condition, the DBMS rejects the update automatically

Summary A view contains data that is derived from existing base tables when users attempt to access the view GRANT command: gives users access privileges to data in the database REVOKE command: terminates previously granted privileges You can create and use an index to make data retrieval more efficient

Summary The DBMS maintains information about the tables, columns, indexes, and other system elements in the system catalog (catalog) or data dictionary Integrity constraints are rules that the data in the database must follow to ensure that only legal values are accepted in specified columns and that primary and foreign key values match between tables

SQL Project Six Completed Good Luck H. Zamanzadeh