Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
TVSN Murthy
Assistant Professor – DFT
NIFT Hyderabad
Disclaimer: These slides are just for the purpose of easy reading and are not comprehensive in
nature. Thus the slides have to be read together with the class lectures, reading material, and
statutes dealing with the subject
RDBMS/Slide 1
Introduction
RDBMS/Slide 2
1
Introduction
File-based Systems:
Entities or objects of interest are represented by records that are stored together in
files. Relationships between objects are represented by using directories of various
kinds.
RDBMS/Slide 3
Introduction
RDBMS/Slide 4
2
Introduction
Common characteristics required for data models:
A data model must show some degree of conceptual simplicity without
compromising the semantic completeness.
A data model must represent the real world as closely as possible.
The representation of the real-world transformations (behavior) must be
in compliance with the consistency and integrity characteristics of any
data model.
RDBMS/Slide 5
Introduction
An organization must have accurate and reliable data for effective decision making.
To this end organization maintains records on the various facets of its operations.
These models capture the essential properties of the objects and record relationships
among them. Such related data is called a database.
RDBMS/Slide 6
3
Introduction
RDBMS/Slide 7
INTERNAL VIEW
Internal Level
RDBMS/Slide 8
4
Three Level Architecture
External View
RDBMS/Slide 9
RDBMS/Slide 10
5
Three Level Architecture
Internal View
Internal view is at the lowest level of abstraction, closet to the physical
storage method used.
It indicates how the data will be stored and describes the data structures
and access methods
View is expressed by the internal schema.
Schema contains the definition of stored record, the method of
representing the data fields, and access aids used.
RDBMS/Slide 11
Data Independence
Data Independence
Three levels of abstraction, along with the mappings from internal to
conceptual and from conceptual to external, provide two distinct levels of
data independence:
Logical Data Independence
Physical Data Independence
RDBMS/Slide 12
6
Data Independence
RDBMS/Slide 13
Data Independence
RDBMS/Slide 14
7
Database Users
DBMS Users
The users of the database system can be classified in the following groups
depending on their degree of expertise or mode of their interactions with
the DBMS
Naïve Users
Online Users
Application Programmers
Database Administrator
RDBMS/Slide 15
Database Users
Naïve User
User who need not be aware of the presence of the database system or
any other system supporting their usage are considered naïve users.
User of the ATM falls in this category
RDBMS/Slide 16
8
Database Users
Online Users
These are users who may communicate with the database directly via
online terminal or indirectly via a user interface and application program.
These users are aware of the presence of the database system and may
have acquired a certain amount of expertise in the limited interaction they
are permitted with the database through the intermediary of the
application program.
Online users can also be naïve users requiring additional help, such as
menus.
RDBMS/Slide 17
Database Users
Application Programmers
Professional programmers who are responsible for developing application
program or user interfaces utilized by the naïve and online users fall into
this category.
The application programs could be written in a general purpose
programming language such as C or VB and include the commands
required to manipulate the database.
RDBMS/Slide 18
9
Database Users
Database Administrator
Centralized control of the database is exerted by a person under the
supervision of a high level administrator. This person or group is referred
to as the database administrator (DBA).
The DBA administers the three levels of the database and in consultation
with the overall community sets up the definition of the global view or
conceptual level of the database.
DBA specifies the external view of the various users and applications and
is responsible for the definition and implementation of the internal level
including the storage structure and access methods to be used for the
optimum performance of the DBMS.
RDBMS/Slide 19
Database Users
RDBMS/Slide 20
10
Data Models
Data Models
Can be classified into two categories:
Object-based logical model – focuses on describing the data, the
relationship among the data, and any constraints defined
Record-based logical model – focuses on describing the data structure
and the access techniques in the Database Management System
RDBMS/Slide 21
Data Models
RDBMS/Slide 22
11
Data Models
RDBMS/Slide 23
Entities
Chen defined an entity as “a thing, which can be easily identified”
An entity is any object, place, person, or activity about which data is recorded
In the diagramming technique, entities are named and represented inside a box
An entity type is a set of things that share common properties
STUDENT, COURSE, and GRADE are examples of entity type
An entity type is usually in uppercase
RDBMS/Slide 24
12
Entity Relationship Model
Entities (Contd.)
Types of Entities
Dependent entity
Is an entity whose existence depends on the existence of another
entity and are also called weak entities
Independent entity
Is an entity which does not depend on any other entity for existence
and are also called regular entities
RDBMS/Slide 25
Relationships
Chen defines a relationship as “an association among entities”.
For example, the relationship between students and instructors
represents the fact that an instructor teaches several students and a
student is taught by several instructors. This relationship could be named
TEACH.
Relationships are depicted as a diamond with the name of the relationship
type.
RDBMS/Slide 26
13
Entity Relationship Model
Relationships (Contd.)
A relationship type is an association of entity types (STUDENT-INSTRUCTOR).
A relationship can associate an entity with itself.
Multiple relationships can also exist between the same entities.
RDBMS/Slide 27
Just a Minute…
1. 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.
Entities
Relationship
RDBMS/Slide 28
14
Types of Relationships
Types of Relationships
There are three types of relationships:
One-to-One
One-to-Many (or Many-to-One)
Many-to-Many
RDBMS/Slide 29
Types of Relationships
One-to-One Relationship
Consider the example of a university. For one DEPARTMENT (like the
department of social sciences) there can be only one department head. This is
a one-to-one relationship.
RDBMS/Slide 30
15
Types of Relationships
Many-to-One Relationship
A STUDENT can MAJOR in only one course, but
many STUDENTs would have registered for a given
MAJOR course. This is a many-to-one relationship.
RDBMS/Slide 31
Types of Relationships
Many-to-Many Relationship
An employee might learn many job skills, and each job skill might be learned
by many employees.
m m
EMPLOYEE LEARNS SKILL
RDBMS/Slide 32
16
Types of Relationships
Just a Minute…
1. What do the following E/R diagrams represent?
RDBMS/Slide 33
Types of Relationships
RDBMS/Slide 34
17
Types of Relationships
RDBMS/Slide 35
Disadvantages
Limited constraint representation
Limited relationship representation
No data manipulation language
Loss of information content
RDBMS/Slide 36
18
Data Base Models
Just a Minute… (Contd.)
2. Consider the following statement of a manufacturing company:
“A supplier ships certain parts. A particular part is not necessarily shipped by
only one supplier. No supplier ships only a single part.”
What type of relationship is this? Draw a diagram to depict the relationship.
RDBMS/Slide 37
RDBMS/Slide 38
19
Data Base Models
Just a Minute…
1. A manufacturer needs to maintain the following details about the supplier:
a. Name
b. Address
c. Credit Status
d. Assigned code number
Draw a diagram to show this information.
RDBMS/Slide 39
RDBMS/Slide 40
20
Data Base Models
Record-based Logical Model
RDBMS/Slide 41
Basic Structure
The segments below other segments are the children of the segment
above them.
RDBMS/Slide 42
21
Data Base Models
A Hierarchical Structure
RDBMS/Slide 43
RDBMS/Slide 44
22
Data Base Models
Network Database Model
The popularity of the network data model coincided with the popularity of
the hierarchical data model. Some data were more naturally modeled with
more than one parent per child. The network model permitted the
modeling of many-to-many relationships in data.
Basic Structure
A member record type can have that role in more than one set,
hence the multiparent concept is supported. An owner record type can
also be a member or owner in another set.
RDBMS/Slide 45
RDBMS/Slide 46
23
Data Base Models
Network Database Model
Advantages
Conceptual simplicity
Handles more relationship types
Data access flexibility
Promotes database integrity
Data independence
Conformance to standards
Disadvantages
System complexity
Lack of structural independence
RDBMS/Slide 47
RDBMS/Slide 48
24
Data Base Models
RDBMS
RDBMS can be defined as a database management system where all data
visible to the user is organized strictly as tables of data values and where all
database operations work on these tables
RDBMS/Slide 49
RDBMS/Slide 50
25
Data Base Models
Relational Data Structure (Contd.)
A domain is a pool of values from which one or more attributes (columns)
draw their actual values
RDBMS/Slide 51
RDBMS/Slide 52
26
Data Base Models
Representing Relationships in an RDBMS
At any given time, no two rows of the table contain the same values in a
column or column combination. This column (or columns) is called the
primary key of the table.
A column in one table whose value matches the primary key in some other
table is called a foreign key
Together, a primary key and a foreign key create a parent-child
relationship between the tables that connects them
RDBMS/Slide 53
Disadvantages
Substantial hardware and system software overhead
Possibility of poor design and implementation
Potential “islands of information” problems
RDBMS/Slide 54
27
Data Base Models
Just a Minute… Self Study
Collect the information on Serial and Sequential files
a. How are they created
b. How records are maintained and manipulated
c. Advantages and Disadvantages if any
RDBMS/Slide 55
RDBMS/Slide 56
28
Data Base Models
Relational Operators
The relational model is based on the principle of relational algebra
It is a collection of operators operating on relations.
Each operator takes one or two relations as its input and produces a new
relation as its output.
Relational Operators are of the following types:
RESTRICT: Extracts specified tuples or rows from a given relation, based
on a condition.
PROJECT: Extracts specified attributes or columns from a given relation.
RDBMS/Slide 57
ID NAME NAME
101 Jones Jones
103 Smith Projection Smith
104 James James
107 Evan Evan
110 Drew Drew
112 Smith Smith
Relation P
Projection of P over attribute “Name”
RDBMS/Slide 58
29
Data Base Models
Relational Operators (Contd.)
PRODUCT: Builds a relation from two specified relations. It consists of all
possible combinations of tuples, one from each of the two relations.
UNION: Builds a relation from tuples appearing in either or both of the
specified relations. To be union compatible, the two tables should
have the same types of attributes.
INTERSECT: Builds a relation consisting of tuples that appear in both
relations.
DIFFERENCE: Builds a relation of tuples appearing in the first but not the
second of two specified relations.
Next
RDBMS/Slide 59
ID NAME S
ID NAME Software Packages Cartesian 101 Jones J1
101 Jones J1
Product 101 Jones J2
J2
103 Smith
103 Smith J1
104 James Relation Q
103 Smith J2
106 Byron
104 James J1
107 Evan
104 James J2
Relation P 106 Byron J1
106 Byron J2
107 Evan J1
107 Evan J2
Relation P x Q
Back RDBMS/Slide 60
30
Data Base Models
Relational Operators (Contd.,)
ID NAME
ID NAME ID NAME
101 Jones
101 Jones 103 Smith
Union 103 Smith
103 Smith 104 James
104 James
104 James 106 Byron
106 Byron
107 Evan 110 Drew
107 Evan
110 Drew Relation Q
110 Drew
112 Smith
112 Smith
Relation P
Relation P U Q
Back RDBMS/Slide 61
ID NAME ID NAME
ID NAME
101 Jones 103 Smith
103 Smith
103 Smith 104 James Intersection
104 James
104 James 106 Byron
110 Drew
107 Evan 110 Drew
Relation P Q
110 Drew Relation Q
112 Smith
Relation P
Back RDBMS/Slide 62
31
Data Base Models
Relational Operators (Contd.,)
ID NAME ID NAME
ID NAME
101 Jones 103 Smith
101 Jones
103 Smith 104 James Difference
107 Evan
104 James 106 Byron
112 Smith
107 Evan 110 Drew
Relation P - Q
110 Drew Relation Q
112 Smith
Relation P
Back
RDBMS/Slide 63
RDBMS/Slide 64
32
Data Base Models
Relational Operators (Contd.)
RDBMS/Slide 65
RDBMS/Slide 66
33
Data Base Models
Applications of an RDBMS (Contd.)
Several RDBMS products are available today. Some popular products are:
Sybase
Oracle
Microsoft SQL Server
Ingress
DB2
RDBMS/Slide 67
Summary
In this lesson, you learned that:
Data models can be classified as:
Object-based models
Record-based models
In the entity-relationship diagramming technique:
Entities are represented as rectangles
Relationships are represented as diamonds
Attributes are represented as ellipses
Relationships, whether many-to-many, one-to-many, or one-to-one, are
represented symbolically
RDBMS/Slide 68
34
Summary
(Contd.,)
Weak entities are represented in double-lined boxes
Subtypes are connected to the supertype by an unnamed relationship,
marked with a crossbar on top
In the relational model, data is represented in tables (relations) of rows
(tuples) and columns (attributes)
The number of tuples is called the cardinality of the relation, and the number
of attributes is called the degree of the relation
An attribute (or set of attributes) that is unique in every tuple is called the
primary key
RDBMS/Slide 69
Summary
(Contd.,)
Unknown or missing information is represented by a NULL in a table
The foreign key is a column in one table that matches the primary key of
another table
The relational model is based on the principle of relational algebra
The eight operators that operate on relations are restrict, project, product,
union, intersect, difference, join, and divide
RDBMS/Slide 70
35
Relational Model
Foreign keys are identifiers that enable a dependent relation (on the many
side of a relationship) to refer to its parent relation (on the one side of the
relationship)
Keys can be simple (a single field) or composite (more than one field)
RDBMS/Slide 71
Relational Model
Primary Key
Foreign Key
(implements 1:N relationship
between customer and order)
Combined, these are a composite
primary key (uniquely identifies the
order line)…individually they are
foreign keys (implement M:N
relationship between order and
product)
RDBMS/Slide 72
36
Relational Model
Integrity Rule 1:
ID NAME ID NAME Phone
A null value for an attribute is a value that is either not known at the time or doest not
apply to a given instance of the object. It may also be possible that a particular tuple
does not have a value for an attribute.
RDBMS/Slide 73
Relational Model
If any attribute of primary key were permitted to have null value, the key cannot be
used for identification of tuples. This contradicts the requirements for a primary key.
If null values were permitted then the two tuples <@, Smith> are indistinguishable
even though they may represent two different instances of entity type employee.
Integrity Rule 1 specifies that instances of the entities are distinguishable and thus
no prime attribute value may be null. This rule is also referred to as the Entity Rule.
RDBMS/Slide 74
37
Relational Model
Integrity Rule 2:
Integrity rule 2 is concerned with foreign keys ie., with attributes of a relation having
domains that are those of the primary key of another relation.
A relation (R) may contain references to another relation (S). Relation R and S need
not be distinct. Suppose the reference in R is via a set of attributes that forms a
primary key of the relation S. This set of attributes in R is a foreign key. The
referencing attribute(s) in the relation R can have null value(s); in this case, it is not
referencing any tuple in the relation S. If the value is not null, it must exist as the
primary attribute of a tuple of the relation S.
Integrity Rule 2 specifies that, Given two relations R and S, suppose R refers to the
relation S via a set of attributes that forms the primary key of S and this set of
attributes forms a foreign key in R. Then the value of the foreign key in a tuple in R
must either be equal to the primary key of a tuple of S or be entirely null. This rule is
also referred to as the Referential Integrity Rule.
RDBMS/Slide 75
Relational Model
Relational Calculus:
Relational Calculus is a query system wherein queries are expressed as variables and
formulas on these variables. Such formulas the properties of the required result
without specifying the method of evaluating it.
Formal logic the main subject matter is propositions from which we can build other
propositions. In predicate calculus, propositions may be built not only out of other
propositions but also out of elements that are not themselves propositions.
RDBMS/Slide 76
38