Sei sulla pagina 1di 40

Relational Database Management System

Relational Database Management System

DATA

DATABASE

DBMS/RDBMS

Information

File Processing System

Application
Programs
(Programs
Written in C
Pascal etc.)

File System
(Data
Structure
File Handling)

Database
(Information in
Files Format)

Disadvantages of FPS
Data Redundancy and Inconsistency
Difficulty in accessing data
Data isolation
Integrity Problems
Atomicity Problems
Concurrent-access anomalies
Security Problems

Data Redundancy and Inconsistency

Name
ABC
DEF

Address
Bhiwani
Delhi

Customer Information

AccNo Name
1002
ABC
1005
DEF

Address
Bhiwani
Jaipur

Saving Account

Difficulty in accessing data

Manager

Requirement

Application
Programs
(Programs
Written in C
Pascal etc.)

File System
(Data Structure
File Handling)

Database
(Information Storage
in Files Format)

Requirements of a DBMS
A mechanism for specification of data and its dependencies

(Integrity Constraints) in an integrated fashion.


Prevention of redundancy and inconsistency.
Provision of adequate security and access-rights.
Mechanism for concurrency control.
Mechanism for recovery from failure. Additionally any DBMS must provide

Schemes for specification of procession rules or application Programs.


Efficient techniques for storage and retrieval of data from the secondary

A DBMS has two major components, namely


Structure of Database is called Database Schema.
Instance, which is a state of the database with the actual data loaded.

A set of software tools/programs which access, update and


process the database, called the query and update-mechanism.

D
B
M
S

File
Manager

Secondary
Storage

Data Independence
The ability to modify a schema definition in one level without affecting a
schema definition in the next higher level is called data independence.

Physical data independence

Logical data independence

Create table emp


(empno number(10),------,-------);

Data Models
A Data Model is a mechanism for describing the data, their interrelationships
and the constraints.

Object-based Conceptual models.


Entity-Relationship model

Record-based models.
Relational Model
Network Model
Hierarchical Model

Physical data models.

The E-R Model


Entities : An entity is a distinct clearly identifiable object of the database e.g Book Attribute :
Each Entity is characterized by a set of attributes e.g. Acc.No. Entity Set : Set of all entities
having attributes of the same type. Relationships : A relationship is a mapping between entity
sets.

Acc_No

Book

Title

Acc_No

Borrowed_By

____

Name

Card_No

USERS

Hierarchical Model
This is special kind of a network model where the relationship is
essentially a tree-like structure.

Hospital
Wards
Patient

Doctors

Units
Nurses

Cardiology

Skin

Physical Data Models


Physical data models are used to describe data at the lowest level. In contrast to logical
data models, there are few physical data models In use. Two of the widely known
ones are the Unifying model and frame-Memory model.

Database Languages
Database Languages
Data-Definition

Data-Manipulation

Data-Control

Create Table Test


(
Title
Varchar2(20),
-------- ,-------);

Update
Insert
Delete
Query

GRANT Connect,
Resource TO x
User

Database Administrator
Roles of DBA
Schema Definition
Storage structure and access-method definition

Schema and Physical-organization modification


Granting of authorization for data access
Integrity-constraint specification

Terms
Simple and Composite Attributes
Single-valued and Multivalued Attributes
Null Attributes
Derived Attributes
Existence Dependencies

Weak Entity Set and Strong Entity Set

Weak Entity Set

Keys

Keys
Candidate Key

Primary Key

Alternate Key

Composite Key

Secondary Key

Foreign Key

Mapping Cardinalities
Mapping cardinalities, or cardinality ratios, express the number of entities to which
another entity can be associated via a relationship set. For a binary relationship set R
between entity sets A and B, the mapping Cardinality must be one of the following

One to One

One to Many

Many to One

Many to Many

More on E-R Diagrams

Company
Owns

Multiple Relationships between


Same entity set

Leased

Vehicle

Staff

Manager

Subordinate
Circular Relationship

Reports to

Specialization & Generalization

The Relational Algebra


The relational algebra is a procedural query language.

Fundamental Operations
select (unary)
project (unary)
rename (unary)
Fundamental Operations
cartesian product (binary)
union (binary)
set-difference (binary)

Several other operations, dened in terms of the fundamental operations:


set-intersection
natural join
division
assignment
Operations produce a new relation as a result.

Formal Definition of Relational Algebra

The Select Operation

The Project Operation

The Cartesian Product Operation

The Union Operation

The Set Difference Operation

Relational Calculus
Relational Calculus is a nonprocedural Query language

Tuple Relational Calculus


Uses Tuple variables which take values of an entire tuple

Domain Relational Calculus


Uses Domain variables which takes values from an attribute

Tuple Relational Calculus

Normalization
Normalization is a process of removing redundancy using functional Dependencies.

To reduce redundancy it is necessary to decompose a relation into a number of smaller relations.


There are several normal Forms.
-First Normal Form (1 NF)
-Second Normal Form (2 NF)
-Third Normal Form(3 NF)
-Boyce-Codd Normal Form (BCNF)

First Normal Form (1NF)


This normal form says that all attributes are simple.
An attribute is said to be simple if it does not contain any subparts.
An attributes which contains subparts is called complex attributes.

Name
F_name

C_addr
L_name

City

State

Zip

Second Normal Form (2NF)


A relation is said to be in 2NF if it is in 1NF and
All non-prime attributes are fully functionally dependent on candidate key
Consider a relation savings_deposit having the fol owing structure:Saving_deposit (name, addr, acc_no, amt )
With the fol owing FDs :
name
Add
name, acc_no
addr
Here [name, acc_no ] is the candidate key and addr and amt are the non
prime attributes.
Among the non-prime attributes amt depends on [name, acc_no ] whereas
addr depends
on name only.
Note that due to FD name
Address causing redundancy.
addr every tuple with the same name will contain the same
This redundancy arises because a non-prime attribute like address is
dependent on an attribute

Third Normal Form (3NF)


A relation is said to be in 3NF and non-prime attributes are not dependent
On each other.
Consider the relation
s_by ( s_name, item, price, gift_item )
With FDs

s_name, item
price
Price
gift_item
Here al prime attributes are ful y functional dependent on candidate
keys, the
Non-prime attribute gift-item is also ful y functional dependent on the
non-prime
Attribute price. This create redundancy because every price value
there is a fixed
Gift item.
We shal have to impose the additional restriction that no non-prime
attribute can
Be functional y dependent on another non-prime attributes.

Boyce-Codd Normal Form (BCNF)

Potrebbero piacerti anche