Sunteți pe pagina 1din 12

BSIT 32 RDBMS VII

KUVEMPU UNIVERSITY

INFORMATION TECHNOLOGY PROGRAMMES


Bachelor of Science in Information Technology - B.Sc. (IT)
Master of Science in Information Technology - M.Sc. (IT)

B.Sc.(IT) - 3 Semester
rd

BSIT - 31 PDP - II
BSIT - 32 RDBMS

Directorate of Distrance Education In Universal Education Trust


Kuvempu University collaboration Bangalore

Shankaraghatta, Shimoga District, Karnataka with


VI BSIT 32 RDBMS

Titles in this Volume :


BSIT - 32 RDBMS
BSIT - 32 RDBMS

Prepared by UNIVERSAL EDUCATION TRUST (UET)


Bangalore

First Edition : May 2005

Copyright © by UNIVERSAL EDUCATION TRUST, Bangalore


All rights reserved

No Part of this Book may be reproduced


in any form or by any means without the written
permission from Universal Education Trust, Bangalore.

All Product names and company names mentioned


herein are the property of their respective owners.

NOT FOR SALE


For personal use of Kuvempu University
IT - Programme Students only.

Corrections & Suggestions

for Improvement of Study material

are invited by Universal Education Trust, Bangalore.

E-mail : info@uetb.org

Mayur Print Ads


Printed at :

Bangalore - 20

Ph : 94480 - 42724
BSIT 32 RDBMS VII

RDBMS
(B S IT - 32)

: Contributing Author :

Phaneendra H. D.
Assistant Professor
Department of CS & E
The National Institute of Engineering
Mysore.
BSIT 32 RDBMS V

Course Introduction

D
atabase and database systems have become an essential component of everyday life in modern
society. This book introduces the fundamental concepts necessary for designing, implementing
and using database systems. Our presentation stresses the fundamentals of relational model,
languages, and facilities provided by the database management systems. This course requires the basic
knowledge of database management systems. We also assume that the readers of this book are familiar
with elementary programming and data- structuring concepts, and exposure to computer organization.
This book has been organized into eight chapters
Chapter 1 provides the background material to the subject RDBMS. This chapter covers the basics
of relational model. This model has been implemented in a large number of commercial systems over the
last twenty-five years. The model uses the concept of a mathematical relation, which looks somewhat like
a table of values as its basic building block. We discuss the basic characteristics of the model, its properties,
and relational algebra, which is a set of operations for the relational model.
Chapter 2 introduces the concept of SQL, the language that we use to extract data from a relational
database. SQL is extremely powerful. SQL has become the standard language for most of the commercial
database systems products, which uses RDBMS. SQL is concerned with three most common tasks
needed by any user of a database management system, namely, data definition, data manipulation, and
data control. We discuss here the commands available to carry out these tasks.
Chapter 3 explains the concept behind normalization. Normalization is a successive reduction of a
given set of relations to a better form. A normal form specifies the actions needed to remove the
drawbacks in the design of the database, leading to creation of a very good database. Here we discuss
various normal forms with the help of examples.
VI BSIT 32 RDBMS

Chapter 4 deals with Oracle architecture. Oracle, currently one of the more widely used RDBMSs
for all most all commercial applications. Here we describe the organization of the Oracle system. Oracle
stores data in the form of tables. The structure of an Oracle database consists of the definition of the
database in terms of schema objects and one or more tablespaces.
Chapter 5 covers procedural language called PL/SQL. PL/SQL is Oracle’s procedural language
extension to SQL. We discuss syntax of PL/SQL, its datatypes and declarations, operators, iterative and
conditional control, functions and procedures, triggers and cursors.
Chapter 6 introduces the concept of remote database system. We introduce, remote procedure call,
the technique used to access the remote database. We briefly narrate ODBC, standards developed for
interfacing clients and servers, and JDBC, and JDBC API, which connects JAVA applications to database
system.
Chapter 7 deals with the Internet databases. The World Wide Web (WWW, or Web) is a distributed
information system based on hypertext. The Web makes it possible to access a file anywhere on the
Internet. We discuss the concept of URL, HTML, XML and search engines.
Chapter 8 provides emerging database technologies. Here we discuss the emerging database
technologies, which have become increasingly important in the recent years. SQL3 data model, mobile
databases, multimedia databases, main memory databases, geographic information systems, temporal and
sequence databases, information visualization, genome data management and digital libraries are among
the new technology trends.
BSIT 32 RDBMS VII

Contents

Chapter 1
RELATIONAL MODEL AND RELATIONAL ALGEBRA
1.0 Objectives 1
1.1 Introduction ............................................................................ 1
1.2 Structure of Relational Databases............................................... 2
1.2.1 Basic Structure of relational data model ........................ 2
1.2.2 Properties of a relation ................................................ 3
1.2.3 Keys of a relation ....................................................... 4
1.2.4 Relational Schema ....................................................... 5
1.3 Relational database as an example ............................................. 6
1.4 Relational algebra .................................................................... 8
1.5 Fundamental operations ............................................................ 8
1.5.1 The select operation .................................................... 9
1.5.2 The project operation .................................................. 10
1.5.3 Composition of relational operators ............................... 10
1.5.4 The union operation ..................................................... 11
1.5.5 The set difference operation ........................................ 12
1.5.6 The Cartesian product operation ................................... 13
1.5.7 The rename operation .................................................. 16
1.6 Additional operations................................................................ 17
1.6.1 The set intersection operation ....................................... 17
1.6.2 The natural join............................................................ 17
1.6.3 The division operation .................................................. 18
VIII BSIT 32 RDBMS

1.6.4 The assignment operation ............................................ 19


1.7 Summary ................................................................................ 19
Check your progress ............................................................... 20

Chapter 2
STRUCTURED QUERY LANGUAGE
2.0 Objectives .............................................................................. 22
2.1 Introduction ............................................................................ 22
2.2 SQL structure ......................................................................... 23
2.3 Data Definition Language ......................................................... 24
2.3.1 The domain of SQL .................................................... 24
2.3.2 Create command ........................................................ 25
2.3.3 The drop command ..................................................... 26
2.3.4 The alter command ..................................................... 27
2.4 Data manipulation language ...................................................... 27
2.4.1 Simple select statement................................................ 27
2.4.2 The where clause ........................................................ 29
2.4.3 The from clause .......................................................... 29
2.4.4 The rename operation with select statement .................. 30
2.4.4.1 Tuple variables ............................................................ 30
2.4.5 String operations ......................................................... 31
2.4.6 Sorting of tuples for display ......................................... 32
2.4.7 The set operations ...................................................... 32
2.4.7.1 The union operation ..................................................... 33
2.4.7.2 The intersect operation ................................................ 34
2.4.7.3 The except operation ................................................... 34
2.4.8 Aggregate functions in SQL ......................................... 34
2.4.9 Group by operations in SQL ......................................... 35
2.4.10 Null values ................................................................. 36
2.5 Nested subqueries ................................................................... 37
2.5.1 Set membership .......................................................... 37
2.5.2 Set comparison ........................................................... 38
2.6 Modifications to the database .................................................... 39
2.6.1 Deletion ..................................................................... 39
2.6.2 Insertion .................................................................... 39
2.6.3 Updates ..................................................................... 40
BSIT 32 RDBMS IX

2.7 Joined relations ........................................................................ 41


2.7.1 Inner join ................................................................... 41
2.7.2 Natural join ................................................................ 42
2.7.3 Left outer join ............................................................. 43
2.7.4 Join types and conditions .............................................. 43
2.7.5 Full outer join .............................................................. 45
2.8 Embedded SQL ........................................................................ 45
2.9 Summary ................................................................................. 46
Check your progress ................................................................. 47

Chapter 3
NORMALIZATION
3.0 Objectives .............................................................................. 50
3.1 Introduction ............................................................................ 50
3.2 Database design process .......................................................... 52
3.3 Normalization .......................................................................... 52
3.4 Description of normalization ...................................................... 52
3.5 Role of keys ............................................................................ 53
3.5.1 The role of keys in maintaining relationship .................... 53
3.5.2 The important keys are ................................................ 53
3.6 Unnormalized relations ............................................................. 54
3.7 Normal forms .......................................................................... 55
3.7.1 First normal form ........................................................ 55
3.7.2 Second normal form .................................................... 56
3.7.3 Third normal form ....................................................... 58
3.7.4 Other Normalization forms ........................................... 59
3.8 Summary ................................................................................ 63
Check your progress ................................................................ 64

Chapter 4
ORACLE ARCHITECTURE
4.0 Objectives ............................................................................... 66
4.1 Introduction ............................................................................ 66
4.1.1 An Overview of Databases and Instances...................... 67
4.2 Internal database structures ...................................................... 68
4.3 Internal memory structures ....................................................... 71
X BSIT 32 RDBMS

4.3.1 Global areas ............................................................... 71


4.3.2 Background process .................................................... 72
4.4 External structures .................................................................. 75
4.5 Architecture overview .............................................................. 77
4.6 Summary ................................................................................ 78
Check your progress ................................................................ 78

Chapter 5
PL/SQL
5.0 Objectives .............................................................................. 81
5.1 Introduction ............................................................................ 81
5.1.1 Performance .............................................................. 82
5.1.2 Portability .................................................................. 82
5.1.3 What PL/SQL can do for programmers? ....................... 82
5.2 The PL/SQL syntax ................................................................. 83
5.2.1 The block PL/SQL structure ........................................ 83
5.2.2 The character set ....................................................... 84
5.2.3 Variables ................................................................... 84
5.2.4 Literals ...................................................................... 85
5.2.5 Comments ................................................................. . 85
5.3 PL/SQL data types and declarations .......................................... 86
5.3.1 Declaring variables ..................................................... 87
5.3.2 Assigning a value to a variable ..................................... 87
5.3.3 Declaring a constant .................................................... 88
5.3.4 Picking up a variable’s parameters from a table cell ....... 88
5.3.5 An identifier in PL/SQL block....................................... 89
5.4 PL/SQL operators ................................................................... 89
5.4.1 Arithmetic operators .................................................... 89
5.4.2 Comparison operators .................................................. 90
5.4.3 Logical operators ........................................................ 91
5.4.4 String operators .......................................................... 92
5.5 Conditional control in PL/SQL ................................................... 92
5.6 Iterative control in PL/SQL ....................................................... 93
5.6.1 Loop statement ........................................................... 93
5.6.2 While loop .................................................................. 94
5.6.3 The GOTO statement .................................................. 95
5.6.4 For Loop .................................................................... 95
BSIT 32 RDBMS XI

5.7 Error handling in PL/SQL ......................................................... 99


5.7.1 User defined exceptions ............................................... 100
5.7.2 Predetermined internal PL/SQL exceptions .................... 101
5.8 PL/SQL functions and procedures ............................................. 104
5.8.1 Functions ................................................................... 104
5.8.2 Procedures ................................................................. 105
5.9 Database triggers ..................................................................... 106
5.10 Cursors ................................................................................... 107
5.10.1 Explicit cursor management .......................................... 108
5.10.2 Explicit cursor attributes .............................................. 111
5.11 Summary ................................................................................ 112
Check your progress ................................................................ 112

Chapter 6
REMOTE DATABASE SYSTEM
6.0 Objectives ............................................................................... 115
6.1 Introduction ............................................................................. 115
6.2 Remote procedure calls ............................................................. 116
6.3 Transparency issues ................................................................. 118
6.4 Introduction to ODBC .............................................................. 120
6.4.1 ODBC architecture ..................................................... 121
6.5 JAVA database introduction ...................................................... 123
6.5.1 Database design for client/server systems ...................... 123
6.5.2 Two tier database design .............................................. 124
6.5.3 Three tier database design ............................................ 125
6.5.4 JDBC API ................................................................. 126
6.5.5 How JDBC works ....................................................... 126
6.5.6 JDBC API components ............................................... 127
6.5.7 JDBC drivers .............................................................. 128
6.6 Summary ................................................................................ 129
Check your progress ................................................................. 130
XII BSIT 32 RDBMS

Chapter 7

INTERNET DATABASES
7.0 Objectives ............................................................................... 131
7.1 Introduction ............................................................................. 131
7.2 The World Wide Web................................................................. 132
7.3 Introduction to HTML................................................................ 133
7.4 Databases and the World Wide Web............................................ 135
7.5 Architecture............................................................................. 135
7.6 Application Servers and Server-side Java.................................... 136
7.7 Beyond HTML is it XML ? ........................................................ 139
7.8 XML-QL: Querying XML data ................................................... 140
7.9 Search engines ......................................................................... 140
7.9.1 Search tools and Methods ............................................. 141
7.10 Summary ................................................................................. 145
Check your progress ................................................................. 145

Chapter 8
EMERGING DATABASE TECHNOLOGIES
8.0 Objectives ............................................................................... 148
8.1 Introduction.............................................................................. 148
8.2 SQL3 Object Model .................................................................. 150
8.3 Mobile databases ..................................................................... 151
8.3.1 Mobile Computing Architecture ..................................... 152
8.3.2 Types of data used in Mobile Computing Applications ...... 152
8.4 Main memory databases ............................................................ 153
8.5 Multimedia Databases ............................................................... 154
8.5.1 Multimedia database applications .................................. 155
8.6 Geographic Information systems ................................................ 156
8.7 Temporal and sequence databases .............................................. 157
8.8 Information Visualization ........................................................... 157
8.9 Genome data management ......................................................... 158
8.9.1 Biological sciences and Genetics ................................... 158
8.9.2 The Genome Database ................................................ 159
8.10 Digital Libraries ........................................................................ 159
8.11 Summary ................................................................................. 160
Check your progress ................................................................ 160

S-ar putea să vă placă și