Lecture 2 & 3
Lecture 2 & 3
Management (II)
Lecturer: Isaac Baffour Senkyire
Review of DB Design &
Management (I)
Database
• Shared collection of logically related data (and a description of this
data), designed to meet the information needs of an organization
or is a system which holds data as an integrated system of records
and metadata, or data about data/descriptions of the data held in
the database.
• Conceptual Level
• Community view of the database.
• Describes what data is stored in database and relationships
among the data.
ANSI-SPARC Three-Level
Architecture
• Internal Level
• Physical representation of the database on the
computer.
• Describes how the data is stored in the database.
Database
Administration
DB Administrator
• A Database Administrator (DBA) is a person (or group of people)
who controls the day to day running of the database and provides
technical support for users in ensuring that the database is used
efficiently and correctly.
Functions of a DB Administrator
• Defining the database
• Liaising with users
• Defining & Monitoring
• security & integrity checks
• backup & recovery procedures
• Monitoring performance
• Responding to change
Functions of a DB Administrator
• Defining the database
• Definitions of the DB Schema from the logical DB design
• Mapping the model onto the storage
• Liaising with users
• Defining the user’s view of the data
• Assistance with application design
• Technical education
Functions of a DB Administrator
• Security Checks
• Enrolling new users
• Defining their level of access
• Integrity Checks
• Usually defined within the data definition of the
schema/subschema
• Often relies on the data dictionary
• Backup Procedures
• Definition of measures to ensure the safety of the DB
• Ensuring that these procedures are carried out
Functions of a DB Administrator
• Recovery Procedures
• Definition of procedures to be carried out in the event of failure
• Testing of these procedures to make sure they will work if/when
needed
• Monitoring Performance
• Dealing with problems - use of tools e.g. Oracle Enterprise Manager
• Looking at the way that the various users of the DB are being serviced
• Educating users in ways to use the DB more efficiently
• Changing the logical/physical structure of the DB to enhance
performance
Functions of a DB Administrator
• Responding to Changes
• New users
• New user requirements
• Software/hardware enhancements
Use of Tools
• Many modern DB environments are very complex, often using
multiple databases. It therefore becomes essential to make use of
tools to carry out the job of Database administration
• Oracle Enterprise Manager
Alternative Definitions
• Data Administration: A high-level function that is responsible for
the overall management of data resources in an organization,
including maintaining corporate-wide definitions and standards
• Database Administration: A technical function that is
responsible for physical database design and for dealing with
technical issues such as security enforcement, database
performance, and backup and recovery
Data Administration Functions
• Data policies, procedures, standards
• Planning
• Data conflict (ownership) resolution
• Internal marketing of DA concepts
• Managing the data repository
Database Administration
Functions
• Selection of hardware and software
• Installing/upgrading DBMS
• Tuning database performance
• Improving query processing performance
• Managing data security, privacy, and integrity
• Data backup and recovery
Data Warehouse Administration
• New role, coming with the growth in data warehouses
• Similar to DA/DBA roles
• Emphasis on integration and coordination of metadata/data across
many data sources
• Specific roles:
• Support decision –support applications
• Manage data warehouse growth
• Establish service level agreements regarding data warehouses and data marts
Database
architecture
The Three Level Architecture
Database architecture
The architecture of a database determines its capability of meeting
user requirements reliably, effectively and efficiently
The 3 schema approach
Based on assumptions that
• Computers and users need to be able to view the same data in different ways
• Different users need to be able to view the same data in different ways
• It is desirable for users and computers to change the way they view data
independently
• it is undesirable for the computer to dictate or constrain the way that users view
the data
Views of data
Two different kinds of view of data
• user views (external views)
defined by external schemas
• implementation view (internal view)
defined by an internal schema
Schemas contain information about the view, not data in the view
Mappings between schemas
To allow users to access data there must be mappings between
external and internal schemas
Direct mappings
Each external schema could be mapped directly to the internal schema
Access
external
schema
A simple example (continued)
struct Employee {
char EmpNum [6];
int Sal;
};
The external level
(the user level)
• Each external view includes multiple occurrences of multiple types of
external record
• A user will either be an application program(mer) or a terminal (end)
user
• Each user has a language at their disposal
Accessing the external level
• Application programmer
• a conventional programming language (eg ‘C’)
• with special DB language embedded in it
• End user
• a query language or special purpose language tailored to the users
requirements
• very high level language
DB Languages
• DBMS Languages: After the DB design is completed the conceptual
and internal schemas of the DB must be mapped
• In many DBMSs where no strict separation of levels is maintained,
one language (data definition language – DDL) is used by the DBA
and DB designer to define both schemas.
• DBMS has a DDL compiler – it processes DDL statements in order to
identify descriptions of the schema constructs and to store the
schema description in the DBMS catalog
DB Languages
• In DBMSs where conceptual and internal levels are separated, DDL is
used to specify only the conceptual schema
• Storage definition language (SDL) is used to specify only the internal
schema.
• In a true 3-schema architecture, a 3rd language is needed. View
definition language (VDL) it is used to specify user views and their
mapping to the conceptual schema.
• Note: In most DBMSs, the DDL is used to define both conceptual and
external schemas
DB Languages
• To use a populated DB, one need a data manipulation language (DML) to
retrieve, insert, delete, and or modify data
• Current DBMSs uses comprehensive integrated language – Structured
Querying Language (SQL): which includes constructs for
• Conceptual schema definition DDL
• View definition VDL
• Data manipulation DML
• The storge definition is kept separated so the fine-tuning of the
performance will be made easier.
• SQL no longer includes storage definition language (SDL) to include
conceptual and external levels only.
DB Languages
• There are 2 types of DML
• High-level (nonprocedural DML)
• Low-level (procedural DML)
• High-level DMS: can be used on its own to specify complex operations in a
concise manner. SQL is an example
• In most DBMSs, statements are entered interactively from a terminal or by
embedding them in a general-purpose code.
• In a general-purpose code: the DML part is identified within the program so
that it can be extracted by the compiler
• A query in high-level DML means which data to retrieve rather than how to
retrieve it.
DB Languages
• Low-level DML: must be embedded in a general-purpose
programming language.
• This type of DML typically retrieve individual records or objects from
the DB and process each separately.
• The low-level DML needs to use programming language constructs,
such as looping, to retrieve and process each record from a set of
records
• sometimes DML commands, high or low-level are embedded in a host
language and the DML is called the data sublanguage.
Data Sublanguage (DSL)
• A DSL is a subset of the language concerned specifically with DB
objects and operations
• The DSL is said to be embedded in the host language
• The host language is responsible for non-DB facilities
DDL and DML
The DSL contains 2 sublanguages:
• Data definition language (DDL)
For designing and describing DB objects
• Value-Independent view
Security Logs and Audit Trails
• Security log: is a journal that keeps a record of all attempted security violations.
• The violation can be recorded in the log or it can trigger an immediate message to the
system operator or to the DBA.
• Audit trails is necessary to set up if the DBA suspects that data is being compromised
without triggering security log entries.
• Triggers: can also be used to set up an audit trail for a table, recording all changes, the
time they were made, and the identity of the user.
• Example: in Oracle – to monitor changes to say grade in the ENROLL table, we could 1 st
set up a table to hold the audit records.
Security Logs and Audit Trails
• The schema for that table might be:
EnrollAudit (dateandTimeOfUpdate, userId, oldStuId, oldClassNo, oldGrade,
newGrade)
• The trigger should insert a record in the ENROLLAUDIT table when a user tries
to update a grade in the ENROLL table.
Encryption
• Encryption requires a cipher system, which consists of the
following components:
• Encryption algorithm: which takes the normal text (plaintext) as
input, performs some operations on it, and produces the
encrypted text (ciphertext) as output.
• Encryption Key: which is part of the input for the encrypting
algorithm and is chosen from a very large set of possible keys.
• Decrypting Algorithm: which operates on the ciphertext as input
and produces the plaintext as output.
• Decryption key: which is part of the input for the decrypting
algorithm and is chosen from a very large set of possible keys
Encryption
• Symmetric Key Encryption: is a from of encryption where the
decryption key is the same as the encryption key, and the
decrypting algorithm is the inverse of the encrypting algorithm.
• Example: Data Encryption Standard (DES), Advanced Encryption
Standard (AES)
• Public – Key Encryption/Asymmetric Encryption: uses 2 separate
keys, where one is a public key and the other is a private key.
• The public key is shared freely – so that anyone wishing to send a
message to a user can find his or her public key easily
• The key is then used as input to an encryption algorithm, which
produces the ciphertext for that user
Encryption
• When the user receives an encrypted message, he or she must
produce the prime factors of the public key to decode it.
• One well – known method of public – key encryption is RSA,
named for its developers, Rivest, Shamir, and Adleman.
• DES Encryption
• Public-key Encryption
SQL Data Control Language
• The Data Control Language of SQL is its authorization sublanguage, it
includes statements to grant privileges to and revoke privileges from
users.
• Privilege: is an action, such as creating, executing, reading, updating,
or deleting, that a user is permitted to perform on database objects.
• Statement for granting privileges:
GRANT {ALL PRIVILEGES | privilege – list}
ON {object - name}
TO {PUBLIC | user – list | role – list} [WITH GRANT OPTION];
SQL Data Control Language
• Possible privileges for base tables are: SELECT, DELETE, INSERT,
UPDATE, or REFERENCES (col – name).
• GRANT UPDATE ON Student (major) TO U101;
• Note: the UPDATE privilege can be made more restrictive by
specifying a column list in parentheses, (example above)
• The REFERENCES privilege is applied to columns that may be used as
foreign keys.
• This privilege allows the user to refer to those columns in creating
foreign key integrity constraints.
SQL Data Control Language
• GRANT REFERENCES (stuId) ON Student TO U101;
• The user list in the TO clause can include a single, several or all users
(the public).
• The optional WITH GRANT OPTION clause gives the newly
authorized user(s) permission to pass the same privilege to others,
example;
• GRANT SELECT, INSERT, UPDATE ON Student TO U101, U102, U103
WITH GRANT OPTION;
• Users U101, U102, U103 would then be permited to write SQL
SELECT, INSERT, and UPDATE statements for the Student table, and
to pass that permission on to other users.
SQL Data Control Language
• Authorization graph or grant diagram is used to keep track of
authorizations.
SQL Data Control Language
• SQL DCL includes the capability to create user roles.
• Role: set of operations that should be performed by an individual or
a group of individuals as part of a job.
1.Create a role
2.Give a grant privilege to a role
3.Assign a role to a user
• CREATE ROLE AdvisorRole; or CREATE ROLE FacultyRole;
• GRANT SELECT ON Student TO AdvisorRole;
• GRANT AdvisorRole to U999
SQL Data Control Language
• SQL DCL statements to remove privileges has this form:
REVOKE {ALL PRIVILEGES | privilege – list}
ON object – list
FROM {PUBLIC | user – list | role – list};
[CASCADE | RESTRICT];
Statistical DB Security
• Statistical DBs are designed to provide data to support statistical
analysis on populations.
• The data itself may contain facts about individuals, but the data is
not meant to be retrieved on an individual basis.
• Users are granted permission to access statistical information such
as totals, counts, or averages, but not information about individuals
• Example: if a user is permitted statistical access to an employee DB,
he or she is able to write queries such as:
Statistical DB Security
• Special precautions must be taken when users are permitted access
to statistical data, to ensure that they are not able to deduce data
about individuals.
• If there are no restrictions in place except that all queries must
involve COUNT, SUM, or AVERAGE, a user who wishes to find the
employee of E101 can do so by adding conditions to the WHERE line
to narrow the population down to that one individual, as in:
SQL INJECTION
• Is an application security weakness that allows attackers to
control an application’s database – letting them access or delete
data, change an application’s data-driven behavior, and do
other undesirable things – by tricking the application into
sending unexpected SQL commands.
SQL INJECTION
SQL Injection Attack Tutorial
End of Lecture