RDBMS.ppt What is RDBMS RDBMS stands for Relational Database Management System.

138 views 49 slides Dec 10, 2023
Slide 1
Slide 1 of 49
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49

About This Presentation

What is RDBMS RDBMS stands for Relational Database Management System. RDBMS stands for Relational Database Management System.

All modern database management systems like SQL, MS SQL Server, IBM DB2, ORACLE, My-SQL, and Microsoft Access are based on RDBMS.

It is called Relational Database Manageme...


Slide Content

Copyright © 2009, Oracle. All rights reserved.
Introduction

Copyright © 2009, Oracle. All rights reserved.I-2
Requirements of an Application:

Copyright © 2009, Oracle. All rights reserved.I-3
Information is a critical factor for any business to be successful.
Information is extracted from data stored in databases.
Database is an integral part of an organization. Aspiring database
developers should be able to efficiently design and implement
databases.
Knowledge of these will enable the developers to build robust
database solutions.
This module will help students to understand the concepts related
to relational databases.

Copyright © 2009, Oracle. All rights reserved.I-4
What is a
Database?

Copyright © 2009, Oracle. All rights reserved.I-5
A database is a collection of logically related data.
Data means known facts, which are meaningful and can be
recorded.
For example:
Hard Disk
Address
Book

Copyright © 2009, Oracle. All rights reserved.I-6
Database Management is the task of maintaining databases so that
the information is easily available.
Database Management Systems (DBMS) is the software required
to perform the task of maintaining databases.
Management of data involves:
Defining structures for data storage.
Providing methods for data manipulation, such as adding, editing,
and deleting data.
Providing data security against unauthorized access.
Database management systems are now available on a wide range
of computers, from desktops to mainframes. The size and power of
the computer determines the system facilities, such as security and
storage.

Copyright © 2009, Oracle. All rights reserved.I-7
The main objectives of any DBMS are to:
Provide an efficient and easy way to store, update, and retrieve data
from a database.
Manage information about users who interact with the DBMS, and the
tasks that these users can perform on the data.
Today, relational databases are the most popular form of storing
data. Besides storing data and extracting information, a database has
to be managed effectively. The software that is used to manage and
retrieve information in a relational database is called a Relational
Database Management System (RDBMS).
A Relational Database Management System (RDBMS) is an
advanced version of DBMS that also defines the relationship between
various data values.

Copyright © 2009, Oracle. All rights reserved.I-8
Some typical applications of an RDBMS are:
Airline and railway reservations
Banking applications
Manufacturing industry
Order processing
Hospital management systems
Library management systems
Hotel industry

Copyright © 2009, Oracle. All rights reserved.I-9
Several RDBMS products are available today. Some popular products are:
Oracle
Microsoft SQL Server
Sybase
Ingres
DB2

Copyright © 2009, Oracle. All rights reserved.I-10
Now, let us understand the
working of DBMS.

Copyright © 2009, Oracle. All rights reserved.I-11
Database
DBMS
Request for
data
Retrieved data
returned as a result
User system to extract
information from the
database

Copyright © 2009, Oracle. All rights reserved.I-12
Relational data structure:
Each table in a database has a unique table name.
The row (or record) in the table is called a tuple.
The column (or field) is called an attribute.
Every column in a table must have a unique name.
The number of tuples is called the cardinality of the table.
The number of attributes is called the degree of the table.
Rows are unordered in a relation.
A column or combination of columns that uniquely identifies each row in
the table is called the primary key of the table.
A table where every row is different from all other rows is called a relation.
A domain is a collection of values from which one or more attributes
(columns) draw their actual values.

Copyright © 2009, Oracle. All rights reserved.I-13
The following diagram describes the data structure of an RDBMS.
T_CODE NAME AGE SEMESTER
I1001 Nancy Mathews 27 I
I1002 Catherine 38 II
I1003 Mac Thams 50 IV
I1004 Joe Nelson 35 III
Tuple

Copyright © 2009, Oracle. All rights reserved.I-14
T_CODE NAME AGE SEMESTER
I1001 Nancy Mathews 27 I
I1002 Catherine 38 II
I1003 Mac Thams 50 IV
I1004 Joe Nelson 35 III
Attributes
The following diagram describes the data structure of an RDBMS.

Copyright © 2009, Oracle. All rights reserved.I-15
T_CODE NAME AGE SEMESTER
I1001 Nancy Mathews 27 I
I1002 Catherine 38 II
I1003 Mac Thams 50 IV
I1004 Joe Nelson 35 III
Primary Key
Relation
The following diagram describes the data structure of an RDBMS.

Copyright © 2009, Oracle. All rights reserved.I-16
T_CODE NAME AGE SEMESTER
I1001 Nancy Mathews 27 I
I1002 Catherine 38 II
I1003 Mac Thams 50 IV
I1004 Joe Nelson 35 III
DOMAIN
T_CODE
DOMAIN
NAME
DOMAIN
AGE
DOMAIN
SEMESTER
The following diagram describes the data structure of an RDBMS.

Copyright © 2009, Oracle. All rights reserved.I-17
Representing missing information:
In RDBMS, missing or unknown information is represented as a NULL
value in a table.
NULL is not the same as space or zero.
Representing relationships in an RDBMS:
A column in one table whose value matches the primary key in some
other table is called a foreign key.
A primary key and a foreign key create a parent-child relationship
between the tables that connect them.

Copyright © 2009, Oracle. All rights reserved.I-18
The ER (Entity-Relationship) model:
Views the real world as a collection of objects or entities and the relationship
among them.
It also has a corresponding diagramming technique.
STUDENT COURSE
LEARN
Sno Sname CrsID Crsname
Entities
Relationship
Attributes Attributes

Copyright © 2009, Oracle. All rights reserved.I-19
An entity:
Is any object, place, person, or activity about which the data is recorded.
Can be categorized as entity type and entity instance.
In the ER model diagramming technique, entities are named and represented
inside a box.
For example:
TEACHER

Copyright © 2009, Oracle. All rights reserved.I-20
Entity can be of the following types:
Dependent entity:
Depends on another entity for existence.
Is also called as a weak entity.
Independent entity:
Does not depend on any other entity for existence.
Is also called as a regular entity.
Independent
Entity
Dependent
Entity

Copyright © 2009, Oracle. All rights reserved.I-21
Relationship among entities:
A relationship is depicted as a diamond with the name of the
relationship type.
Relationship
For example:

Copyright © 2009, Oracle. All rights reserved.I-22
The following diagram represents the association of an entity with itself.
STUDENT
SEMINAR
An entity associating with
itself can be a student giving
a seminar presentation to
other students.

Copyright © 2009, Oracle. All rights reserved.I-23
The following statement has been extracted from a case presented by a
manufacturer regarding the maintenance of their data: “A supplier ships
certain parts”. Identify the entities mentioned in this statement, and their
relationship. Draw a diagram depicting the relationship.
Solution:
Entities: SUPPLIER, PARTS
Relationship: SHIP or SUPPLIES

Copyright © 2009, Oracle. All rights reserved.I-24
There are three types of relationships:
One-to-one
One-to-many (or Many-to-one)
Many-to-many

Copyright © 2009, Oracle. All rights reserved.I-25
The following diagram represents the one-to-one relationship between
DEPARTMENT and DEPARTMENT HEAD.
For a particular DEPARTMENT there can be only one DEPARTMENT HEAD.

Copyright © 2009, Oracle. All rights reserved.I-26
The following diagram represents the many-to-one relationship between
STUDENT and MAJOR.
A STUDENT can MAJOR in only one course, but many STUDENTs can register for a
given MAJOR course.

Copyright © 2009, Oracle. All rights reserved.I-27
The following diagram represents the many-to-many relationship between
STUDENT and COURSE.
A STUDENT can take many COURSEs and many STUDENTs can register for a given COURSE.

Copyright © 2009, Oracle. All rights reserved.I-28
What do the following ER diagrams represent?
Solution:
Many students can work on many projects.
Many employees belong to only one department.

Copyright © 2009, Oracle. All rights reserved.I-29
Consider the following statement of a manufacturing company:
“A supplier supplies certain parts. A particular part is not necessarily supplied
by only one supplier. No supplier supplies only a single part.” What type of
relationship is this? Draw a diagram to depict the relationship.
Solution:
Many-to-many relationship

Copyright © 2009, Oracle. All rights reserved.I-30
An attribute:
Is a property of a given entity.
Is depicted as ellipses, labeled with the name of the property.
The following diagram shows the various attributes of the entity, STUDENT.

Copyright © 2009, Oracle. All rights reserved.I-31
A manufacturer needs to maintain the following details about the supplier:
Name
Address
Credit status
Assigned code number
Draw a diagram to depict this information.
Solution:

Copyright © 2009, Oracle. All rights reserved.I-32
A subtype:
Is a subset of another entity.
Is always dependent on the supertype for its existence.
The attributes of a supertype apply to all of its subtypes.

Copyright © 2009, Oracle. All rights reserved.I-33
The following diagram shows the relationship between supertype
(PATIENT) and subtypes (INPATIENT and OUTPATIENT).
PATIENT
ID
Name
Addr
OUTPATIENTINPATIENT
VstDateRoomNo BedNo

Copyright © 2009, Oracle. All rights reserved.I-34
Map an ER diagram to a table
The following components play an important part while mapping an
ER diagram to table:
oRegular entities
oAttributes
oRelationships
oWeak entities
oSubtypes and supertypes

Copyright © 2009, Oracle. All rights reserved.I-35
Regular entities:
They can exist alone, independent of any other entity.
They are the “building blocks” of the database.
Each regular entity maps to a table.
For example, STUDENT and BOOKS are two separate entities in the
following ER diagram.
STUDENT BOOKSISSUES

Copyright © 2009, Oracle. All rights reserved.I-36
Attributes:
Each property or attribute shown in the ER diagram maps to an attribute
in the appropriate table.
In the following ER diagram, STUDENT and BOOKS individually has
different attributes.
Entity becomes the table and the
attributes of the entity become
columns of the table.

Copyright © 2009, Oracle. All rights reserved.I-37
Relationships:
There are the following types of relationships:
One-to-One
One-to-Many
Many-to-Many

Copyright © 2009, Oracle. All rights reserved.I-38
One-to-one relationship:
One instance of an entity can relate to only one instance of the related entity.
If frequent queries require data from
the two tables, then it is better to
merge the two tables to improve
query performance.
For example:

Copyright © 2009, Oracle. All rights reserved.I-39
One-to-many relationship:
One instance of an entity can relate to more than one instance of the related entity.
Mapped to the
DEPARTMENT
table
Mapped to the
EMPLOYEE
table
For example:

Copyright © 2009, Oracle. All rights reserved.I-40
Many-to-many relationship:
Many instances of an entity can relate to more than one instance of the related
entity.
The primary keys, ROLL_NO and CODE of
the STUDENT and BOOKS table will act as
the foreign keys in the ISSUE table.
Mapped to the
STUDENT
table
Mapped to
the BOOKS
table
Mapped to
the ISSUES
table
For example:

Copyright © 2009, Oracle. All rights reserved.I-41
For example, a user wants to know which book was issued to a particular
student and on which date. You can use the foreign keys in the ISSUE table to
make a join between all the three tables.
ROLL_NO NAME CODE DESC ISSUE_DATE RETURN_DATE
What is the primary key of the ISSUE table? There are two possibilities. One
possibility is to take a combination of the two foreign keys (ROLL_NO and CODE)
The resulting key is known as Composite Key.
Another possibility is to create a new attribute for the primary key, for example
ISSUENUM.
ISSUENUM ROLL_NO CODE ISSUE_DATE RETURN_DATE

Copyright © 2009, Oracle. All rights reserved.I-42
Weak entity:
It is an entity whose existence depends on some other entity.
The EMPLOYEEADDRESS
entity can be mapped to a
separate table.
ADDRESSID EMPNO CITY
For example:

Copyright © 2009, Oracle. All rights reserved.I-43
Subtypes and Supertypes:
A subtype is a subset of another entity.
A subtype is always dependent on supertype for its existence.
The primary key of the supertype creates a link between the
supertype and subtypes.

Copyright © 2009, Oracle. All rights reserved.I-44
For example:
Each subtype and
supertype maps to a
separate table.
Supertype
Subtypes

Copyright © 2009, Oracle. All rights reserved.I-45
An RDBMS identifies and locates rows by value.
Relational systems require keys that can uniquely identify the rows of a table.
The various types of keys used in an RDBMS are:
oPrimary
oForeign
oCandidate
oAlternate
oComposite
Keys

Copyright © 2009, Oracle. All rights reserved.I-46
Any attribute (or set of attributes) that uniquely identifies a row in a
table is a candidate for the primary key. Such an attribute is called a
candidate key.
One of the candidate keys is chosen to be the primary key, based on
the familiarity and greater usage.
Any attribute that is a candidate for the primary key but is not the
primary key is called the alternate key.
When the key that uniquely identifies the rows of the table is made up
of more than one attribute, it is called a composite key.
Keys (Contd)

Copyright © 2009, Oracle. All rights reserved.I-47
Consider the STUDENT table, as shown in the following diagram.
STUDENT# and REGN# are
both individually unique in every
row.
If STUDENT# is chosen as the
primary key, then REGN# is the
alternate key.
Candidate keys
Primary keyAlternate key

Copyright © 2009, Oracle. All rights reserved.I-48
Keys can be simple or composite. A Simple key is composed of a
singe attribute.
A composite key, on the other hand, comprises two or more attributes.
ACCNUM TRANSDATE TRANSTIME AMOUNT DESCRIPTION
A1101 01/02/200112:30 P.M1000.00Deposit
A1102 01/02/200112:30 P.M2000.00Deposit
A1101 02/02/200110:30 P.M3000.00Deposit
In the preceding table, assume that only one transaction can take
place for a given account number at a time.
We can select ACCNUM, TRANSDATE, and TRANSTIME as the
composite key.

Copyright © 2009, Oracle. All rights reserved.I-49
Consider the table, WORKING HOURS of an employee, as shown in the
following diagram.
EMPLID PROJECTID HOURS
E309 P675 18
E453 P908 5
E334 P876 20
Composite key
Each row can be uniquely identified by a
composite key composed of EMPLID and
PROJECTID.