0% found this document useful (0 votes)
2 views90 pages

Notes

The document provides an overview of Database Management Systems (DBMS), explaining key concepts such as data, databases, and their applications in various sectors like banking and education. It discusses the advantages of DBMS over traditional file processing systems, including data abstraction, data independence, and the use of data models like the entity-relationship model. Additionally, it covers database languages, including Data Definition Language (DDL) and Data Manipulation Language (DML), and highlights the importance of schemas and data dictionaries.

Uploaded by

kingthemaster080
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views90 pages

Notes

The document provides an overview of Database Management Systems (DBMS), explaining key concepts such as data, databases, and their applications in various sectors like banking and education. It discusses the advantages of DBMS over traditional file processing systems, including data abstraction, data independence, and the use of data models like the entity-relationship model. Additionally, it covers database languages, including Data Definition Language (DDL) and Data Manipulation Language (DML), and highlights the importance of schemas and data dictionaries.

Uploaded by

kingthemaster080
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 90

DBMS

Unit-I
Introduction

Data: It is collection of information which is to be translated into
meaningful form for the purpose of processing i.e. Data contains
both useful /unuseful information but information is useful data
i.e. Extracted from the data.

Database:A database is a collection of data. It contains
information related to one particular enterprise.

Bank: -which stores customer, accounts, loans & banking
transaction information

Airlines: - For schedules & reservations information.

Universities: - For student, course registration & exam
information

DBMS:Data Base Management System

Database management system is a collection of interrelated data &
a set of programs to access the data.

The primary goal of a DBMS is to provide way to store and retrieve
database information that is both convenient and efficient

Database is an important part of enterprises
Database System Applications

Banking:Customer info., loan accounts, Banking Transactions.

Airlines:

University

Credit Card Transactions:

Telecommunication

Finance

Sales

On-l9ine retailers

Manufacturing:

Human Resources
Purpose of database System


Disadvantages in using file processing system.
1. Data Redundancy(duplication) and Inconsistency :

Since different programmers create the files and application
programs over a long period.
(i) The data files are likely to have different formats.
(ii) Programs may be written in several programming languages
(iii) The information may be duplicated in several files.

This redundancy leads to higher storage and access cost.

In addition, it may lead to data inconsistency that is the various
copies of the same data may no longer agree. E.g. address may be
written in various ways
2. Difficulty in accessing data:

Convenient file processing system does not allow needed data to
be retrieved in a convenient and efficient manner.

E.g. consider a data file Student with fields (Rollno, name, marks)

Application programs are written to access data. If user wants the
list of student whose marks is greater than 75. And if program is
not written then it is necessary to write down a new program for
producing such list.
3. Data isolation:

Because data are scattered in various files, and files may be in
different formats, writing new application programs to retrieve
the appropriate information is difficult.
4. Integrity Constraints:

The data values stored in the database must satisfy certain types
of constraints

e.g. Balance of a saving account may never fall RS. 200.

Application programmers enforce these consistency constraints
by adding appropriate code in the various application programs.
However, when a new constraint is to be added, it is difficult to
change programs to enforce the new constraints.

5. Atomicity Problems

A computer system is subject to failure. In many applications, if a
failure occurs it is difficult that, the data be restored to the
consistent state that existed prior to failure.

e.g. Consider a program to transfer Rs. 250 from account A to
account B. If failure occurs it is possible that fund was be removed
from account A but not transferred to account B.

This results in inconsistent state.

It is essential that either both credit and debit occur or that
neither occur.

That is funds transfer must be atomic –it must happen in its
entirely or not at all.

6. Concurrent Access Anomalies:

Many systems allow multiple users to update the data
simultaneously. But in case of file processing system data is not
centralized.

If two or more users want to access database at the same time,
interaction of concurrent updates may result in inconsistent data.
7. Security Problems:

Not every user of the database system should be able to access all
the data.

But enforcing such security constraints is difficult in conventional
file processing system.
DATA ABSTRACTION:

A major purpose of a database system is to provide users with
abstract view of the data. That is, the system hides certain details
of how the data are stored and maintained

Many complex database structures are used to represent data in
the database. Since many database system users are not computer
trained, developers hide the complexity from users through
several levels of abstraction, to simplify users interaction with the
system:

Physical level: It is the lowest level of data abstraction, It
describes how data are actually stored and describes data
structures and access methods to be used by the database.

At the physical level, complex data structures are used for
describing data.

Conceptual Level: It is the next higher level of abstraction. It
describes what data are stored in the database and relationship
that exists among the data..

Here, the entire database is described in terms of small number of
relatively simple structures.

The conceptual level of abstraction is used by database
administrators, who must decide what information is kept in the
database.

Implementation of the simple structures at the logical level may
involve complex level physical structures.

View level: It is the highest level of abstraction. It describes only a
part of the entire database.

Need of Abstraction:Many users of the database system will not
be concerned with all of the information. They may need only a
part of the entire database. This level of abstraction exists for
simplifying users interaction with system.
INSTANCES AND SCHEMAS

Database Changes over time as info. Is inserted and deleted.

Collection of information stored in the database at a particular
moment is called an instance of database.

The overall design(architecture or blueprint) of the database is
called database schema.

Schemas are changed infrequently.

A database schema is similar to the variable declarations or type
definitions in the programming language.
e.g. struct student
{
int rollno;
char name [40];
char address[40]
int marks;
} stud;

A database schema corresponds to the programming language
data type definition eg. Student structure in the above example.

The value of a given type has a particular value at a given instance.

e.g. stud variable in the above example has a particular value if
used in application program

Database systems have several schemas partitioned according to
the level of abstraction.
Physical schema describes the database design at the lowest
level.
Logical schema describes the database design at the logical
level.
A database may also have several schemas at the logical level,
sometimes called subschmas that describes different views of
the database.
DATA INDEPENDENCE

The ability to modify a schema defination in one level without
affecting a schema definition in the next higher level is called data
independence.

There are two levels of Independance


Logical data independence is more difficult to achieve than is
the physical data independence.

Programmer construct applications by using the logical schema .
The physical schema is hidden beneath the logical schema and can
be changed easily without affecting the application programs.

Database Languges

DDL:Data Defination Language- specify the database scheme

DML:Data Manipulation Language-express database query &
updates

Data definition language: Database schema is specified by a set
of definitions expressed by a special language called data
definition language (DDL).

The result of compilation of DDL statements is a set of tables,
which is stored in a special file called data directory

e.g. following statement in the SQL languages defines student
table
create table student
( rollno int(5),
name char(30),
address char(40)) ;

DATA DICTIONARY: The result of compilation of DDL statements
is a set of tables , which is stored in a special file called data
dictionary. This file contains metadata i.e. data about data. Among
the types of information the data dictionary stores following
information.

Name of relations (table).

Names of attributes of each relation

Domains of attributes

Names of views defined on the database, and the definition of
those views.

Integrity constraints for each relation.

In addition to that many system keeps following data on the user
of the system.

Name of authorized users.

Accounting information about users.

In system that use highly sophisticated structure to store
relations, statistical and descriptive relations may be kept on line.

Data Manipulation language:

DML is a language that enables users to access or manipulate data
as organized by the appropriate data model.

Data manipulation means:
– To retrieve information from the database
– To insert information form the database
– To delete information from database
– To modify information from database

There are basically two types of DML:


Procedural DML’s

Non procedural DML’s

Procedural DML’s : It requires a user to specify what data are
needed and how to get those data.

Non procedural DML’S: It requires a user to specify what data are
needed without specifying how to get those data.
e.g. DML component of the SQL language is non procedural
language.

Query:

A query is a statement requiring or requesting the retrieval of
information. The portion of a DML that involves information
retrieval is calleda query language.

e.g. select name from student where rollno=10;

This query in the SQL finds the name of the student whose roll
number is 10.

Queries may involve from more than one table.

The query processor component of the database system translates
DML queries into sequences of actions at the physical level of the
database system.
DATA MODELS

Underlying the structure of a database is data model, a collection
of conceptual tools for describing data, data relationships, data
semantics, and consistency constraints.
OBJECT BASED LOGICAL MODELS:

Object- based logical models are used in describing data at the
logical and view level. They provide flexible structuring
capabilities and allow data constraints to be specified explicitly.

There are several models. Several of more widely known ones are
– The entity relationship model

– The object oriented model


– The semantic data model
– The functional data model

The entity relationship model:

The entity relationship model is based on a perception of a real
world that consists of a collection of basic objects, called entities
and of relationships among those objects. An entity is a “thing” or
“object” in the real world.

E.g. person is a entity. A relationship is association among several
entities.

The set of all entities of the same type is called entity set. The set
of all relationships of the same type is called relationship set.

The overall logical structure of a database can be expressed
graphically by E-R diagram, Which is built from following
components
• Rectangles which represent entity set
• Ellipses which represent attributes
• Diamonds which represent relationship
• Lines which link attributes to entity sets and entity sets to
relationships.

The object Oriented Model Like the E-R model object oriented
model is based on a collection of objects.

An object contains values stored at a particular instance .An object
also contains bodies of code that operate on the object. These
objects are called methods.

Object that contains same type of values and same methods
grouped together into classes.

A class may be viewed as a type definition for objects.

Unlike entities in the E-R model , Each object has its own unique
identity independent of the values it contains.

Record Based Logical Models:

Record based logical model are used in describing data at the
logical and view levels.

Record based models are so named because database is
structured in fixed format of records of the several types.

Each record type defined a fixed number of fields, attributes and
each field is usually of a fixed length.

The three most widely accepted record based data models are
relational,network and hierarchical model.

Relational model:

Relational model uses a collection of tables to represent both data
and the relationships among those data. Each table has multiple
columns and each column has a unique name.

Example


Network Model:

Data in the network model are represented by collections of
records and relationship among data are represented by links,
Which can be viewed as pointers.

The records in the database are organized as collections of
arbitrary Graphs


Hierarchical Model :The hierarchical model is similar to the
network model.

It differs from network model in that the records are organized as
a collections of trees rather than arbitrary graphs.

Differences among models:

The relational model differs from network and hierarchical
models in that it does not use pointers or links. Instead, the
relational model relates by the values that they contain.
ENTITY RELATIONSHIP MODEL

Data model is a collection of conceptual tools for describing
data, data relationship, data semantics, consistency constraints.

Data models are classified into three categories.

Object based Logical Model
– E-R model
– Object-Oriented Model
– Functional Model

Record based Logical Model
– Relationship Model
– Network Model
– Hierarchical Model

Physical Model
– Unifying Model
– Frame Memory Model
E-R Model

E-R model is based on a perception of a real world that consists of
a set of basic objects, and a relationship among these objects.

Entity: An entity is a “thing” or “object” that is distinguishable
from all other objects.

For example
– Person is an entity
– Customer is an entity
– Student is an entity

An entity has a set or properties or attributes and the values for
some set of attributes or properties may uniquely identify an
entity.

Entity sets: An entity set is set of entities of the same type that
share the same properties.

For example
– Set of persons
– Set of customers
– Set of student

Attribute:An entity is represented by a set of attributes. An
attributes are descriptive properties possessed by each member
of entity set.

Each entity has a value for each of its attributes.

For each attribute ,there is a set of permitted values, called
domain or value set of that attribute.

A database thus includes a collection of entity sets, each of
which contains any number of entities of the same type.

ATTRIBUTE

Each entity has a set of attributes. Following are the attribute
types.

Simple attributes:
– These attributes can’t be divided into subparts.
– e.g. – Roll no, Account no. etc

Composite attributes:
– Composite attributes can be divided into sub parts.
– e.g. - birthday might have 3 fields

Single valued attributes:
– These attributes have a single value for a particular entity.
– e.g. account no, Roll no.

Derived attributes:
– The value for this type of attribute can be derived from the
values of other attributes.
– e.g. age from birthday.

Null Value attribute:
– Null value is used when an entity does not have a value for
attribute
– e.g. if a customer has no address

RELATIONSHIP:- A relationship is an association among several
entities

e.g. Consider two entity sets

Customer with attributes
– 1. name
– 2. address
– 3. social security


Account with attributes
– 1. social-security no.
– 2. balance
– 3. type


In this above example ,every customer has account in the bank.
Depositor is a relation between two entities customer and account
which specifies which account belongs to which customer.

Degree of a Relationship Set:The number of entity sets that
participate in a relationship set.

Relationship sets with two entity sets are binary (or degree
two).
most relationship sets in a database system are binary.

Relationship sets may involve more than two entity sets.
Entity sets customer, account, and branch may be linked by
the ternary (degree three) relationship set CAB.

Mapping Cardinality

Mapping cardinality or cardinality ratios:express the number of
entities to which another entity can be associated via a
relationship set.

It is most useful in describing the binary relationship.

Cardinality types are distinguished by drawing a directed line

(→):signifying “one,”

or an undirected line (—), signifying “many,” between the
relationship set and the entity set.

For a binary relationship set R between entity sets A and B, the
mapping cardinality must be one of the following


One to one :- An entity in A is associated with at most one entity
in B and an entity in B is associated at most one entity in A.


One to many :- An entity in A is associated with any number of
entities in B.

An entity in B, however can be associated with at most one entity
in A.

Many to one :- An entity in A is associated with at most one entity
in B.

An entity in B however can be associated with any number of
entities in A.


Many to many :- An entity in A is associated with any number of
entities in B

and an entity in B is associated with any number of entities in A.

PARTICIPATION CONSTRAINTS

● Total participation: - The participation of an entity set E in a


relationship set R is said to be total if every entity in E participates
in at least one relationship R.

Total Participation is shownn by Double line

Partial Participation: - If only some entities in E participate in
relationships in R , the participation of entity set is said to be
partial.

Partial Participation is shown by single line.


Every student must enrolled for any course so it is total
participation while course is not enrolled all students so it is
partial participation.
KEYS:

Keys allow us to identify uniquely an entity in the entity set.

Keys are distinguishing one entity from other.

Superkey:- A is a set of one or more attributes, that taken
collectively allow us identify uniquely an entity in the entity set.
Superkey may contain extra attributes.

Candidate key :- Candidate key is a superkey for which no proper
subset is a superkey. Such Minimal superkey are called the
candidate key.

Primary key :- The key chosen by database designer as a
principal means of identifying an entities in the entity set.

Candidate Key: The minimal set of attributes that can uniquely
identify a tuple is known as a candidate key. For Example,
STUD_NO in STUDENT relation.

It is a minimal super key.

It is a super key with no repeated data is called a candidate key.

The minimal set of attributes that can uniquely identify a record.

It must contain unique values.

It can contain NULL values.

Every table must have at least a single candidate key.

A table can have multiple candidate keys but only one primary key
(the primary key cannot have a NULL value, so the candidate key
with a NULL value can’t be the primary key).

The value of the Candidate Key is unique and may be null for a
tuple.

There can be more than one candidate key in a relationship.

The candidate key can be simple (having only one attribute) or
composite as well.

STUD_NO is the simple candidate key for relation STUDENT.

{STUD_NO, COURSE_NO} is a composite candidate key for relation
STUDENT_COURSE.


Primary Key: There can be more than one candidate key in
relation out of which one can be chosen as the primary key. For
Example, STUD_NO, as well as STUD_PHONE, are candidate keys
for relation STUDENT but STUD_NO can be chosen as the primary
key (only one out of many candidate keys).

It is a unique key.

It can identify only one tuple (a record) at a time.

It has no duplicate values, it has unique values.

It cannot be NULL.

STUDENT table -> Student(STUD_NO, SNAME, ADDRESS,
PHONE) , STUD_NO is a primary key

Super Key: The set of attributes that can uniquely identify a tuple
is known as Super Key. For Example, STUD_NO, (STUD_NO,
STUD_NAME), etc.

A super key is a group of single or multiple keys that identifies
rows in a table.

It supports NULL values.

Adding zero or more attributes to the candidate key generates the
super key.

A candidate key is a super key but vice versa is not true.

e.g. STUD_NO+PHONE is a super key.

Alternate Key: The candidate key other than the primary key is
called an alternate key.

All the keys which are not primary keys are called alternate keys.

It is a secondary key.

It contains two or more fields to identify two or more records.

These values are repeated.

Eg:- SNAME, and ADDRESS is Alternate keys

STUD_NO, as well as PHONE both, are candidate keys for relation
STUDENT but PHONE will be an alternate key (only one out of
many candidate keys).

Foreign Key : It is a key it acts as a primary key in one table and it
acts as secondary key in another table.

It combines two or more relations (tables) at a time.

They act as a cross-reference between the tables.

For example, STUD_NO in STUDENT_COURSE is a
foreign key to STUD_NO in STUDENT relation(primary)

The relation which is being referenced is called referenced
relation and the corresponding attribute is called referenced
attribute the relation which refers to the referenced relation is
called referencing relation and the corresponding attribute is
called referencing attribute.

Strong Entity set:- An entity set which has a primary key is called
as strong entity set.

Weak Entity set:- An entity set may not have a sufficient
attributes to form primary key. Such entity set is a termed as a
weak entity set.

Weak entity set is represented in E-R dig. by set by double
rectangles.

Member of strong entity set is dominant entity and member of
weak entity set is subordinate entity.

The existence of a weak entity set depends on the existence of a
strong entity set.

Strong Entity:

A strong entity is not dependent on any other entity in the
schema. A strong entity will always have a primary key. Strong
entities are represented by a single rectangle. The relationship of
two strong entities is represented by a single diamond.

Various strong entities, when combined together, create a strong
entity set.

Strong entities have either total participation or not.
Weak Entity:

A weak entity is dependent on a strong entity to ensure its
existence. Unlike a strong entity, a weak entity does not have any
primary key. It instead has a partial discriminator key. A weak
entity is represented by a double rectangle.

The relation between one strong and one weak entity is
represented by a double diamond. This relationship is also known
as identifying relationship.

While weak entity always has total participation.
REPRESENTATION OF MAPPING
CARDINALITY

Mapping cardinality is represented by directed line(→) or directed
line ( ).

One to one :

A customer is associated with at most one loan via the relationship


borrower.
A loan is associated with at most one customer via borrower

Many to many

A customer is associated with several loans via


borrower as well as
a loan is associated with several customers via
borrower.

One to Many:

A loan is associated with at most one customer via borrower, a
customer may have several loans.


Many to one:

A loan is associated with several customers via borrower, a
customer is associated with at most one loan.

Examples of ER-Diagram

STEPS TO DRAW E-R DIAGRAM



Identify entities from given problem definition.

Identify relationships.

Identity attributes of entities

Draw the E-R diagram using above information with conventions
of E-R dig.

Construct an E-R diagram for a car-insurance company that has a
set of customers, each of whom owns one or more cars. Each car
has associated with it zero to any number of recorded accidents.

Construct an E-R diagram for a hospital with a set of patients and
a set of medical doctors. Associate with each patient a log of the
various tests andexamination conducted.

A movie studio wishes to maintain a database to manage their
files of movies, actors and directors. The following facts are
relevant. Each actor has appeared in many movies Each director
has directed many movies. Each actor and director may have
several addresses and telephone numbers. Identify entities and
attributes . Draw an E-R diagram.
EXTENDED E-R FEATURES

Following are the extended Entity relationship feature of E-R


model.

Specialization

Generalization

Aggregation
Specialization


An entity is divided into sub-entities based on its characteristics.

It is a top-down approach where the higher-level entity is
specialized into two or more lower-level entities.

For Example, an EMPLOYEE entity in an Employee management
system can be specialized into DEVELOPER, TESTER, etc. . In this
case, common attributes like E_NAME, E_SAL, etc. become part of a
higher entity (EMPLOYEE), and specialized attributes like
TES_TYPE become part of a specialized entity (TESTER).
Generalization

Generalization is the process of extracting common properties
from a set of entities and creating a generalized entity from it.

It is a bottom-up approach in which two or more entities can be
generalized to a higher-level entity if they have some attributes in
common.

For Example, STUDENT and FACULTY can be generalized to a
higher-level entity called PERSON .In this, common attributes like
P_NAME, and P_ADD become part of a higher entity (PERSON),
and specialized attributes like S_FEE become part of a specialized
entity (STUDENT).

Aggregation


Aggregation is an abstraction through which relationships are
treated as higher level entities.

It helps to express relationship among relationships.

An ER diagram is not capable of representing the relationship
between an two entity – relationships which may be required in
some scenarios. In those cases, a relationship with its
corresponding entities is aggregated into a higher-level entity.

For Example, an Employee working on a project may require some
machinery. So, REQUIRE relationship is needed between the
relationship WORKS_FOR and entity MACHINERY. Using
aggregation, WORKS_FOR relationship with its entities EMPLOYEE
and PROJECT is aggregated into a single entity and relationship
REQUIRE is created between the aggregated entity and
MACHINERY.
Converting ER diagram to Tables


Assignment

You might also like