You are on page 1of 49

RDBMS Concepts

6-Jan-04 Satyam Computer Services Ltd.


Agenda
 Introduction
 Database Management Systems
 Normalization
 Codd’s Rules
 SQL

6-Jan-04 Satyam Computer Services Ltd.


Introduction

6-Jan-04 Satyam Computer Services Ltd.


 Data?

 Information?

6-Jan-04 Satyam Computer Services Ltd.


Initial Data Storage Methods
 Data is represented in one or more flat
files
 Flat file is nothing but electronic
representation of cardboard file.
 Every business group has its own set of
files

6-Jan-04 Satyam Computer Services Ltd.


Disadvantages of Flat File Systems
 No centralized control.
 Data Redundancy
 Data Inconsistency
 Data can not be shared
 Standards can not be enforced
 Security issues
 Integrity can not be maintained
 Data dependence

6-Jan-04 Satyam Computer Services Ltd.


Database Management
Systems

6-Jan-04 Satyam Computer Services Ltd.


Database Management Systems

 A system whose overall purpose is to


record and maintain information

 A database is a repository for stored


data and programs to manipulate it.

6-Jan-04 Satyam Computer Services Ltd.


Advantages of DBMS
 Centralized control.
 No Data Redundancy
 Data Consistency
 Data can be shared
 Standards can be enforced
 Security can be enforced
 Integrity can be maintained
 Data independence

6-Jan-04 Satyam Computer Services Ltd.


Data Models
 A data model is a collection of concepts
for describing data
 A Schema is a description of a particular
collection of data using the given data
model
 The relational model is the most widely
used model today

6-Jan-04 Satyam Computer Services Ltd.


Levels of Abstraction
Many Views and single
Conceptual and Physical
Schema
•Views Describe how users see
the data
•Conceptual Schema defines
the logical structure
•Physical Schema defines the
physical files and Indexes

6-Jan-04 Satyam Computer Services Ltd.


Example University Database
 Conceptual Schema
 Students(sid: string, name: string, login: string,
age: integer, gpa:real)
 Courses(cid: string, cname:string, credits:integer)
 Physical Schema
 Relations stored as unordered files.
 Index on first column of Students.
 External Schema (View):
 Course_info(cid:string,enrollment:integer)

6-Jan-04 Satyam Computer Services Ltd.


Data Independence
 Applications insulated from how data is
structured and stored
 Logical Data Independence: Protection
from changes in logical structure of
data
 Physical Data Independence: Protection
from changes in physical structure of
data

6-Jan-04 Satyam Computer Services Ltd.


Structure of a DBMS

6-Jan-04 Satyam Computer Services Ltd.


ACID Test
 Atomicity
 Consistency
 Isolation
 Durability

6-Jan-04 Satyam Computer Services Ltd.


Types of DBMS

 Hierarchical

 Network

 Relational

6-Jan-04 Satyam Computer Services Ltd.


Example Data
S# SNAME STATUS CITY
S1 Smith 20 London
S2 Jones 10 Paris
S3 Blake 30 Paris

P# PNAME COLOR WEIGHT CITY


P1 Nut Red 12 London
P2 Bolt Green 17 Paris
P3 Screw Blue 17 Rome
P4 Screw Red 14 London

S# P# QTY
S1 P1 300
S1 P2 200
S1 P3 400
S2 P1 300
S2 P2 400
6-Jan-04 S3 P2 200 Satyam Computer Services Ltd.
Hierarchical DBMS
Data is represented by a tree structure
P1 Nut Red 12 London P2 Bolt Green 17 Paris

S2 Jones 10 Paris 300 S3 Blake 30 Paris 200


S1 Smith 20 London 300 S2 Jones 10 Paris 400
S1 Smith 20 London 200

P3 Screw Blue 17 Rome P4 Screw Red 14 London

S1 Smith 20 London 400

6-Jan-04 Satyam Computer Services Ltd.


Hierarchical DBMS (Contd.)
 Can not handle Many-Many relations

 Can not reflect all real life situations

 Anomalies in insert, delete and update


operations.

6-Jan-04 Satyam Computer Services Ltd.


Network DBMS
 Data is represented by records and
pointers
 Addresses Many-Many relations
 Insert,delete,update operations possible
 Complex in design

6-Jan-04 Satyam Computer Services Ltd.


Relational DBMS
 Based on Relational Mathematics
principles
 Data is represented in terms of rows
and columns of a table
 Addresses all types of relations
 Easy to design
 No anomalies for insert/delete/update

6-Jan-04 Satyam Computer Services Ltd.


Relational Terminology
Tuple (Row)
Attribute (Column)
Relation (Table)

Integrity Constraints
Primary Key
Alternate Key
Foreign Key

6-Jan-04 Satyam Computer Services Ltd.


Normalization

6-Jan-04 Satyam Computer Services Ltd.


Normalization
 Normalization - process of removing
data redundancy by decomposing
relations in a Database.

 De normalization - carefully introduced


redundancy to improve query
performance.

6-Jan-04 Satyam Computer Services Ltd.


Normalization through
decomposition
 The decomposition approach starts with
one relation and the relation is
decomposed into more number of
relations to remove insert, delete and
update anomalies.

 1NF, 2NF, 3NF and BCNF can be


achieved by this approach.

6-Jan-04 Satyam Computer Services Ltd.


Un normalized Form
A relation is said to be in Un normalized
Form (0NF) if the values of any of its
attributes are non-atomic. In other
words more than one value is
associated with each instance of the
attribute.

6-Jan-04 Satyam Computer Services Ltd.


Un normalized Relation
S# PQ
P# QTY

S1 P1 300
P2 200
P3 400
P4 200

S2 P1 300
P2 400

S3 P2 200

6-Jan-04 Satyam Computer Services Ltd.


First Normal Form
A Relation is said to be in First Normal
Form (1 NF) if the values of each
attribute of the relation are atomic. In
other words, only one value is
associated with each attribute and the
value is not a set or a list of values.

6-Jan-04 Satyam Computer Services Ltd.


First Normal Form
S# STATUS CITY P# QTY

S1 20 London P1 300
S1 20 London P2 200
S1 20 London P3 400
S1 20 London P4 200
S1 20 London P5 100
S1 20 London P6 100
S2 10 Paris P1 300
S2 10 Paris P2 400
S3 10 Paris P2 200
S4 20 London P2 200
S4 20 London P4 300
S4 20 London P5 400

6-Jan-04 Satyam Computer Services Ltd.


Functional Dependency
Given a relation R, attribute Y of R is
functionally dependent on attribute X if
and only if each X-value in R has
associated with it precisely one Y-value
in R (at any one time)

6-Jan-04 Satyam Computer Services Ltd.


Full Functional Dependency
Attribute Y is fully functionally dependent
on attribute X if it is functionally
dependent on X And Functionally
dependent on any proper subset of X

6-Jan-04 Satyam Computer Services Ltd.


Second Normal Form
A relation R is in Second Normal Form (2
NF) if it is in the 1NF and every non key
attribute is full functionally dependent
on the primary key.

6-Jan-04 Satyam Computer Services Ltd.


Third Normal Form
A relation R is in Third Normal Form (3
NF) if and only if it is in the 2NF and
every non-key attribute is
non-transitively dependent on the
primary key.

6-Jan-04 Satyam Computer Services Ltd.


Boyce Codd Normal Form
A relation R is in Boyce/Codd Normal
Form (BCNF) if and only if every
determinant is a candidate key.

An attribute, possibly composite, on


which some other attribute is fully
functionally dependent is a
determinant.

6-Jan-04 Satyam Computer Services Ltd.


Student Subject Teacher
Smith Maths Prof. White
Smith Physics Prof. Green
Jones Maths Prof. White
Jones Physics Prof. Brown

 A subject can be taught to a student by


only one teacher.
 Each teacher teaches only one subject.
 Each subject is taught by several
teachers.
6-Jan-04 Satyam Computer Services Ltd.
Student Subject Position
Smith Maths 1
Smith Physics 2
Jones Maths 2
Jones Physics 1

 No two students can get same position


in same subject.

6-Jan-04 Satyam Computer Services Ltd.


Codd’s Rules

6-Jan-04 Satyam Computer Services Ltd.


Codd’s Rules

Microsoft Word
Document

6-Jan-04 Satyam Computer Services Ltd.


Structured Query Language

6-Jan-04 Satyam Computer Services Ltd.


Structured Query Language
 DDL – Data Definition Language
 DML – Data Manipulation language
 DCL – Data Control Language

6-Jan-04 Satyam Computer Services Ltd.


DDL
 Create
 Alter
 Drop
 Truncate

6-Jan-04 Satyam Computer Services Ltd.


DML
 Insert
 Update
 Delete
 Select

6-Jan-04 Satyam Computer Services Ltd.


DCL
 Commit
 Rollback
 Save point
 Set transaction

6-Jan-04 Satyam Computer Services Ltd.


Integrity Constraints
 Primary key (PK)
 Foreign Key (FK)
 Unique key (UK)
 Not Null
 Check

6-Jan-04 Satyam Computer Services Ltd.


Data Types
 Character
 Varchar2
 Number
 Date
 BLOB
 BFILE

6-Jan-04 Satyam Computer Services Ltd.


Arithmetic Operator
 +
 -
 *
 /
 Mod
 ABS

6-Jan-04 Satyam Computer Services Ltd.


Logical Operators
 AND
 OR
 IN
 NOT IN
 <
 >
 <=
 >=
 <>
 BETWEEN

6-Jan-04 Satyam Computer Services Ltd.


Set Operators
 UNION
 UNION ALL
 INTERSECTION
 MINUS

6-Jan-04 Satyam Computer Services Ltd.


Thank You

6-Jan-04 Satyam Computer Services Ltd.

You might also like