1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing...
-
Upload
allison-kelly -
Category
Documents
-
view
224 -
download
4
Transcript of 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing...
![Page 1: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/1.jpg)
1
Chapter 6Database Administration
![Page 2: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/2.jpg)
2
Introduction
Database administrationThe process of managing a database
Database administratorA person or an entire group charged with
managing the database
![Page 3: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/3.jpg)
3
Views
Base tablesExisting, permanent tables in a relational
database
ViewA derived table where data is derived from
a base tableUser interacts with the viewView provides security
![Page 4: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/4.jpg)
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)
![Page 5: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/5.jpg)
5
Creating the HOUSEWARES View
![Page 6: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/6.jpg)
6
HOUSEWARES View
![Page 7: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/7.jpg)
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
![Page 8: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/8.jpg)
8
Using the HOUSEWARES View
![Page 9: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/9.jpg)
9
Using the HOUSEWARES View
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;
![Page 10: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/10.jpg)
10
CREATE VIEW Format
The formulation of the view definition is: CREATE <view name> AS <query>
The defining query can be any valid SQL query
![Page 11: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/11.jpg)
11
Renaming Columns When Creating a View
![Page 12: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/12.jpg)
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
![Page 13: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/13.jpg)
14
Row-and-Column Subsets and Updates through a ViewA 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
![Page 14: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/14.jpg)
15
Creating the SALES_CRED View
![Page 15: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/15.jpg)
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
![Page 16: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/16.jpg)
20
Statistics
Views involving statistics calculated from one or more base tables won’t allow updatesRows cannot be added to a view that
includes calculations
![Page 17: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/17.jpg)
21
Dropping a View
![Page 18: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/18.jpg)
22
DROP View Command
Deletes a view definition only
Table and data on which view is based still exists
![Page 19: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/19.jpg)
23
Security
Security is the prevention of unauthorized access to the database
Two security mechanismsViewsGRANT command
![Page 20: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/20.jpg)
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 rowsUpdate existing rows
![Page 21: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/21.jpg)
25
Example 6
User Jones must be able to retrieve data from the SALES_REP tableGRANT SELECT ON SALES_REP TO
JONES;
![Page 22: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/22.jpg)
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
![Page 23: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/23.jpg)
34
GRANT and REVOKE Format
GRANT <privilege> TO <user>
REVOKE <privilege> FROM <user>WITH GRANT OPTION is not meaningful
part of REVOKE commandRevoke cascades so privileges granted
with the WITH GRANT OPTION are revoked for all who were granted privileges
![Page 24: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/24.jpg)
35
Example 14
User Jones is no longer allowed to retrieve data from the SALES_REP tableREVOKE SELECT ON SALES_REP
FROM JONES;
![Page 25: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/25.jpg)
36
Indexes
Create and use an index to speed the searching process
![Page 26: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/26.jpg)
38
Index for CUSTOMER Table on CUSTOMER_NUMBER Column
![Page 27: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/27.jpg)
39
Indexes
AdvantagesMakes certain types of retrieval more
efficient
Disadvantagesoccupies disk space and is technically
unnecessarymust be updated whenever corresponding
data in the database is updated
![Page 28: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/28.jpg)
40
Creating Indexes
![Page 29: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/29.jpg)
41
Dropping an Index
Command to delete an index is DROP INDEXDROP INDEX CREDNAME;
![Page 30: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/30.jpg)
42
Unique Indexes
When a column that is not the primary key requires unique values, create a unique index using the CREATE UNIQUE INDEX commandCREATE UNIQUE INDEX SSN ON
CUSTOMER (SOC_SEC_NUMBER);
![Page 31: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/31.jpg)
43
The System Catalog
Information concerning tables known to the DBMS is kept in the system catalog, or the data dictionary
System catalog contains tablesSYSTABLES (in Oracle: DBA_TABLES)SYSCOLUMNS (in Oracle:
DBA_TAB_TABLES)SYSVIEWS (in Oracle: DBA_VIEWS)
![Page 32: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/32.jpg)
44
System Catalog
System catalog is a relational database
Users need special privileges to view the data in the system catalog
![Page 33: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/33.jpg)
45
Tables Owned by PRATT
![Page 34: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/34.jpg)
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
![Page 35: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/35.jpg)
49
Integrity Support
To prevent violations, the DBMS provides integrity supportTypes 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
![Page 36: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/36.jpg)
50
CHECK Clause
To ensure the only legal values for item class are AP, HW, or SGCHECK (ITEM_CLASS IN (‘AP’, ‘HW’,
‘SG’))
ORCHECK (ITEM_CLASS = ‘AP’ OR
ITEM_CLASS = ‘HW’ OR ITEM_CLASS = ‘SG’)
![Page 37: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/37.jpg)
51
ADD PRIMARY KEY Clause
To indicate that SLSREP_NUMBER is the primary key for the SALES_REP tablePRIMARY KEY (SLSREP_NUMBER)
![Page 38: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/38.jpg)
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 matchesADD FOREIGN KEY (SLSREP_NUMBER)
REFERENCES SALES_REP
![Page 39: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/39.jpg)
53
Assigning a Primary Key
![Page 40: 1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.](https://reader035.fdocuments.us/reader035/viewer/2022062309/56649f1a5503460f94c2fadf/html5/thumbnails/40.jpg)
54
Adding Foreign Keys