0% found this document useful (0 votes)
19 views64 pages

Lec11_240406

The document covers database administration, focusing on the roles of a Database Administrator (DBA) in managing data security, backup, and recovery, as well as the technical aspects of database design and implementation. It discusses distributed databases, their characteristics, and security risks, along with countermeasures such as authentication, authorization, and encryption. Additionally, it explains how to create and manage user privileges, sequences, and views within a database system.

Uploaded by

david--chin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views64 pages

Lec11_240406

The document covers database administration, focusing on the roles of a Database Administrator (DBA) in managing data security, backup, and recovery, as well as the technical aspects of database design and implementation. It discusses distributed databases, their characteristics, and security risks, along with countermeasures such as authentication, authorization, and encryption. Additionally, it explains how to create and manage user privileges, sequences, and views within a database system.

Uploaded by

david--chin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 64

Lecture 11

Database
Administration,
Distribution
and Security
Chapters 12 and 16 - Coronel, C., Morris, S. & Rob, P. (2023). Database Systems: Design, Implementation & Management, 14th
Edition, Cengage Learning
Learning Objectives

• LO#1 Know database administration.


• LO#2 Understand distributed database.
• LO#3 Identify database security risks.

11-2
Database Administrator (DBA)’s Managerial
Role
• Provide end-user support
• Enforce policies, procedures, and standards
for correct data creation, usage, and
distribution within the database
• Manage data security, privacy, and integrity
• Manage data backup and recovery
– Fully recover data in case of data loss
– Database security officer (DSO): Ensures database
security and integrity
11-3
A plan that is made for dealing with an emergency

DBA’s Managerial Role


– Disaster management: Planning, organizing, and
testing of database contingency plans and recovery
臨時計劃
procedures
– Backup and recovery measures must include at
least:
• Proper backup identification
• Convenient and safe backup storage
• Physical protection of both hardware and software
• Personal access control to the software of a database
installation
• Insurance
保險範圍coverage for the data in the database

11-4
DBA’s Technical Role
• Evaluate, select, and install DBMS and related
utilities
實施
• Design and implement databases and
applications
• Test and evaluate databases and applications
• Operate the DBMS, utilities, and applications
• Train and support users
• Maintain the DBMS, utilities, and applications
11-5
分散式

Distributed Database
• Distributed database: single logical database
physically divided among networked
computers
• Distributed database management system
操縱
(DDBMS): supports and manipulates
distributed databases

11-6
Distributed Database

11-7
特徵
Characteristics of Distributed DBMSs
同質
• Homogeneous DDBMS: same local DBMS at
each site
異質
• Heterogeneous DDBMS: at least two sites at
which local DBMSs are different (multiple
databases)
• Shared characteristics of DDBMSs
– Location transparency
– Replication
碎片化 transparency
– Fragmentation transparency
11-8
9
威脅
Threats to Computer Systems
The act of getting money from people
by threatening to tell a secret of theirs

Trapdoor – a method of gaining access to some parts


of a system other than by the normal procedure
Database Security
舞弊 malpractice

• Involves measures to avoid:


– Theft and fraud
保密
– Loss of confidentiality (secrecy)
– Loss of privacy
– Loss of integrity
– Loss of availability

11-11
Countermeasures – Computer-Based
Controls
對策 an action taken against an unwanted action or situation

• Concerned with physical controls to


administrative procedures and includes:
驗證 授權
– Authentication and authorization
– Integrity
– Encryption 加密
寫日記
– Backup and journaling
– Availability

12
11-12
Countermeasures – Computer-Based
Controls
• Authentication
– A mechanism that determines whether a user is
who he or she claims to be.

13
11-13
Countermeasures – Computer-Based
Controls
• Authorization
授予 特權
– The granting of a right or privilege, which enables
a subject to legitimately have access to a system
or a system’s object.

14
11-14
Creating Users
• The DBA creates users by using the CREATE
USER statement.
CREATE USER user
IDENTIFIED BY password;

SQL>
SQL> CREATE
CREATE USER
USER scott
scott
22 IDENTIFIED
IDENTIFIED BY
BY tiger;
tiger;
User
User created.
created.

cresecure.sql
11-15
So, putting it all together, you're telling the database, "Let's set up a new
user called Scott, and his password will be tiger." Once this command is
executed, Scott will have his own user account in the database and can log
in using "tiger" as his password.

16
User System Privileges
• Once a user is created, the DBA can grant specific system privileges
to a user.

GRANT
GRANT privilege
privilege [,
[, privilege...]
privilege...]
TO
TO user
user [,
[, user...];
user...];

• An application developer may have the following system


privileges:
– CREATE SESSION
– CREATE TABLE
– CREATE SEQUENCE
– CREATE VIEW
– CREATE PROCEDURE

11-17
授予
Granting System Privileges
• The DBA can grant a user specific system
privileges.
SQL>
SQL> GRANT
GRANT create
create table,
table, create
create sequence,
sequence, create
create view
view
22 TO
TO scott;
scott;
Grant
Grant succeeded.
succeeded.

11-18
What Is a Role?

11-19
Creating and Granting Privileges to a Role

SQL>
SQL> CREATE
CREATE ROLE
ROLE manager;
manager;
Role
Role created.
created.

SQL>
SQL> GRANT
GRANT create
create table,
table, create
create view
view
22 to
to manager;
manager;
Grant
Grant succeeded.
succeeded.

SQL>
SQL> GRANT
GRANT manager
manager to
to BLAKE,
BLAKE, CLARK;
CLARK;
Grant
Grant succeeded.
succeeded.

11-20
21
22
23
Changing Your Password
– The DBA creates your user account and initializes your
password.
– You can change your password by using the ALTER
USER statement.
– Syntax
ALTER USER user IDENTIFIED BY password;
– where: user is the name of the
user
password specifies the new password
SQL> ALTER USER scott
2 IDENTIFIED BY lion;
User altered.
11-24
Object Privileges
Object
Privilege Table View Sequence Procedure
ALTER  
DELETE  
EXECUTE 
INDEX 
INSERT  
REFERENCES 
SELECT   
UPDATE  
11-25
26
27
28
29
30
Object Privileges
– Object privileges vary from object to object.
– An owner has all the privileges on the object.
– An owner can give specific privileges on that
owner’s object.

GRANT
GRANT object_priv
object_priv [(columns)]
[(columns)]
ON
ON object
object
TO
TO {user|role|PUBLIC}
{user|role|PUBLIC}
[WITH
[WITH GRANT
GRANT OPTION];
OPTION];

11-31
Granting Object Privileges
– Grant query privileges on the EMP table.
SQL>
SQL> GRANT
GRANT select
select
22 ON
ON emp
emp
33 TO
TO sue,
sue, rich;
rich;
Grant
Grant succeeded.
succeeded.

• Grant privileges to update specific columns to


users and roles.
SQL>
SQL> GRANT
GRANT update
update (dname,
(dname, loc)
loc)
22 ON
ON dept
dept
33 TO
TO scott,
scott, manager;
manager;
Grant
Grant succeeded.
succeeded.

11-32
Using WITH GRANT OPTION and PUBLIC Keywords

• Give a user authority to pass along the


privileges.
SQL>
SQL> GRANT
GRANT select,
select, insert
insert
22 ON
ON dept
dept
33 TO
TO scott
scott
44 WITH
WITH GRANT
GRANT OPTION;
OPTION;
Grant
Grant succeeded.
succeeded.

– Allow all users on the system to query data from


Alice’s DEPT table.
SQL>
SQL> GRANT
GRANT select
select
22 ON
ON alice.dept
alice.dept
33 TO
TO PUBLIC;
PUBLIC;
Grant
Grant succeeded.
succeeded.
11-33
What Is a Sequence?
A sequence:
• Automatically generates unique numbers
• Is a sharable object
• Is typically used to create a primary key value
• Replaces application code
• Speeds up the efficiency of accessing sequence values
when cached in memory

11-34
35
36
37
The CREATE SEQUENCE Statement Syntax

Define a sequence to generate sequential numbers


automatically:

CREATE
CREATE SEQUENCE
SEQUENCE sequence
sequence
[INCREMENT
[INCREMENT BYBY n]
n]
[START
[START WITH
WITH n]
n]
[{MAXVALUE
[{MAXVALUE nn || NOMAXVALUE}]
NOMAXVALUE}]
[{MINVALUE
[{MINVALUE nn || NOMINVALUE}]
NOMINVALUE}]
[{CYCLE
[{CYCLE || NOCYCLE}]
NOCYCLE}]
[{CACHE
[{CACHE nn || NOCACHE}];
NOCACHE}];

11-38
Creating a Sequence
• Create a sequence named DEPTNO_SEQ to be
used for the primary key of the DEPT table.
• Do not use the CYCLE option.

CREATE
CREATE SEQUENCE
SEQUENCE deptno_seq
deptno_seq
INCREMENT
INCREMENT BY
BY 22
START
START WITH
WITH 4242
MAXVALUE
MAXVALUE 80
80
NOCACHE
NOCACHE
NOCYCLE;
NOCYCLE;
Sequence
Sequence created.
created.

creseq.sql
11-39
Using a Sequence
• Insert a new department named “Support” in
loc “Kowloon”.
INSERT
INSERT INTO
INTO dept(deptno,
dept(deptno, dname,
dname, loc)
loc)
VALUES
VALUES (deptno_seq.NEXTVAL,
(deptno_seq.NEXTVAL,
'Support',
'Support', ‘Kowloon');
‘Kowloon');
11 row
row created.
created.

• View the current value for the DEPTNO_SEQ


sequence.
SELECT
SELECT deptno_seq.CURRVAL
deptno_seq.CURRVAL
FROM
FROM dual;
dual;

creseq.sql
11-40
Removing a Sequence
• Remove a sequence from the data dictionary by using the
DROP SEQUENCE statement.
• Once removed, the sequence can no longer be referenced.

DROP
DROP SEQUENCE
SEQUENCE dept_deptid_seq;
dept_deptid_seq;
Sequence
Sequence dropped.
dropped.

11-41
Required Privileges
System privileges

DBA grants CREATE (ANY) PROCEDURE


ALTER ANY PROCEDURE
DROP ANY PROCEDURE
EXECUTE ANY PROCEDURE

Object privileges
Owner grants
EXECUTE

To be able to refer and access objects from a different


schema in a subprogram, you must be granted access to
the referred objects explicitly, not through a role.

11-42
Granting Access to Data
Direct access:
EMP
GRANT SELECT Scott
ON emp
TO scott;
Grant Succeeded.
SELECT
Indirect access:
GRANT EXECUTE Green
ON query_emp SCOTT.QUERY_EMP
TO green;
Grant Succeeded.

The procedure executes with the privileges of the


owner (default).
query_emp.sql 11-43
撤銷
How to Revoke Object Privileges
– You use the REVOKE statement to revoke
privileges granted to other users.
– Privileges granted to others through the WITH
GRANT OPTION will also be revoked.

REVOKE
REVOKE {privilege
{privilege [,
[, privilege...]|ALL}
privilege...]|ALL}
ON
ON object
object
FROM
FROM {user[,
{user[, user...]|role|PUBLIC}
user...]|role|PUBLIC}
[CASCADE
[CASCADE CONSTRAINTS];
CONSTRAINTS];

11-44
Revoking Object Privileges
• As user Alice, revoke the SELECT and INSERT
privileges given to user Scott on the DEPT table.

SQL>
SQL> REVOKE
REVOKE select,
select, insert
insert
22 ON
ON dept
dept
33 FROM
FROM scott;
scott;
Revoke
Revoke succeeded.
succeeded.

11-45
Why Use Views?
• To restrict data access
• To make complex queries easy
• To provide data independence
• To present different views of the same data

11-46
Why Use Views?

47
48
49
50
Create the view regardless Create the view only if

Creating a View
of whether or not the the base table(s) exist(s)
base table(s) exist(s)

• You embed a subquery within the CREATE VIEW


statement.
CREATE
CREATE [OR
[OR REPLACE]
REPLACE] [FORCE|NOFORCE]
[FORCE|NOFORCE] VIEW
VIEW view
view
[(alias[,
[(alias[, alias]...)]
alias]...)]
AS
AS subquery
subquery
[WITH
[WITH CHECK
CHECK OPTION
OPTION [CONSTRAINT
[CONSTRAINT constraint]]
constraint]]
[WITH
[WITH READ
READ ONLY
ONLY [CONSTRAINT
[CONSTRAINT constraint]];
constraint]];

• The subquery can contain complex only rowssyntax.


SELECT
Specifies that accessible to
the view can be inserted or updated

Ensures no DML operations can be


performed on the view

11-51
Creating a View
• Create a view, EMPVU80, that contains
details of employees in department 30.
CREATE VIEW empvu30
AS SELECT empno, ename, sal
FROM emp
WHERE deptno = 30;
View created.

• Retrieve data from the view EMPVU30.


SELECT *
FROM empvu30;

creview.sql
11-52
53
54
Removing a View

You can remove a view without losing data because a


view is based on underlying tables in the database.

DROP
DROP VIEW
VIEW view;
view;

DROP VIEW empvu80;


View dropped.

11-55
Countermeasures – Computer-Based
Controls
• Integrity
– Prevents data from becoming invalid, and hence
giving misleading or incorrect results.
• Encryption
– The encoding of the data by a special algorithm
that renders the data unreadable by any program
without the decryption key.

56
11-56
Countermeasures – Computer-Based
Controls
• Backup
– Process of periodically taking a copy of the
database and log file (and possibly programs) to
offline storage media.
• Journaling
– Process of keeping and maintaining a log file (or
journal) of all changes made to database to enable
effective recovery in event of failure.

57
11-57
Countermeasures – Computer-Based
Controls
• Availabilty
– Ensures that database service is available even in
event of failure.

58
11-58
Oracle Data Guard
Oracle Data Guard is the management, monitoring, and
automation software that works with a production database
and standby database(s) to protect the data against failures,
errors, and corruptions that destroy the production database.
One or more
copies of the
production
database
called

11-59
Switchover and Failover
– Switchover
• Planned role reversal
• Used for operating system or hardware
maintenance
– Failover
• Unplanned role reversal
• Use in emergency
• Minimal or zero data loss depending on
choice of data protection mode

11-60
61
62
Why Oracle Data Guard?
連續的
– Continuous service through a disaster or crippling
data failure 嚴重損壞 seriously damaging
– Complete data protection against corruptions and
data loss
– Get more work done on your production systems
– Eliminate idle standby systems
– Configure the system to meet business protection
and recovery requirements
– Centralized and simple management

11-63
RAID (Redundant Array of Independent
Disks) Technology
• A large disk array comprising an arrangement of several
independent disks having redundant components integrated
into the working system organized to
– improve reliability whenever there is one or more component
failures
– increase performance by ensuring the DBMS continues to operate
even if one of the hardware components fails.

64
11-64

You might also like