Dbms Module 1
Dbms Module 1
INTRODUCTION TO DATABASES
1
INTRODUCTION
⚫Definition
⚫DBMS- Definition and
Functionalities
⚫Properties of database
⚫A Simplified Database System
Environment
⚫Example of University Database
2
Basic Definitions
⚫ Data: Known facts that can be recorded and have an implicit
meaning.
5
Typical DBMS Functionality
Other functions of DBMS
6
A Simplified Database System
Environment
7
Example of a Database
(with a Conceptual Data Model)
8
Example of a Database System
9
Main Characteristics of the
Database Approach
⚫ Self-describing nature of a database system:
◦ A DBMS catalog stores the description of the database.
The description is called meta-data. This allows the
DBMS software to work with different databases.
⚫ Insulation between programs and data:
◦ Program – data independence
●Allows changing data storage structures and operations
without having to change the DBMS access programs.
◦ Program – operation independence
●User application programs can operate on the data by
invoking operations through their names and
parameters regardless how operations are
implemented.
10
Main Characteristics of the
Database Approach
⚫ Data Abstraction:
◦ The characteristics that allows program – data
independence and program – operation
independence is called data abstraction.
◦ A data model is used to hide storage details
and present the users with a conceptual view
of the database.
12
Database Users
Users may be divided into those
who actually use and control the
content (called “Actors on the
Scene”) and
those who enable the
database to be developed and
the DBMS software to be
designed and implemented
(called “Workers Behind the
Scene”).
13
Database Users
Actors on the scene
◦ End-users: they use the data for queries, reports and some
of them actually update the database content.
17
Advantages of Using the Database
Approach
⚫ Controlling redundancy in data storage and in
development and maintenance efforts.
18
Advantages of Using the Database
Approach
19
Additional Implications of Using the
Database Approach
⚫Potential for enforcing standards:
◦ This is very crucial for the success of database applications in
large organizations Standards refer to data item names,
display formats, screens, report structures, meta-data
(description of data) etc.
20
Additional Implications of Using the
Database Approach
⚫Flexibility to change data structures:
◦ Database structure may evolve as new requirements are
defined.
⚫Availability of up-to-date
information:
◦ Very important for on-line transaction systems such as airline,
hotel, car reservations.
⚫Economies of scale:
◦ By consolidating data and applications across departments
wasteful overlap of resources and personnel can be avoided.
21
When not to use a DBMS
⚫ Main inhibitors (costs) of using a DBMS:
◦ High initial investment and possible need for
additional hardware.
◦ Overhead for providing generality, security,
concurrency control, recovery, and integrity
functions.
22
When not to use a DBMS
⚫When no DBMS may suffice:
◦ If the database system is not able to
handle the complexity of data
because of modeling limitations
23
Brief History of Database Applications
25
Extending Database Capabilities
⚫Implementation (representational)
data models
◦ Provide concepts that fall between the above two,
balancing user views with some computer storage 28
Schemas, Instances and Database State
⚫ Database Schema
◦ The description of a database. Includes descriptions of the database
structure and the constraints that should hold on the database.
⚫ Schema Diagram
◦ A diagrammatic display of (some aspects of) a database schema.
⚫ Schema Construct
◦ A component of the schema or an object within the schema, e.g.,
STUDENT, COURSE.
⚫ Database State
◦ The actual data stored in a database at a particular moment in time.
Also called snapshot or instance or occurrence.
29
30
Database Schema Vs. Database
State
⚫Initial Database State
◦ Refers to the database when it is loaded
⚫Valid State
◦ A state that satisfies the structure and constraints of the
database.
⚫Distinction
◦ The database schema changes very infrequently. The database state
changes every time the database is updated.
◦ Schema is also called intension, whereas state is called
extension.
31
Three-Schema Architecture
⚫Proposed to support DBMS
characteristics of:
◦ Program-data independence.
32
Three-Schema Architecture
⚫ Defines DBMS schemas at three levels:
33
Three-Schema Architecture
34
Three-Schema Architecture
Mappings among schema levels
are needed to transform requests
and data. Programs refer to an
external schema, and are
mapped by the DBMS to the
internal schema for execution.
35
Data Independence
⚫ The capacity to change the schema at one level of a
database system without having to change the
system at the next higher level.
36
Data Independence
⚫ When a schema at a lower level is
changed, only the mappings between
this schema and higher-level schemas
need to be changed in a DBMS that fully
supports data independence.
◦ Pre-compiler Approach
41
DBMS Interfaces
⚫ User-friendly interfaces:
◦ Menu-based, popular for browsing on the web
◦ Forms-based, designed for naïve users
◦ Graphics-based (Point and Click, Drag and Drop etc.)
◦ Natural language: requests in written English
◦ Speech as Input and Output
◦ Web Browser as an interface
◦ Parametric interfaces (e.g., bank tellers) using
function keys.
◦ Interfaces for the DBA:
●Creating accounts, granting authorizations
●Setting system parameters
●Changing schemas or access path
42
DBMS Component Modules
43
DBMS ARCHITECTURES
44
BASIC CLIENT/SERVER ARCHITECTURES
45
Two-Tier Client/Server Architectures
for DBMSs
⚫ In such an architecture, the
server is often called a query
server or transaction server
because it provides these two
functionalities.
⚫ Intermediate layer or
middle tier is called the
application server or the
Web server, depending
on the application.
⚫ This server plays an
intermediary role by
running application
programs and storing
business rules (procedures
or constraints) that are
used to access data from
the database server.
⚫ It can also improve
database security by47
Using High – Level Conceptual Data Models
for Database Design
48
An Example Database
Application
⚫ Requirements of the Company
(oversimplified for illustrative purposes)
49
Contd…
⮚ We store each EMPLOYEE’s social security
number, address, salary, sex, and birth
date. Each employee works for one
department but may work on several
projects. We keep track of the number of
hours per week that an employee currently
works on each project. We also keep track
of the direct supervisor of each employee.
⚫ Entity
◦ A thing in the real world with an
independent existence.
◦ Eg: A particular person, Car, House or an
Employee
⚫ Attribute
◦ The particular property that describes
the entity.
◦ Eg: An Employee’s name, age, address,
salary and job
51
Types of Attributes
⚫ Composite versus simple(Atomic) Attributes
⚫ Complex Attributes
◦ For example, {Address_phone({Phone(Area_Code,
Phone_Number)}, Address(Street_Address(Number,
Street, Apartment_Number), City, Zip_Code))}
⚫ Null Values
52
Entity Types
⚫ A collection of entities that have the same
attributes.
54
Key Attribute of an Entity Type
55
Value Sets (Domains) of
Attributes
⚫Each simple attribute of an entity
type is associated with a value
set (or domain of values), which
specifies the set of values that
may be assigned to that attribute
for each individual entity.
CAR
Registration(RegistrationNumber, State), VehicleID, Make, Model, Year, (Color)
car1
((ABC 123, TEXAS), TK629, Ford Mustang, convertible, 1999,
(red, black))
car2
((ABC 123, NEW YORK), WP9872, Nissan 300ZX, 2-door,
2002, (blue))
car3
((VSY 720, TEXAS), TD729, Buick LeSabre, 4-door, 2003,
Entity Set
(white, blue))
.
.
. 57
Relationship Types, Relationship
Sets, and Instances
⚫A relationship type R among n
entity types E1, E2, … En defines a
set of associations – or a
relationship set – among
entities from these entity types.
e1 r1 d1
e2 r2
d2
e3
r3
e4
r4 d3
e5
r5
e6
e7 r6
r7
59
Example 2…
EMPLOYEE WORKS_ON PROJECT
r9
e1
r1 p1
e2 r2
p2
e3 r3
e4
r4 p3
e5
r5
e6
r6
e7
r7
r
8
60
Relationship Degree
⚫The degree of a relationship type
is the number of participating
entity types.
61
Role Names and Recursive Relationships
e1 2
1 r1
e2 2
1 r2
e3
2
1 r3
e4
2
e5 1
1 r4
e6 2
1 r5
e7 2
r6
(1) Supervisor
Role
(2) Subordinate
Role 63
Constraints on Relationship
Types
⚫ There are two types of relationship constraints:
◦ Cardinality ratio
● The cardinality ratio for binary relationship specifies the
maximum number of relationship instances that an entity
can participate in.
● The possible cardinality ratio for binary relationship types
are 1:1, 1:N, N:1 and M:N
◦ Participation
● The participation constraint specifies whether the existence
of an entity depends on its being related to another entity
via the relationship type.
● This constraint specifies the minimum number of
relationship instances that each entity can participate in.
e1 r1 d1
e2 r2
d2
e3
r3
e4
d3
e5
.
e6
.
e7
65
1:N Relationship
EMPLOYEE WORKS_FOR DEPARTMENT
e1 r1 d1
e2 r2
d2
e3
r3
e4
r4 d3
e5
r5
e6
e7 r6
r7
66
M:N Relationship
EMPLOYEE WORKS_ON PROJECT
r9
e1 r1 p1
e2 r2
p2
e3
r3
e4
r4 p3
e5
r5
e6
e7 r6
r7
r8
67
Participation Constraint and
Existence Dependence
⚫ The participation constraint specifies
whether the existence of an entity
depends on its being related to another
entity via the relationship type.
69
Weak Entity Types
⚫ Entity types that do not have key attributes of their own are called
weak entity types.
⚫ The entity types which contain key attributes of their own are called
regular entity types or strong entity types.
⚫ The relationship type that relates a weak entity type to its owner is
called as identifying relationship of the weak entity type.
⚫ The weak entity type normally has a partial key, which is the set of
attributes that can uniquely identify weak entities that are related to
the same owner entity.
70
Example…
Example:
Suppose that a DEPENDENT entity
is identified by the dependent’s
first name and birth date, and the
specific EMPLOYEE that the
dependent is related to.
RELATIONSHIP TYPE
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
COMPOSITE ATTRIBUTE
DERIVED ATTRIBUTE
TOTAL PARTICIPATION OF E2 IN R
72
Proper Naming of Schema
Constructs
⚫ Use singular names for entity types,
rather than plural one.
74
Alternative Notations for ER
Diagrams
75
Relationships of Higher Degree
⚫Relationship types of degree 2
are called binary
⚫Relationship types of degree 3
are called ternary and of degree
n are called n-ary
⚫In general, an n-ary relationship
is not equivalent to n binary
relationships
76
Subclasses and Superclasses
❑An entity type may have additional
meaningful subgroupings of its entities
SECRETAR
Y
Superclasses: EMPLOYEE
ENGINEER
EMPLOYEE Subclasses: SECRETARY,
ENGINEER,
TECHNICIA
N
TECHNICIAN,
SALARIED_EMPLOYEE,
SALARIED_EMPLOYEE HOURLY_EMPLOYEE
HOURLY_EMPLOYEE
77
Example
Lname SSN
Fname Addr
d
∪ ∪ d
∪ ∪
∪
TypingSpee
EngType MANAGER ∪
d TGrade HOURLY_EM
P
SECRETAR TECHNICIA ENGINEE SALARIED_EM
Y N R P
78
Why class/subclass relationships
and specializations
⚫ Certain attributes may apply to some but not
all entities of the superclass.
◦ A subclass is defined in order to group the entities to
which these attributes apply.
◦ The members of the subclass may still share the
majority of their attributes with the other members
of the superclass.
79
Why need class/subclass
relationships and specializations
⚫Some relationship types may be
participated in only by entities
that are members of the
subclass.
80
Subclasses vs. Superclasses
⚫ The set of entities in each subclasses is a
subset of the entities that belong to
EMPLOYEE
⚫ Each is called a subclass of EMPLOYEE
⚫ EMPLOYEE is the superclass for each of
these subclasses
⚫ The relationship between a superclass
and any one of its subclass is called a
superclass/subclass or class/subclass
relationship.
e.g., EMPLOYEE/SECRETARY and EMPLOYEE/TECHNICIAN are two
class/subclass relationships.
81
Properties of Superclasses and
Subclasses
⚫A member entity of the subclass
represents the same real-world entity
as some member of the superclass.
∪
TypingSpeed ∪ ∪ EngType
TGrade
SECRETARY ENGINEER
TECHNICIAN
85
Example
d
∪ ∪ d
∪ ∪
∪
TypingSpee
EngType MANAGER ∪
d TGrade HOURLY_EM
P
SECRETAR TECHNICIA ENGINEE SALARIED_EM
Y N R P
86
Specialization
⚫The process of defining a set of
subclass of an entity type (the
superclass of the specialization).
88
Diagrammatically representation of
specialization in an EER diagram
Esuper
Specific Specific
attributes attributes
∪ ∪
…
…
E2
E1
89
Example
EMPLOYEE
d
∪ ∪ d
∪ ∪
∪
MANAGER ∪
HOURLY_EM
P
SECRETAR TECHNICIA ENGINEE SALARIED_EM
Y N R P
MANAGES BELONGS_T
O
PROJECT TRADE_UNIO
N
90
Specialization
The specialization process allows
us to do the following:
⚫Define a set of subclass of an
entity type
⚫Establish additional specific
attributes with each subclass
⚫Establish additional specific
relationship types between each
subclass and other entity types or
other subclasses 91
Generalization
⚫Generalization is the reverse of
specialization process. It defines
a generalized entity type from
the given entity types.
92
Generalization (cont.)
NoOfPassenger LicensePlateNo NoOfAxles LicensePlateNo
s
MaxSpee Tonnage
d CAR Price TRUCK Price
VehicleID VehicleID
VEHICLE
NoOfPassenger d
s ∪ NoOfAxles
∪
MaxSpee
d CAR TRUCK Tonnage
93
Generalization (cont.)
⚫We can view {CAR, TRUCK} as a
specialization of VEHICLE
⚫Alternatively, we can view
VEHICLE as a generalization of
CAR and TRUCK
94
Generalization (cont.)
⚫Generalization suppresses the
difference among several entity types,
identifying their common features,
and generalize them into a single
superclass of which the original
types are special subclasses.