Sie sind auf Seite 1von 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
Satyam Computer Services Ltd.

6-Jan-04

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
Satyam Computer Services Ltd.

6-Jan-04

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
Satyam Computer Services Ltd.

6-Jan-04

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) Relations stored as unordered files. Index on first column of Students. Course_info(cid:string,enrollment:integer)
Satyam Computer Services Ltd.

Physical Schema
 

External Schema (View):




6-Jan-04

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
Satyam Computer Services Ltd.

6-Jan-04

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# S1 S2 S3 SNAME Smith Jones Blake STATUS 20 10 30 CITY London Paris Paris

P# P1 P2 P3 P4

PNAME Nut Bolt Screw Screw

COLOR Red Green Blue Red

WEIGHT 12 17 17 14

CITY London Paris Rome London

S# S1 S1 S1 S2 S2 6-Jan-04 S3

P# P1 P2 P3 P1 P2 P2

QTY 300 200 400 300 400 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 S1

Jones 20

10 London

Paris 300

300 S1

S3 S2 Smith

Blake Jones 20

30 10 Londo n

Paris Paris 200

200 400

Smith

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
Satyam Computer Services Ltd.

6-Jan-04

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.
Satyam Computer Services Ltd.

6-Jan-04

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.
Satyam Computer Services Ltd.

6-Jan-04

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
#
S1

PQ
P# 1 2 3 4 1 2 2 QTY 300 200 400 200 300 400 200

S2

S3

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# S1 S1 S1 S1 S1 S1 S2 S2 S3 S4 S4 S4 STATUS 20 20 20 20 20 20 10 10 10 20 20 20 CITY London London London London London London Paris Paris Paris London London London P# P1 P2 P3 P4 P5 P6 P1 P2 P2 P2 P4 P5 QTY 300 200 400 200 100 100 300 400 200 200 300 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 Smith Smith Jones Jones

Subject Maths Physics Maths Physics

Teacher Prof. White Prof. Green Prof. White 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.
Satyam Computer Services Ltd.

6-Jan-04

Student Smith Smith Jones Jones

Subject at s Physics aths Physics

Positio 1 2 2 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

icroso t Word ocument

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  <  >  <=  >=  <>  BET EEN 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.

Das könnte Ihnen auch gefallen