1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.

Slides:



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

Basic SQL Introduction Presented by: Madhuri Bhogadi.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Database Security by Muhammad Waheed Aslam SIS Project Leader ITC/KFUPM.
Database Management System
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
1 Query Languages: How to build or interrogate a relational database Structured Query Language (SQL)
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Security and Transaction Management Pertemuan 8 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
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.
10/3/2000SIMS 257: Database Management -- Ray Larson Relational Algebra and Calculus University of California, Berkeley School of Information Management.
SQL Query Extras MIS 433. Rerunning the last Query n Type the forward slash “/” to rerun the last query that was entered.
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.
1 An Introduction to SQL. 2 Objectives  Understand the concepts and terminology associated with relational databases  Create and run SQL commands 
Chapter 6: Integrity and Security Thomas Nikl 19 October, 2004 CS157B.
Database Lecture # 1 By Ubaid Ullah.
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.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
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.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 6: Chapter 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
1 Database Administration. 2 Objectives  Understand, create, and drop views  Grant and revoke users’ privileges  Understand and obtain information.
Chapter 6 Database Administration
Database Management COP4540, SCS, FIU Constraints and security in SQL (Ch. 8.6, Ch22.2)
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
1 A Guide to SQL Chapter 2. 2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation.
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.
Access Project 3 Notes. Introduction Maintaining the Database  Modifying the data to keep it up-to-date Restructure the Database  To change the database.
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
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.
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.
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.
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
SQL Overview Structured Query Language
Chapter 4 Indexes. Indexes Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage; composed.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Chapter 3: Relational Databases
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
TABLES AND INDEXES Ashima Wadhwa.
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:

1 Chapter 6 Database Administration

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

3 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

4 Views A view is defined by creating a defining query (SQL command that indicates the rows and columns that will appear in the view)

5 Creating the HOUSEWARES View

6 HOUSEWARES View

7 Views Data does not exist in the form of the view Query acts as a “window” into the database (see Figure 6.3) As far as the user is concerned the entire database consists of the dark shaded portion of the PART table

8 Using the HOUSEWARES View

9 In Figure 6.4, the query first is merged with the query that defines the view, producing the following statement: SELECT PART_NUMBER, PART_DESCRIPTION, UNITS_ON_HAND, UNIT_PRICE FROM PART WHERE ITEM_CLASS = ‘HW’ AND UNITS_ON_HAND > 100;

10 CREATE VIEW Format The formulation of the view definition is: CREATE AS The defining query can be any valid SQL query

11 Renaming Columns When Creating a View

12 HOUSEWARES VIEW The HOUSEWARES view is an example of row-and-column subset view because it consists of a subset of the rows and columns in some base table

13 View Benefits Views provide data independence Different users can view the same data in different ways because each user has their own view It can contain only those columns required by a given user Greatly simplifies user perception of database Furnishes a measure of security since user as access to data contained only in their view

14 Row-and-Column Subsets and Updates through a View 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

15 Creating the SALES_CRED View

16 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

17 SLSREP_DEMO and SLSREP_FIN tables

18 Creating the SLSREP View

19 Using the SLSREP View

20 Statistics Views involving statistics calculated from one or more base tables won’t allow updates Rows cannot be added to a view that includes calculations

21 Dropping a View

22 DROP View Command Deletes a view definition only Table and data on which view is based still exists

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

24 GRANT and REVOKE Commands Grant different privileges to users and revoke them later, if necessary: Ability to select rows from a table Insert new rows Update existing rows

25 Example 6 User Jones must be able to retrieve data from the SALES_REP table GRANT SELECT ON SALES_REP TO JONES;

26 Example 7 Users Smith and Brown must be able to add new parts to the PART table. GRANT INSERT ON PART TO SMITH, BROWN;

27 Example 8 User Anderson must be able to change the last name, first name, and street address of customers GRANT UPDATE ON CUSTOMER (LAST, FIRST, STREET) TO ANDERSON;

28 Example 9 User Martin must be able to delete order lines GRANT DELETE ON ORDER_LINE TO MARTIN;

29 Example 10 Every user must be able to retrieve part numbers, part descriptions, and item classes GRANT SELECT ON PART (PART_NUMBER, PART_DESCRIPTION, ITEM_CLASS) TO PUBLIC;

30 Example 11 User Roberts must be able to create an index on the SALES_REP table GRANT INDEX ON SALES_REP TO ROBERTS;

31 Example 12 User Thomas must be able to change the structure of the CUSTOMER table GRANT ALTER ON CUSTOMER TO THOMAS;

32 Example 13 User Wilson must have all privileges for the SALES_REP, CUSTOMER, and ORDERS tables GRANT ALL ON SALES_REP, CUSTOMER, ORDERS TO WILSON;

33 Privileges Privileges that can be granted are SELECT UPDATE DELETE INSERT INDEX For a user to pass the privilege on to others the database administrator must use GRANT statement and include WITH GRANT OPTION

34 GRANT and REVOKE Format GRANT TO REVOKE FROM WITH GRANT OPTION is not meaningful part of REVOKE command Revoke cascades so privileges granted with the WITH GRANT OPTION are revoked for all who were granted privileges

35 Example 14 User Jones is no longer allowed to retrieve data from the SALES_REP table REVOKE SELECT ON SALES_REP FROM JONES;

36 Indexes Create and use an index to speed the searching process

37 CUSTOMER Table With Row Numbers

38 Index for CUSTOMER Table on CUSTOMER_NUMBER Column

39 Indexes Advantages 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

40 Creating Indexes

41 Dropping an Index Command to delete an index is DROP INDEX DROP INDEX CREDNAME;

42 Unique Indexes When a column that is not the primary key requires unique values, create a unique index using the CREATE UNIQUE INDEX command CREATE UNIQUE INDEX SSN ON CUSTOMER (SOC_SEC_NUMBER);

43 The System Catalog Information concerning tables known to the DBMS 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)

44 System Catalog System catalog is a relational database Users need special privileges to view the data in the system catalog

45 Tables Owned by PRATT

46 Views Owned by PRATT

47 Columns in the Customer Table

48 Integrity in SQL An integrity constraint is a rule that the data in the database must follow Examples: No two sales reps can have the same sales rep number The sales rep number for a customer must match the number of a sales rep currently in the database Item classes for parts must be AP, HW, or SG

49 Integrity Support To prevent violations, the DBMS provides integrity support Types of constraints supported in SQL Legal values Primary keys Foreign keys CHECK clause ensures that only legal values that satisfy a particular condition are allowed in a given column

50 CHECK Clause To ensure the only legal values for item class are AP, HW, or SG CHECK (ITEM_CLASS IN (‘AP’, ‘HW’, ‘SG’)) OR CHECK (ITEM_CLASS = ‘AP’ OR ITEM_CLASS = ‘HW’ OR ITEM_CLASS = ‘SG’)

51 ADD PRIMARY KEY Clause To indicate that SLSREP_NUMBER is the primary key for the SALES_REP table PRIMARY KEY (SLSREP_NUMBER)

52 Foreign Key A foreign key is a column on one table whose values match the primary key of another table To specify a foreign key, specify both the column that is a foreign key and the table it matches ADD FOREIGN KEY (SLSREP_NUMBER) REFERENCES SALES_REP

53 Assigning a Primary Key

54 Adding Foreign Keys

55 Violating Foreign Key Constraints

56 Parent and Child Figure 6.24 includes the words “parent” and “child” When a foreign key is used, the table containing the foreign key is the child and the tabled referenced by the foreign key is the parent

57 Adding Additional Integrity Constraints

58 Violating an Integrity Constraint