0% found this document useful (0 votes)
96 views57 pages

Group 22

The document discusses the roles and responsibilities of a database administrator (DBA). It begins by defining what a DBA is and their key responsibilities, which include deciding the database schema, storage structure, access strategy, liaising with users, defining authorization checks and validation procedures, and monitoring performance. It then provides more details on how a DBA would administer a database, including choosing an architecture, using data integrity rules, implementing security rules and access restrictions, and ensuring physical security, data privacy, and managerial controls. The role of the DBA in projects is also outlined, such as creating and deleting user accounts, granting and revoking privileges, and making the database secure. Finally, it defines database security and how it can

Uploaded by

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

Group 22

The document discusses the roles and responsibilities of a database administrator (DBA). It begins by defining what a DBA is and their key responsibilities, which include deciding the database schema, storage structure, access strategy, liaising with users, defining authorization checks and validation procedures, and monitoring performance. It then provides more details on how a DBA would administer a database, including choosing an architecture, using data integrity rules, implementing security rules and access restrictions, and ensuring physical security, data privacy, and managerial controls. The role of the DBA in projects is also outlined, such as creating and deleting user accounts, granting and revoking privileges, and making the database secure. Finally, it defines database security and how it can

Uploaded by

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

NAME……………………………………..ID…..

1.KIDANEMARIAM…………… CIR/127/10
2.HASAN NURI………….. CIR/ /10
3.GASHEHUN ASNAKE………… CIR/ /10
4.EGNUMA DEBISA………….. CIR/ /10
SUBMIT TO MR.WORKU MULUYE

SECTION B
DEPARTMENT: Information system

1
PROJECT TITLE: COLLEGE OF COMPUTING
AND INFORMATICS
2. What is Database Administration?
Database administration refers to the whole set of activities performed
by a database administrator to ensure that a database is always
available as needed. Other closely related tasks and roles are database
security, database monitoring and troubleshooting, and planning for
future growth. 

3. What is Database and who is Database administrator?


 Database Administrator (DBA) is individual or a group of
specialists who has good understanding of database and coordinates
all activities of the database and they have centralized control of
database
 Database administrator (DBA) is the information technical
responsible for ensuring the ongoing operational functionality and
efficiency of an organization’s databases and application that
access those databases.
 The DBA provides capability for database users while accessing
the content of the database. The DBA can perform some
responsibilities: Account Creation, Account Deletion, Granting the

2
privilege that who gives, revoking those privileges, Security Level
Assignment.
 RESPONSIBILITIES OF DATABASE ADMINISTRATOR (DBA)
Deciding the information content of the database (defining
schema)
It is the DBA’s job to decide exactly what information is to be held in
the database - in other words, to identify the entities of interest to the
enterprise and to identify the information to be recorded about those
entities. Having done this, the DBA must then define the content of
the database by writing the conceptual schema.

Deciding the storage structure and access strategy (access method)


The DBA must also decide how the data is to be represented in
the database, and must specify the representation by writing the
storage structure definition. In addition, the associated mapping
between storage structure definition and the conceptual schema
must also be specified. The DBA also must decide the access
method of the database properly in manageable way.

Liaising with the users


It is the business of the DBA to liaise with users, to ensure that the
data they require is available, and to write the necessary external
schemas. In addition, the mapping between any given external
schema and the conceptual schema must also be specified. In
practice the external DDL will probably include the means for

3
specifying the mapping, but the schema and the mapping should be
clearly distinguishable.

Defining authorization checks and validation procedures


Authorization checks and validation procedures may be considered
as logical extensions of the conceptual schema. The conceptual
DDL will include facilities for specifying such checks and
procedures.

Defining a strategy for backup and recovery


Once an enterprise is committed to a database, it become critically
dependent on the successful operation of that system. In the event of
damage to any portion of the database – caused by human error, say, or a
failure in the hardware or supporting operating system – it is essential to
be able to repair the data concerned with a minimum of delay and with
as little effect as possible on the rest of the system.

Monitoring performance and responsibilities to changes in requirements


The DBA is responsible for so organizing the system as to get the
performance that is “best for the enterprise” and for making the
appropriate adjustments change. Any change to details of storage and
access must be accompanied by a corresponding change to the definition
of the mapping to storage, so that the conceptual schema may remain
constant.

4
In short a database administrator is the specialist or a group of specialists
who has a higher responsibility to control and manage the DBMS. This
specialist or specialists has the following responsibilities

 Installing and upgrading the database server and application tools


 Allocating system storage and planning storage requirements for the
database system
 Modifying the database structure, as necessary, from information given
by application developers and as the organization need.

 Enrolling users and maintaining system security


 Ensuring compliance with database vendor license agreement
 Controlling and monitoring user access to the database
 Monitoring and optimizing the performance of the database
 Planning for backup and recovery of database information
 Maintaining archived data
 Backing up and restoring databases

4. How could you administer a database?


o While we are DBA we administrate database by using the
following ways and methods :-
o First choose the best database architecture and design it properly
because it is crucial the effectiveness of database administrator
o The design of the database must fit the need of the organization

5
o Then we use data integrity rules properly when define the schema
because those rules are the best guard to protect the data in
database environment
o Then if the data integrity rules are defined properly, we use
database security rules to protect the data from personal access
from inside the organization and outside the organization those
rules are:
 Access Privileges
o Users should access the database only in ways in which

they are entitled.


o Data in the database must access only and only by

authorized person.
o Security
o Access restrictions ensure that the database is secure.
o Passwords, encryption, and views implement security.
o Effective password protection is critical.

The database security issue can be considered from the following


aspects

 Data privacy: He owner of the data must be known and customer right
must be protected

6
 physical security: Hardware and software related and as well as data
related problem also must planned properly to administrate database
properly
 Managerial Controls:
Insiders
o Employee selection & Job termination
o Monitoring suspicious behavior
o Job segmentation (who can do what with data*) Physical & Logical
access limitations
Outsiders
o Physical access limitations
o “Shadowing”

4) Logical Security

Unauthorized disclosure (e.g., letting a competitor see the strategic


marketing plans)

Unauthorized modification (e.g., letting employees change their salary


figures)

Unauthorized withholding (e.g., preventing a finance officer from


retrieving data needed to get a bank loan).

7
5. What is role of DBA in your project?
The DBA has the overall control on our project. Those roles: -

 Create User account: - creating different accounts for different users as

well as user groups.


 Delete user account: - deleting an existing account of users or user groups.

 Grant Privileges to users: - giving different levels of privileges for different

users and user groups.


Privileges like: -
 Select or access data and information from the databases table
 Insert information into different tables
 Update the existing tables to be changed
 Delete records from any tables
 Revoke Privileges from the users: - denying or canceling previously

granted privileges for users due to various reasons.


 Make the Database Secure: - The DBA is responsible for the overall
security of the database system. The database administrator is responsible to
make the database to be secure. By limiting or restricting level of access to
the users.

6. What is database security and how could you secure database in oracle 12c?

Database security refers to the collective measures used to protect and


secure a database or database management software from illegitimate
use and malicious threats and attacks. It is a broad term that includes

8
a multitude of processes, tools and methodologies that ensure security
within a database environment
In other word, Database security is a protection of information in the
database and protecting data against unauthorized access, disclosure,
alteration, modification and destruction. Database security is making
the database or the data.
The oracle relational database management system (RDBMS): is an
industry leading database system designed for mission critical data
storage and retrieval
The RDBMS is responsible for accurately storing data and
effectively retrieving that data in response to user queries.
 In oracle 12c the database security is categorized in three
categories
1. Detective: There are also other mechanisms like activity
monitoring, database firewall, auditing and reporting.
2. Preventive: There are different mechanisms like:
Encryption is the Foundation Preventive Control for Oracle
Databases
o Transparent data encryption: is encrypts data at rest in

Oracle Databases
o Prevents access to data at rest

o Requires no application changes

9
o Built-in two-tier key management architecture: consisting of a
master encryption key and one or more data encryption keys.
o “Near Zero” overhead with hardware
o Integrations with Oracle technologies redaction, masking and sub
setting , privileged user control
3. Administrative: there is an also additional mechanism like key
management, privilege and data discovery, and configuration
management.

10
7.Difference between oracle and MYSQL
Oracle MYSQL
1.uses PL/SQL Server uses T-SQL,
2.Owned by oracle corporation Owned by Microsoft Corporation
3.Complex and more efficient Simpler and easier syntaxes
syntax
4.Clear and crisp error handling Displays error messages in pre-
defined formats
5.Uses a copy of the records while Uses Row or Page blocking and
modifying it and allows Reads of never allows a Read while the page
original data while doing the is blocked
modification
6.Values are not changed before Values are changed even before
commit Commit
7.It is much simpler to handle Transaction Failure requires the
because changes are done only on a data to be modified to the original
copy. before the Write process
8.Roll Back is allowed Roll Back is not allowed during a
transaction
9.Concurrent accesses are Concurrent accesses are not
permitted and waits are generally permitted when a Write is in
less progress. This leads to longer
waits.
10.Good support but with non- Excellent customer support
technical staffs as well
11.Runs on a variety of platforms Runs on Windows platform only
12.Lock sizes varies as per the Locks pages of the same size

11
need
13. Follows Dynamic memory Follows Global memory allocation
allocation and allows DBA to and less intrusion of DBA. Hence,
intrude more. So, chances of fewer chances of human errors.
human error is higher
14.Uses Bitmap, indexes based on No Bitmap, indexes based on
functions, and reverse keys functions, and reverse keys
15.Uses Star query optimization Query optimization is missing
16.Uses both After and Before Allows triggers and mostly uses
triggers After triggers
17.Uses java. Uses linked servers to read or write
to external files
18.complex interface Extremely simple user-interface
8. Describe the purpose of SQLPLUS,SQL developer and Enterprise
Management?

1) SQL is the query language that is used to communicate with Oracle


server to access and modify the data. SQL is a language, SQL*Plus is a
tool. SQL*Plus is an Oracle product that you use to run SQL and
PL/SQL statements. SQL*plus is a character based interactive tool, that
runs in a GUI environment.
2) SQL Plus is the most basic Oracle Database utility, with a basic
command-line interface, commonly used by users, administrators, and
programmers.
3) SQL*Plus is essentially an interactive query tool with some scripting
capabilities. You can enter a SQL statement, such as a SELECT query,

12
and view the results. You can execute data definition language (DDL)
statements to create tables and other objects. DBAs can use SQL*Plus to
start up, shut down, and otherwise administer a database. You can even
enter and execute PL/SQL code.
4) It is a non-GUI, character-based tool that has been around since the
dawn of the Oracle age. SQL Plus understands five categories of text:
1. SQL statements
2. PL/SQL blocks
3. SQL Plus internal commands, for example:-environment control
commands such as SET and environment monitoring commands such as
SHOW
4. Comments
5. External commands prefixed by the ! char
Scripts can include all of these components.
The purpose of SQLPLUS is provide the command line utility that
allows writing SQL and PL/SQL commands.

SQL Developer tool is used by Oracle and Other Database Vendors to


enable users design and code / interact with Databases.

SQL Developer supports Oracle Database 10g, 11g, and 12c and will run
on any operating system that supports Java. SQL Developer provides
powerful editors for working with SQL, PL/SQL, Stored Java
Procedures, and XML

13
A free graphical user interface, Oracle SQL Developer allows database
users and administrators to do their database tasks in fewer clicks and
keystrokes. A productivity tool, SQL Developer's main objective is to
help the end user save time and maximize the return on investment in the
Oracle Database technology stack."

Enterprise Manager uses the Microsoft Windows online help system to


provide you with help information for windows and dialog boxes in the
Console and database tools.

An enterprise manager is a set of software features designed to help


manage hardware and software on a particular platform. The term is
associated with an offering from Oracle that manages proprietary and
non-Oracle components of systems.

Oracle Enterprise Manager includes various components such as:

Oracle Enterprise Manager Database Control

Oracle Enterprise Manager Application Server Control

Oracle Enterprise Manager Grid Control

Various Oracle Enterprise Manager tools may help to centralize


administration and auditing of Oracle servers, streamline operations,
track compliance with industry standards or manage database life cycles.
Different management sub-functions include things like drift

14
management, the comparing of various configurations, and consistency
management, which can be applied to Oracle DBA environments.

9. Write Oracle 12c new features

Advanced Index Compression: Advanced Index Compression works


well on all supported indexes, including those indexes that are not good
candidates for the existing prefix compression feature; including
indexes with no, or few, duplicate values in the leading columns of the
index. Advanced Index Compression improves the compression ratios
significantly while still providing efficient access to the index.

Zone Maps: For full table access, zone maps allow I/O pruning of data
based on the physical location of the data on disk, acting like an anti-
index. Accessing only the relevant data optimizes the I/O necessary to
satisfy a query, increasing the performance significantly and reducing
the resource consumption.

Rapid Home Provisioning:

Rapid Home Provisioning allows deploying of Oracle homes based on


gold images stored in a catalog of pre-created homes. Provisioning time
for Oracle Database is significantly improved through centralized
management while the updating of homes is simplified to linkage.

15
Oracle snapshot technology is used internally to further improve the
sharing of homes across clusters and to reduce storage space.

Attribute Clustering:

Attribute clustering is a table-level directive that clusters data in close


physical proximity based on the content of certain columns. This
directive applies to any kind of direct path operation, such as a bulk
insert or a move operation. Storing data that logically belongs together
in close physical proximity can greatly reduce the amount of data to be
processed and can lead to better compression ratios.

Automatic Big Table Caching

In previous releases, in-memory parallel query did not work well


when multiple scans contended for cache memory. This feature
implements a new cache called big table cache for table scan
workload. This big table cache provides significant performance
improvements for full table scans on tables that do not fit entirely into
the buffer cache.

FDA Support for CDBs:

Flashback Data Archive (FDA) is supported for multitenant container


databases (CDBs) in this release. Customers can now use Flashback
Data Archive in databases that they are consolidating using Oracle
Multitenant, providing the benefits of easy history tracking to

16
applications using pluggable databases (PDB) in a multitenant
container database.

Full Database Caching

Full database caching can be used to cache the entire database in


memory. It should be used when the buffer cache size of the database
instance is greater than the whole database size. In Oracle RAC systems,
for well-partitioned applications, this feature can be used when the
combined buffer caches of all instances, with some extra space to handle
duplicate cached blocks between instances, is greater than the database
size. Caching the entire database provides significant performance
benefits, especially for workloads that were previously limited by I/O
throughput or response time. More specifically, this feature improves the
performance of full table scans by forcing all tables to be cached. This is
a change from the default behavior in which larger tables are not kept in
the buffer cache for full table scans.

In-Memory Aggregation: In-Memory Aggregation optimizes queries


that join dimension tables to fact tables and aggregate data (for example,
star queries) using CPU and memory efficient KEY VECTOR and
VECTOR GROUP BY aggregation operations.

17
PDB Metadata Clone: An administrator can now create a clone of a
pluggable database only with the data model definition. The dictionary
data in the source is copied as is but all user-created table and index data
from the source is discarded. This feature enhances cloning functionality
and facilitates rapid provisioning of development environments.

PDB Remote Clone: The new release of Oracle Multitenant fully


supports remote full and snapshot clones over a database link. A non-
multitenant container database (CDB) can be adopted as a pluggable
database (PDB) simply by cloning it over a database link. Remote
snapshot cloning is also supported across two CDBs sharing the same
storage. This feature further improves rapid provisioning of pluggable
databases. Administrators can spend less time on provisioning and focus
more on other innovative operations.

PDB Snapshot Cloning Additional Platform Support: With the


initialization parameter CLONEDB set to true, snapshot clones of a
pluggable database are supported on any local, Network File Storage
(NFS) or clustered file systems with Oracle Direct NFS (DNFS) enabled.
The source of the clone must remain read-only while the target needs to
be on a file system that supports sparseness. Snapshot cloning support is
now extended to other third-party vendor systems. This feature eases the
requirement of specific file systems for snapshot clones of pluggable

18
databases. With file system agnostic snapshot clones, pluggable databases
can be provisioned even faster than before.

PDB State Management across CDB Restart: The SAVE STATE


clause and DISCARD STATE clause are now available with the
ALTER PLUGGABLE DATABASE SQL statement to preserve the
open mode of a pluggable database (PDB) across multitenant
container database (CDB) restarts. If SAVE STATE is specified,
open mode of specified PDB is preserved across CDB restart on
instances specified in the INSTANCES clause. Similarly, with the
DISCARD STATE clause, the open mode of specified PDB is no
longer preserved. These new SQL clauses provide the flexibility to
choose the automatic startup of application PDBs when a CDB
undergoes a restart. This feature enhances granular control and
effectively reduces downtime of an application in planned or
unplanned outages.
PDB Subset Cloning: The USER_TABLESPACES clause allows a
user to specify which table spaces need to be available in the new
pluggable database (PDB). An example of the application of this clause
is a case where a customer is migrating from a non-multitenant container
database (CDB) where schema-based consolidation was used to separate
data belonging to multiple tenants to a CDB where data belonging to
each tenant is kept in a separate PDB. The USER_TABLESPACES
clause helps to create one PDB for each schema in the non-CDB. This

19
powerful clause helps convert cumbersome schema-based consolidations
to more agile and efficient pluggable databases.

11. Identify users and their role in your project.

CCI management system users and their role in our project.

No User Role
1. Habte Head
2 Feydu Dean
3 Sefidein Instructor
4. Genet Assistant
6. Kidanemariam Student

12. Using SQLPLUS connect as A SYSDBA and create another DBA user
within a pluggable database regarding your project business rule.
Enter user-name: sys as sysdba
Enter password:

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED


---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO

20
3 ORCLPDB READ WRITE NO
4 DORM READ WRITE NO
5 CCIMS READ WRITE NO
6 CCI READ WRITE NO
SQL> alter session set container=CCI;
Session altered.
13. Connect a new DBA to the database and create other
users that access the database based on your use case.
SQL> create user ADMN identified by admn;

User created.

SQL> grant DBA to ADMN;

Grant succeeded.

SQL> grant create session to ADMN;

Grant succeeded.

SQL> connect ADMN/admn@//localhost:1521/cci;


Connected.

SQL> show user;


USER is "ADMN"

SQL> create user Feydu identified by fey;

User created.

21
SQL> alter user Feydu default tablespace users quota unlimited on
users;

User altered.

SQL> grant create session to Feydu;

Grant succeeded.

SQL> create user haftemuu identified by hafte;

User created.

SQL> alter user Haftemuu default tablespace users quota unlimited on


users;
User altered.

SQL> grant create session to Haftemuu;

Grant succeeded.

SQL> create user Werku identified by werk;

User created.

SQL> alter user Werku Default Tablespace users quota unlimited on


users;

User altered.

SQL> grant create session to Werku;

22
Grant succeeded.

SQL> create user Ganet identified by gani;

User created.

SQL> alter user Ganet default tablespace users quota unlimited on


users;//without giving tablespace the user cannot insert,update,and
delete.

User altered.

SQL> grant create session to Ganet;

Grant succeeded.

SQL> create user Kidanemariyam identified by kidu;

User created.

SQL> alter user Kidanemariyam default tablespace users quota


unlimited on users;

User altered.

SQL> grant create session to Kidanemariyam;

Grant succeeded.

14. Create roles.


SQL> create role Dean;

23
Role created.

SQL> create role Head;

Role created.

SQL> create role Instructor;

Role created.

SQL> create role Assistant;

Role created.

SQL> create role Student;

Role created.

15. What is profile?


 Profile is a set of limits on database resource. If we assign
the profile to a user ,then that user cannot exceed the limit.
 Is a collection of parameters that sets limits on database
resource. When we change the profile to a user, we assign a
profile but you apply also a set of parameters.

create profile.

SQL> CREATE PROFILE userProfile LIMIT


2 FAILED_LOGIN_ATTEMPTS 3

24
3 PASSWORD_LIFE_TIME 60
4 PASSWORD_REUSE_TIME 60
5 PASSWORD_REUSE_MAX 5
6 PASSWORD_LOCK_TIME 1/24
7 PASSWORD_GRACE_TIME 10;
Profile created.
16. Grant system privileges to the Roles may be Alter Database,
Create Pluggable Database, Create Table, Create Any Table,
Alter Any Table, Drop Any Table, Lock Any Table, Select Any
Table, Insert Any Table, Update Any Table, Delete Any Table,
Create Session, Create Any Index, Drop Any Index, Create
Tablespace, Unlimited Tablespace, Create Role, Drop Any Role,
Grant Any Role, Create Trigger, Create Any Trigger, Create
Procedure, Create Any Procedure, Drop Any Procedure, Create
User, Alter User, Drop User, Create View, Create Any View,
Drop Any View…

SQL> grant create session ,Alter Database,Create Pluggable


Database,Create Any Table,Alter Any Table,drop Any Table,Lock Any
Table,Select Any Table,Create Role,Drop Any Role,Grant Any
Role,create User,Alter User,Drop User,Create Any View to Dean;
Grant succeeded.

25
SQL> grant create session, create table, create Any view ,drop Any table
to Head;
Grant succeeded.

SQL> grant create session, create View, create Table to Instructor;

Grant succeeded.

SQL> grant create session, create View to Assistant;

Grant succeeded.

SQL> grant create session, create View to Student;

Grant succeeded.

17. Identify user’s responsibility from the organization business


rule and grant Roles to the Users and then connect high privilege
user to the pluggable database.

SQL> show user;


USER is "ADMN"

SQL> grant Head to haftemuu;

Grant succeeded.

SQL> grant Instructor to Werku;

Grant succeeded.

26
SQL> grant select on ADMN.Student to Student;

Grant succeeded.

SQL> grant Student to Kidanemariyam;

Grant succeeded.

SQL> grant Dean to Feydu;

Grant succeeded.

18. Create 3rd normalized tables and create triggers that enables
to update and delete data from both parent and child tables since
oracle supports only on delete cascade but not on update
cascade.

SQL> create table Department(DepID varchar(10) primary key,


DepName varchar(30) not null,Deplocation varchar(30)not null
,Dep_HName varchar(30));

Table created.

SQL> insert into Department values('10','IS','second floor of cci


collage','Hafte');

1 row created.

27
SQL> insert into Department Values('11','SE','second floor of cci
collage','aaaa');

1 row created.

SQL> insert into Department values('12','IT','3rd floor of cci collage


','iiii');

1 row created.

SQL> insert into Department values('13','CS','3rd floor of cci


collage','cccc');

1 row created.

28
SQL> select*from Department;

DEPID DEPNAME DEPLOCATION


---------- ------------------------------ ------------------------------
DEP_HNAME
------------------------------
10 IS second floor of cci collage
Hafte

11 SE second floor of cci collage


aaaa

12 IT 3rd floor of cci collage


iiii

13 CS 3rd floor of cci collage


cccc

SQL> create table Instructor(Inst_ID varchar(10) primary


key,Inst_Name varchar(30)not null, Inst_Gender varchar(30)not
null,Inst_Experience varchar(10),Inst_Salary float,Inst_Age Int, DepID
varchar(10) ,foreign key(DepID) references Department(DepID));

Table created.

SQL> insert into Instructor values('1','mr.werku','Male','5


year',7000,30,'10');

1 row created.

29
SQL> insert into Instructor values('2','mr.sefedin','Male','2
year',7000,29,'11');

1 row created.

SQL> insert into Instructor values('3','mr.henok','Male','3


year',7000,33,'10');

1 row created.

SQL> select * from Instructor;

INST_ID INST_NAME INST_GENDER


---------- ------------------------------ ------------------------------
INST_EXPER INST_SALARY INST_AGE DEPID
---------- ----------- ---------- ----------
1 mr.werku Male
5 year 7000 30 10

2 mr.sefedin Male
2 year 7000 29 11

3 mr.henok Male
3 year 7000 33 10

SQL> create table Course(Course_Code varchar(10) primary


key,Course_Name varchar(30)not null,Credit_Hour int, Course_Type
varchar(30)not null, DepID varchar(10) ,foreign key(DepID) references
Department(DepID));

Table created.

30
SQL> insert into Course values('INSSY1111','Advanced DB',5,'major
course','10');

1 row created.

SQL> insert into Course values('INSSY011','c#',7,'major course','10');

1 row created.

SQL> insert into Course values('INSSY012','OOSAD',5,'major


course','10');

1 row created.

SQL> select* from Course;


COURSE_COD COURSE_NAME CREDIT_HOUR
---------- ------------------------------ -----------
COURSE_TYPE DEPID
------------------------------ ----------
INSSY1111 Advanced DB
5
major course 10

INSSY011 c#
7
major course 10

INSSY012 OOSAD
5
major course 10

SQL> create table Class(Class_No varchar(10) primary key,


Class_Location varchar(30)not Null,Bulding_No varchar(30)not Null);

31
Table created.

SQL> drop table Class;

Table dropped.

SQL> create table Student(Stud_ID varchar(10) primary key,


Stud_FName varchar(30)not null,Stud_LName varchar(30)not
null,Stud_Gender varchar(30)not null,GPA float,Birth_Of_date date,age
int,Section Varchar(1)not null,DepID varchar(10) ,foreign
key(DepID) references Department(DepID));

Table created.

SQL> insert into Student


values('CIR/127/10','kidan','kuma','male',3.00,'12 dec 1990',20,'B','10');

1 row created.

SQL> insert into Student values('CIR/120/10','hansar','nuri','male',3.00,'1


jan 1990',20,'B','10');

1 row created.

SQL> insert into Student


values('CIR/107/10','Egnuma','Debisa','Fmale',3.00,'1 jan
1990',20,'B','10');

32
1 row created.

SQL> insert into Student values('CIR/118/10','Gashehun','Asnake','male',3.00,'3 jul


1990',20,'B','10');

1 row created.

SQL> select * from Student;

STUD_ID STUD_FNAME STUD_LNAME


---------- ------------------------------ ------------------------------
STUD_GENDER GPA BIRTH_OF_ AGE S DEPID
------------------------------ ---------- --------- ---------- - ----------
CIR/127/10 kidan kuma
male 3 12-DEC-90 20 B 10

CIR/120/10 hansar nuri


male 3 01-JAN-90 20 B 10

CIR/107/10 Egnuma Debisa


Fmale 3 01-JAN-90 20 B 10

CIR/118/10 Gashehun Asnake


male 3 03-JUL-90 20 B 10

SQL> create table Class(Class_No varchar(10) primary key,


Class_Location varchar(30)not Null,Bulding_No varchar(30)not Null,

33
Stud_ID varchar(10) ,foreign key(Stud_ID) references
Student(Stud_ID));

Table created.

SQL> insert into Class values('CCi03','around CCI


collage','111','CIR/127/10');

1 row created.

SQL> insert into Class values('CCI04','around CCI


collage','110','CIR/120/10');

1 row created.

SQL> insert into Class values('CCI05','around CCI


collage','111','CIR/107/10');

1 row created.
SQL> select *from Class;

CLASS_NO CLASS_LOCATION BULDING_NO


---------- ------------------------------ ------------------------------
STUD_ID
----------
CCi03 around CCI collage 111
CIR/127/10

CCI04 around CCI collage 110


CIR/120/10

CCI05 around CCI collage 111


CIR/107/10

34
SQL>create table StudentPhone(phone_no varchar(20) primary
key,Stud_ID varchar(10) ,foreign key(Stud_ID) references
Student(Stud_ID));
Table created.
SQL>insert into StudentPhone('0947398069','CIR/127/10');
1 row created.
SQL>insert into StudentPhone('09883168069','CIR/120/10');
1 row created.
SQL>insert into StudentPhone('0971738069','CIR/107/10');
1 row created.
SQL>insert into StudentPhone('0918586069','CIR/118/10');
1 row created.
SQL> select* from StudentPhone;

PHONE_NO STUD_ID
-------------------- ----------
0947398069 CIR/127/10
0988168069 CIR/120/10
0971738069 CIR/107/10
0918586069 CIR/118/10

SQL>create table InstructorPhone(phone_no varchar(20) primary


key,Inst_ID varchar(10) ,foreign key(Inst_ID) references
Instructor(Inst_ID));
Table created.
SQL>insert into InstructorPhone('0916536522 ','1');

35
1 row created.
SQL>insert into StudentPhone('09883168069','CIR/120/10');
1 row created.
SQL>insert into StudentPhone('0920938947 ','2');
1 row created.
SQL> select*from InstructorPhone;

PHONE_NO INST_ID
-------------------- ----------
0916536522 1
0920938947 2

SQL> create table studinstcorsjucnction(Stud_ID varchar(10), foreign


key(Stud_ID) references Student(Stud_ID),Inst_ID varchar(10), foreign
key(Inst_ID) references Instructor(Inst_ID), Course_Code varchar(10),
foreign key(Course_Code) references Course(Course_Code),constraint
PKInsStuCour primary key (Inst_ID, Stud_ID,Course_Code));

Table created.

SQL> insert into studinstcorsjucnction


values('CIR/127/10','1','INSSY011');

1 row created.

SQL> insert into studinstcorsjucnction


values('CIR/120/10','2','INSSY012');

1 row created.

36
SQL> select*from studinstcorsjucnction;

STUD_ID INST_ID COURSE_COD


---------- ---------- ----------
CIR/127/10 1 INSSY011
CIR/120/10 2 INSSY012

19. The table owner grant object privileges to the Roles or Users may be
Select, Insert, Update, Delete, Alter, Index, References…

SQL> GRANT select, update, delete, Insert on ADMN.Student to


Head;

Grant succeeded.

SQL> grant select, update, delete, Insert on ADMN.Course to Head;

Grant succeeded.

SQL> grant select, update, delete, Insert on ADMN.Course to Instructor;

Grant succeeded.

SQL> grant select, update, delete, Insert on ADMN.Student to


Instructor;

Grant succeeded.

SQL> grant select on ADMN.Student to Student;

37
Grant succeeded.

SQL> grant select, update, delete, Insert on ADMN.Student to Dean;

Grant succeeded.

SQL> grant select, update, delete, Insert on ADMN.Instructor to Dean;

Grant succeeded.

20 . Create synchronized backup copy trigger for each


table.
SQL> connect sys/sys as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL> connect ADMN/admn@//localhost:1521/CCI;
Connected.
SQL> show user
USER is "ADMN"
SQL> Set Serveroutput On;
SQL> Create or replace trigger BeforeAll_STUDENT
2 Before Insert or Update or Delete on STUDENT
3 For each row
4 Enable
5 Declare
6 userName varchar2(60);
7 Begin
8 select user into userName from dual;
9 If Inserting Then
10 DBMS_OUTPUT.PUT_LINE ('One Row Inserted By Mr. '||
userName);

38
11 ElsIf Updating Then
12 DBMS_OUTPUT.PUT_LINE ('One Row Updated By Mr. '||
userName);
13 ElsIf Deleting Then
14 DBMS_OUTPUT.PUT_LINE ('One Row Deleted By Mr. '||
userName);
15 End If;
16 end;
17 /
Trigger created.

SQL> delete Student;


One Row Deleted By Mr. ADMN
One Row Deleted By Mr. ADMN
One Row Deleted By Mr. ADMN
One Row Deleted By Mr. ADMN

SQL> Create or replace trigger BeforeAll_Department


2 Before Insert or Update or Delete on Department
3 For each row
4 Enable
5 Declare
6 userName varchar2(60);
7 Begin
8 select user into userName from dual;
9 If Inserting Then
10 DBMS_OUTPUT.PUT_LINE ('One Row Inserted By '||userName);
11 ElsIf Updating Then
12 DBMS_OUTPUT.PUT_LINE ('One Row Updated By '||
userName);

39
13 ElsIf Deleting Then
14 DBMS_OUTPUT.PUT_LINE ('One Row Deleted By '||userName);
15 End If;
16 end;
17 /

Trigger created.

SQL> delete Department;


One Row Deleted By ADMN
One Row Deleted By ADMN
One Row Deleted By ADMN
One Row Deleted By ADMN

SQL> Create or replace trigger BeforeAll_COURSE


2 Before Insert or Update or Delete on COURSE
3 For each row
4 Enable
5 Declare
6 userName varchar2(60);
7 Begin
8 select user into userName from dual;
9 If Inserting Then
10 DBMS_OUTPUT.PUT_LINE ('One Row Inserted By '||
userName);
11 ElsIf Updating Then
12 DBMS_OUTPUT.PUT_LINE ('One Row Updated By '||
userName);
13 ElsIf Deleting Then
14 DBMS_OUTPUT.PUT_LINE ('One Row Deleted By '||userName);
15 End If;
16 end;
17 /

Trigger created.

40
SQL> delete COURSE;
One Row Deleted By ADMN
One Row Deleted By ADMN
One Row Deleted By ADMN

******************BACKUP***************

CREATE TABLE Student_BACKUP AS SELECT* FROM STUDENT


WHERE 1=2;
create or replace trigger Student_Backup
before Insert or update or delete on Student
For each row
Enable
Begin
If Inserting Then
Insert into
Student_Backup(Stud_ID,Stud_FName,Stud_LName,Stud_Gender,GPA
,Birth_Of_date,age,Section,DepID )
Values(:New.Stud_ID,:New.Stud_FName,:New.Stud_LName,:New.Stu
d_Gender,:New.GPA,:New.Birth_Of_date,:New.Age,:New.Section,:Ne
w.DepID );
ElsIf Updating Then
Update Student_Backup set Stud_ID
=:new.Stud_ID,Stud_FName=:New.stud_FName,Stud_LName=:New.st
ud_LName
,Stud_Gender=:New.Stud_Gender,GPA=:New.GPA,Birth_Of_date=:Ne
w.Birth_Of_date,age=:New.age,
Section=:New.Section,DepID=:New.DepID
where Stud_ID =:Old.Stud_ID ;
ElsIf Deleting Then
Delete From Student_Backup Where Stud_ID=:Old.Stud_ID ;
End If;

41
end;
Trigger created.

CREATE TABLE Instruct_BACKUP AS SELECT* FROM


INSTRUCTOR WHERE 1=2;
create or replace trigger instruct_Backup
before Insert or Update or Delete on Instructor
for each row
Enable
Begin
If inserting Then
Insert Into
instruct_backUp(Inst_ID,Inst_Name,Inst_Gender,Inst_Experience,Inst_
Salary,DepID)
values
(:New.Inst_ID,:New.Inst_Name,:New.Inst_Gender,:New.Inst_Experienc
e,:New.Inst_Salary,:New.DepID);
ElsIf Updating Then
Update instruct_Backup set Inst_ID
=:new.Inst_ID,Inst_Name=:New.Inst_Name,INST_GENDER=:New.Ins
t_Gender,
INST_EXPERIENCE=:New.Inst_Experience,INST_SALARY=:New.In
st_Salary,DEPID=:New.DepId where INST_ID=:Old.Inst_ID ;
ElsIf Deleting Then
Delete From Instruct_Backup Where Inst_ID=:Old.Inst_ID;
End If;
end;

Trigger created.

21. Create database security audit by using DBA audit TRIAL


for each table to audit DML operations.

42
--------------------DBA AUDIT TRIAL-----------------------------------------

CREATE OR REPLACE TRIGGER STUDENT_AUDIT


BEFORE INSERT OR UPDATE OR DELETE ON
STUDENT
FOR EACH ROW
ENABLE
DECLARE
USER_NAME VARCHAR2(30);
USED_DATE VARCHAR2(60);
BEGIN
select user, to_CHAR (Sysdate, 'DD/MoN/YYY
HH24:MI:SS')into USER_NAME,USED_DATE FROM
DUAL;
IF INSERTING THEN

insert into
STUDENT_AUDIT(New_Stud_ID,Old_Stud_ID
,New_Stud_FName,
Old_Stud_FName,New_Stud_LName,Old_Stud_LName,

43
New_Stud_Gender,Old_Stud_Gender,New_GPA,Old_GPA,Ne
w_Birth_Of_date,

Old_Birth_Of_date,New_age,Old_age,New_Section,Old_Sectio
n,New_DepID,
Old_DepID ,USER_NAME,ENTERY_DATE,Operation)
VALUES(:NEW.Stud_ID,NULL,
:NEW.Stud_FNAME,NULL,:NEW.Stud_LNAME,NULL,:NE
W.Stud_Gender,NULL,:NEW.GPA,NULL,

:NEW.Birth_Of_date,NULL,:NEW.Age,NULL,:NEW.Section,
NULL,
:NEW.DepID,NULL,USER_NAME,USED_DATE,'INSERT');

ELSIF UPDATING THEN

insert into STUDENT_AUDIT(New_Stud_ID,Old_Stud_ID


,New_Stud_FName,

Old_Stud_FName,New_Stud_LName,Old_Stud_LName,New_
Stud_Gender,Old_Stud_Gender,

44
New_GPA,Old_GPA,New_Birth_Of_date,Old_Birth_Of_date,
New_age,Old_age,New_Section,
Old_Section,New_DepID,Old_DepID
,USER_NAME,ENTERY_DATE,Operation)
VALUES(:NEW.Stud_ID,:OLD.Stud_ID,
:NEW.Stud_FNAME,:Old.Stud_FNAME,:NEW.Stud_LNAME,
:Old.Stud_LNAME,:NEW.Stud_Gender,:Old.Stud_Gender,:NE
W.GPA,:Old.GPA,

:NEW.Birth_Of_date,:Old.Birth_Of_date,:NEW.Age,:Old.Age,:
NEW.Section,:Old.Section,

:NEW.DepID,:Old.DepID,USER_NAME,USED_DATE,'UPDA
TE');

ELSIF DELETING THEN

insert into STUDENT_AUDIT(New_Stud_ID,Old_Stud_ID


,New_Stud_FName,

45
Old_Stud_FName,New_Stud_LName,Old_Stud_LName,New_
Stud_Gender,Old_Stud_Gender,

New_GPA,Old_GPA,New_Birth_Of_date,Old_Birth_Of_date,
New_age,Old_age,New_Section,
Old_Section,New_DepID,Old_DepID
,USER_NAME,ENTERY_DATE,Operation)
VALUES(NULL,:Old.Stud_ID,NULL,
:Old.Stud_FNAME,NULL,:Old.Stud_LNAME,NULL,:Old.Stud
_Gender,NULL,:Old.GPA

,NULL,:Old.Birth_Of_date,NULL,:Old.Age,NULL,:Old.Sectio
n,NULL,
:Old.DepID,USER_NAME,USED_DATE,'DELETE');
END IF;
END;
AUDIT SELECT ,UPDATE,INSERT,DELETE ON
ADMN.COURSE;
Audit succeeded.

46
AUDIT SELECT ,UPDATE,INSERT,DELETE ON
ADMN.STUDENT;
Audit succeeded.
AUDIT SELECT ,UPDATE,INSERT,DELETE ON
ADMN.CLASS;
Audit succeeded.
AUDIT SELECT ,UPDATE,INSERT,DELETE ON
ADMN.INSTRUCTOR;
Audit succeeded.
AUDIT SELECT ,UPDATE,INSERT,DELETE ON
ADMN.STUD_PHONE;
Audit succeeded.

COURSE
//////////////////////////////////////////////////////////////////////////

Create table Course_AUDIT(New_course_code varchar2(20),


Old_course_code varchar2(20),New_course_name varchar(20),
Old_course_name varchar(20),New_credit_hour varchar(20),
Old_credit_hour varchar(20),New_DepId
varchar(20),Old_DepId varchar(20),

47
USER_NAME varchar2(20),ENTERY_DATE varchar2(20),Operation
varchar2(20));

CREATE OR REPLACE TRIGGER Course_AUDIT


BEFORE INSERT OR UPDATE OR DELETE ON Course
FOR EACH ROW
ENABLE
DECLARE
USER_NAME VARCHAR2(30);
USED_DATE VARCHAR2(60);
BEGIN
select user, to_CHAR (Sysdate, 'DD/MoN/YYY HH24:MI:SS')into
USER_NAME,USED_DATE FROM DUAL;
IF INSERTING THEN

insert into Course_AUDIT(New_course_code ,


Old_course_code ,New_course_name ,
Old_course_name ,New_credit_hour ,
Old_credit_hour ,New_DepId ,Old_DepId ,
USER_NAME ,ENTERY_DATE ,Operation )
VALUES(:NEW.Course_Code,Null,:New.Course_Name,Null,:New.Cre
dit_Hour,Null,:New.DepID,Null,
USER_NAME,USED_DATE,'INSERT');

48
ElsIf Updating Then

insert into Course_AUDIT(New_course_code ,


Old_course_code ,New_course_name ,
Old_course_name ,New_credit_hour ,
Old_credit_hour ,New_DepId ,Old_DepId ,
USER_NAME ,ENTERY_DATE ,Operation )
VALUES(:NEW.Course_Code,:Old.Course_Code,:New.Course_Name,:
Old.Course_Code,:New.Credit_Hour,:Old.Credit_Hour,:New.DepID,:Ol
d.DepID,
USER_NAME,USED_DATE,'UPDATE');

ElsIf Deleting Then

insert into Course_AUDIT(New_course_code ,


Old_course_code ,New_course_name ,
Old_course_name ,New_credit_hour ,
Old_credit_hour ,New_DepId ,Old_DepId ,
USER_NAME ,ENTERY_DATE ,Operation )
VALUES
(Null,:Old.Course_Code,Null,:Old.Course_Name,Null,:Old.Credit_Hour
,Null,:Old.DepID,

49
USER_NAME, USED_DATE,'DELETE');
END IF;
END;

22.create DDL trigger for each table with schema


auditing to audit DDL operations (track changes to the
database)
DDL auditing
////////////////////////////////////
CREATE TABLE SCHEMA_AUDIT(DDL_DATE
DATE,DDL_USER VARCHAR(40), EVENET_ONOBJECT
VARCHAR(40),
OBJECT_NAME VARCHAR(40),DDL_OPERATION
VARCHAR(40));
CREATE OR REPLACE TRIGGER SCH_AUDIT
AFTER DDL ON SCHEMA
BEGIN
INSERT INTO SCHEMA_AUDIT VALUES(Sysdate,
Sys_context('USERENV', 'CURRENT_USER'),
Ora_Dict_Obj_Type,
Ora_Dict_Obj_Name,

50
Ora_Sysevent);
End;
hr _schema_audit
Create or replace trigger hr_Schema_Audit
After DDL On Schema
BEGIN
Insert into Schema_Audit Values(Sysdate,
Sys_context('USERENV', 'CURRENT_USER'),
Ora_Dict_Obj_Type,
Ora_Dict_Obj_Name,
Ora_Sysevent);
End;

23.create database level schema level triggers(to monitor or


audit the system event such as user logon,user logoff,database
shutdown and startup
/////////////////////////////logon
Create Table ADMN_Event_Audit (
Event_type Varchar2(40),
Logon_date date,
Logon_time Varchar2(50),
Logoff_date date,
Logoff_time Varchar2(50)
);
Create or Replace Trigger ADMN_Logon_Audit
After Logon On Schema
Begin
Insert into ADMN_Event_Audit values(
Ora_sysevent,

51
Sysdate,
To_Char(Sysdate, 'HH24:MI:SS'),
Null,
Null);
Commit;
End;

DISC;
Connect ADMN/admn@//Localhost:1521/CCI;

select * from ADMN_Event_Audit;

EVENT_TYPE LOGON_DAT
---------------------------------------- ---------
LOGON_TIME LOGOFF_DA
-------------------------------------------------- ---------
LOGOFF_TIME
--------------------------------------------------
LOGON 01-JUN-19
23:31:01

LOGON 01-JUN-19
23:33:29

EVENT_TYPE LOGON_DAT
---------------------------------------- ---------
LOGON_TIME LOGOFF_DA
-------------------------------------------------- ---------
LOGOFF_TIME

52
--------------------------------------------------
/////////////////////////////////logoff
Create Table ADMN_Event_Audit (
User_name Varchar2(40),
Event_type Varchar2(40),
Logon_date date,
Logon_time Varchar2(50),
Logoff_date date,
Logoff_time Varchar2(50)
);

Create or Replace Trigger ADMN_Logoff_Audit


Before Logoff On Database
Begin
Insert into ADMN_Event_Audit values(
User,
Ora_sysevent,
Null,
Null,
Sysdate,
To_Char(Sysdate, 'HH24:MI:SS')
);
Commit;
End;
show user;
////////////////////////////////////
24. lock and unlock users, revoke system and object privileges,
drop users when user turnover from the organization.
/////////////////////////////////Lock and unlock

53
alter user haftamu account lock;
alter user haftamu account unlock;

alter user Kidanemariyam account lock;


alter user Kidanemariyam account unlock;

alter user Werku account lock;


alter user Werku account unlock;

alter user Ganet account lock;


alter user Ganet account unlock;
///////////////////////////////////// Revoke privilege

revoke Alter Database, Create Pluggable Database, from Dean;

revoke create any view ,create session, drop any table from
Head;

revoke create view, Create table from Instructor;

revoke create View,Create Session from Student;

revoke create session,Create View from Assistant;

/////////////////////////////////////////////////////// drop user

54
drop user Haftamu;
drop user Werku

25.backup your database using RMAN.


////////////////////////////////////////////////Rman Backup
List of Datafiles in backup set 15
Container ID: 6, PDB Name: CCI
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
20 Full 8417066 02-JUN-19 NO E:\APP\ORACLE12C\ORADATA\ORCL\CCI\SYSTEM01.DBF
21 Full 8417066 02-JUN-19 NO E:\APP\ORACLE12C\ORADATA\ORCL\CCI\SYSAUX01.DBF
22 Full 8417066 02-JUN-19 NO
E:\APP\ORACLE12C\ORADATA\ORCL\CCI\UNDOTBS01.DBF
23 Full 8417066 02-JUN-19 NO E:\APP\ORACLE12C\ORADATA\ORCL\CCI\USERS01.DBF
26.Recover your database level and transaction from accidental
and intentional failures.
27 Describe the concept of a distributed database.
Distributed database: A logically interrelated collection of
shared data (and a description of this data) physically distributed
over a computer network. A distributed database is a collection
of data which are distributed over different computers of a
computer network
Advantages
 Matches distributed organizational model
 Improved sharability and local autonomy
 Improved availability
 Improved reliability
 Improved performance
 Economics
 Modular growth
Disadvantages
 Complexity
 Cost Security
 Lack of standards

55
 Integrity control more difficult
 Database design more complex
21. Design distributed database model(architecture) for your
project and identify data distribution/allocation strategies and
data storage mechanism to store a single relation in a distributed
database architecture.

28 distributed database design refers to the following


problem:given a database and its workload, how should the
databases split and allocate a sites so as to optimize certain
objective function(e.g., To minimize the resource consumption
in the processing query workload).
In distributed database design two issues considered:-
 Data fragmentation which determines how the data should be
fragmented and
 Data allocation which determines how the fragments should
allocated.
The design problem is applicable when a distributed database
system has to be built from scratch. In the case when multiple
existing databases are to integrated(e.g.in multi-database
context),there is no design issue.
Architecture
A database user accesses the distributed database through:

56
 Local applications: applications which do not require
data from other sites.
 Global applications:- applications which do require
data from other sites.

57

You might also like