Unit 1 DBMS R23
Unit 1 DBMS R23
UNIT I
Introduction: Database system, Characteristics (Database Vs File System), Database Users, Advantages
of Database systems, Database applications. Brief introduction of different Data Models; Concepts of
Schema, Instance and data independence; Three tier schema architecture for data independence;
Database system structure, environment, Centralized and Client Server architecture for the database.
Entity Relationship Model: Introduction, Representation of entities, attributes, entity set, relationship,
relationship set, constraints, sub classes, super class, inheritance, specialization, generalization using ER
Diagrams.
Data
The raw facts are called as data. The word “raw” indicates that they have not been processed.
Examples:
Ages of employees: 25; 29; 45; 23; 60; 51; 35 …
Names of employees: Ben; Anna: Mark; Kathy; Rose; Jack; Jane …
Information
The processed data is known as information.
Ex: Ages of Employees: Ben is 25 yrs old; Anna is 29 yrs old; Mark is 45 yrs old; Kathy is 35
yrs old; Rose is 60 yrs old; while Jack is 51 yrs old…
Knowledge
knowledge is the awareness or the conscious understanding of information or a concept
1. Knowledge refers to the practical use of information.
2. Knowledge necessarily involves a personal experience.
Example: Our employees Ben, Anna, and Kathy are still young and they are prospective
leaders of the firm.
DATA/INFORMATION PROCESSING:
The process of converting the data (raw facts) into meaningful information is called as
data/information processing.
File: The collection of data is called a file that is stored in the computer with a file name.
These files are managed by the File Based system.
File Based Systems
File is a collection of data which is stored in computer. Each file has a specific
format. The files are managed by File system.
A file system is a technique of arranging the files in a storage medium like a hard disk, pen
drive, DVD, etc. It helps you to organizes the data and allows easy retrieval of files when they
are required. It mostly consists of different types of files like mp3, mp4, txt, doc, etc. that are
grouped into directories. File systems consist of different files which are grouped into
directories.
KHIT, Guntur
Problems:
No standards
Data duplication
Data dependence
No way to generate ad hoc queries
No provision for security, recovery, concurrency, etc.
To overcome these problems the Data base system was implemented.
Backup and It doesn’t provide backup and recovery of It provides backup and recovery
Recovery data if it is lost. of data even if it is lost.
KHIT, Guntur
DATABASE SYSTEM
A database is an organized collection of structured data, typically stored electronically in a
computer system.
A database is usually controlled by a database management system (DBMS). Together, the data
and the DBMS, along with the applications that are associated with them, are referred to as a
database system, often shortened to just database.
Example Databases:
• Medical records
• Bank accounts
• Stock control
• Personnel systems
• Product catalogues
• Telephone directories
• Train timetables
Why Database?
A Data Base Management System is a system software for easy, efficient and reliable data processing and
management.
A database system consists of
Data (the database)
Software
Hardware
Users
KHIT, Guntur
KHIT, Guntur
DATABASE USERS
In large organizations, many people are involved in the design, use, and maintenance of a large
database with hundreds of users. The people whose jobs involve the day-to-day use of a large
database; we call them the actors on the scene.
we consider people who may be called workers behind the scene—those who work to maintain
the database system environment but who are not actively interested in the database contents as
part of their daily job.
Database users are categorized based up on their interaction with the data base.
These are seven types of data base users in DBMS.
1. Database Administrator (DBA) :
Database Administrator (DBA) is a person/team who defines the schema and also
controls the 3 levels of database.
The DBA will create a user account id and password for the user if he/she need to access
the data base.
DBA is responsible for providing security to the data base and allows only the authorized
users to access/modify the data base.
DBA monitors the recovery and back up and provide technical support.
The DBA has a DBA account in the DBMS which called a system or superuser account.
KHIT, Guntur
6. Application Programmer :
Application Program are the back end programmers who writes the code for the application
programs.They are the computer professionals. These programs could be written in
Programming languages such as Visual Basic, Developer, C, FORTRAN, COBOL etc.
7. Casual Users / Temporary Users :
Casual Users are the users who occasionally use/access the data base .
Concepts of Schema
A schema can be defined as the design of a database. The overall description of the database is
called the database schema.
The schema also called as Blue Print or skeleton of the database.
It can be categorized into three parts. These are:
1. Physical Schema 2. Logical Schema 3. View Schema
KHIT, Guntur
DBMS Instance
The data stored in database at a particular moment of time is called instance of database.
Database schema defines the variable declarations in tables that belong to a particular database;
the value of these variables at a moment of time is called the instance of that database.
For example, lets say we have a single table student in the database, today the table has 100
records, so today the instance of the database has 100 records.
Data Independence
Data Independence is defined as a property of DBMS that helps you to change the Database
schema at one level of a database system without requiring to change the schema at the next
higher level.
Data independence helps you to keep data separated from all programs that make use of it.
KHIT, Guntur
DBMS Architectures
DBMS architectures are 3 types:
Centralized DBMS(1-tier)
Client-Server Architecture (2-tier)
Client-Server Architecture (3-tier)
Centralized DBMS:
Combines everything into single system
includingDBMS software, hardware, application
programs, and user interface processing software.
User can still connect through a remote terminal –
however, all processing is done at centralized site.
KHIT, Guntur
The intermediate layer or middle layer is called Application Server or Web Server, depending
on the application.
KHIT, Guntur
This server plays an intermediary role by running application programs and storing business
rules that are used to access data from the server.
It can also improve database security by checking client’s credentials before forwarding request
to the database server.
Figure (b) shows another architecture used by some other vendors. The layers in this are
Presentation, Business and Database services layers.
Advantages of Three-Tier Architecture :
1. The key three-tier benefit is improved scalability, since the application servers can be
deployed on many machines. Also, the database does not make longer connections with
every client – it only requires connections from a smaller number of application servers.
2. It improves data integrity. Here, all the updated information goes through the second
tier. The second tier can ensure that only important information is allowed to be updated in
the database and the risk of unreliable client applications corrupting information is
removed.
3. Security is improved since the client does not have direct access to the database; it is
more difficult for a client to obtain unauthorized data. Business logic is more secure
because it is stored on a secure central server.
4. Balancing of load is much easier with division of core business from the server of the
database.
KHIT, Guntur
Naive users are interact with the system by invoking one of the application programs that
have been written previously.
KHIT, Guntur
Query Processor:
The query processor will accept query from user and solves it by accessing the database.
Parts of Query processor:
DDL interpreter
This will interprets DDL statements and fetch the definitions in the data dictionary.
DML compiler
a. This will translates DML statements in a query language into low level instructions
that the query evaluation engine understands.
b. A query can usually be translated into any of a number of alternative evaluation plans
for same query result DML compiler will select best plan for query optimization.
Query evaluation engine
This engine will execute low-level instructions generated by the DML compiler on
DBMS.
Storage Manager:
A storage manager is a program module which acts like interface between the data stored
in a database and the application programs and queries submitted to the system.
Thus, the storage manager is responsible for storing, retrieving and updating data in the
database.
The storage manager components include:
o Authorization and integrity manager: Checks for integrity constraints and
authority of users to access data.
o Transaction manager: Ensures that the database remains in a consistent state
although there are system failures.
o File manager: Manages the allocation of space on disk storage and the data
structures used to represent information stored on disk.
o Buffer manager: It is responsible for retrieving data from disk storage into main
memory. It enables the database to handle data sizes that are much larger than the
size of main memory.
Disk Storage:
Disk storage is useful to store the actual database which maintains the following:
KHIT, Guntur
E-R Model
The ER model is used to define the conceptual view of database. The work of
the ER Model revolves around real-world entities and the associations between these
objects. At view level, the ER model is considered a good option for designing
databases.
Why we use ER Diagrams?
Helps to describe entities, attributes, relationships.
Provide a preview of how all your tables should connect, what fields are going
to be on each table.
ER diagrams are translatable into relational tables which allow you to build
databases quickly.
ER diagrams can be used by database designers as a blueprint for
implementing database.
The database designer gains a better understanding about the database with
the help of ER diagram.
Advantages
Simple: If we know the relationship between the attributes and the entities
we can easily build the ER Diagram for the model.
Effective Communication Tool: This model is used widely by the database
Easy Conversion to any Model: This model can be converted to any other
model like relational, network, hierarchical model etc.
Disadvantages
No industry standard for notation: means one developer might use notations
B.ChandraSekhar@Dept. of IT,
Downloaded by DEVARAJU PUTCHIGALLA ([email protected])
lOMoARcPSD|53142443
3. Relationships.
Notations
E-R Diagram is a visual representation of data that describes how data is related to
each other using different symbols and notations. Following are the major
Lines: It links attributes to entity types and entity types with other relationship
types.
Primary key: attributes are underlined
B.ChandraSekhar@Dept. of IT,
Example ER diagram:
employees, dealers, orders, and products can be considered as entities. Every entity is
rectangle.
Examples:
B.ChandraSekhar@Dept. of IT,
Types of Entities
There are two types of entities. They are:
1. Strong Entity.
2. Weak Entity.
Strong Entity
Strong entity are those entity types which has a key attribute. The primary key helps
Weak Entity
Weak entity doesn't have a key attribute. Weak entity type can't be identified
on its own. Its existence depends upon some other strong entity. For example, there
can be children only if the parent exits. There can be no independent existence of
children.
between a weak entity type and strong entity type is called an identifying
B.ChandraSekhar@Dept. of IT,
Attributes
An attribute is a property or characteristic of the entity that holds it. For example, a
Student might have attributes: roll_no, name, address, phone_no, etc. It is represented
by an ellipse/oval.
There exists a specific domain or set of values for each attribute from where the
attribute can take its values.
For example, a student's name cannot be a numeric value. It has to be alphabetic. A
1. Simple attribute.
2. Composite attribute.
3. Single valued attribute.
B.ChandraSekhar@Dept. of IT,
5. Derived attribute.
6. Key attribute.
1. Simple attribute
Here, student’s class, gender, dob are atomic values which cannot be divided further.
2. Composite attribute
Here, the attributes “Name” and “Address” are composite attributes as they are
B.ChandraSekhar@Dept. of IT,
Here, all the attributes are single valued attributes as they can take only one at a time.
4. Multi-Valued Attribute
— These are the attributes which can take more than one value at a time.
— They are represented by a double ellipse.
Example:
Here, the attributes “Mob_no” and “Email_id” are multi-valued attributes as they can
— These are the attributes which can be derived from other attribute(s).
— They are represented by dashed ellipses.
Example:
B.ChandraSekhar@Dept. of IT,
6. Key Attribute
— These are the attributes which can identify an entity uniquely in an entity set.
— Key attributes should be underlined.
Example:
Relationship
A relationship is an association among two or more entities. Entities take part in the
Department entity.
Like entities, a relationship too can have attributes. These attributes are called
B.ChandraSekhar@Dept. of IT,
Degree of a Relationship
— The number of entity sets that participate in a relationship set is termed as the
Degree of that relationship. Degree of above relationship is 2.
Types of Relationships
On the basis of degree of a relationship set, a relationship can be classified into the
following types:
1. Unary relationship.
2. Binary relationship.
3. Ternary relationship.
4. N-ary relationship.
1. Unary relationship
— When there is a relationship between two entities of the same type is known
as Unary relationship. It is known as a recursive relationship.
— This means that the relationship is between different instances of the same
entity type.
B.ChandraSekhar@Dept. of IT,
3. Ternary relationship
— When there are exactly three entity sets participating in a relationship then
such type of relationship is called ternary relationship
— For example: In the real world, a patient goes to a doctor and doctor
prescribes the medicine to the patient, three entities Doctor, Patient and
Medicine are involved in the relationship “prescribes”.
N-ary relationship
— When more than three entity sets are participating in a relationship, then
such type of relationship is called an N-ary relationship
— For example: In the real world, a patient goes to a doctor and doctor
prescribes the diagnosis and medicine to the patient, four entities Doctor,
Patient, Medicine and Diagnostics are involved in the relationship
“prescribes”.
B.ChandraSekhar@Dept. of IT,
Mapping Cardinalities/Constraints
— It defines how many entities in entity set A can be related to entities in
entity set B in a relationship set R.
(or)
— It defines number of instances participated in a relationship.
— It is most useful in describing the relationship sets that involve more than two
entity sets.
— For binary relationship set R on an entity set A and B, there are four possible.
— These are as follows:
1. One to one(1:1)
2. One to many(1:M)
3. Many to one(M:1)
4. Many to many(M:M)
1. One to One(1:1)
— An entity in A is associated with at most one entity in B, and an entity in B is
associated with at most one entity in A.
— Symbol used:
For example, assume that the only male can be married to only one female and
one female can be married to only one male, this can be viewed as one- to-one
cardinality.
B.ChandraSekhar@Dept. of IT,
2. One to Many(1:M)
— An entity in A is associated with any (zero or more) entities of B, and an
entity in B can be associated with at most one entity in A.
— Symbol used:
3. Many to One(M:1)
— Symbol used:
— For example: A student can belong to atmost one class but one class can have
many students.
B.ChandraSekhar@Dept. of IT,
— For example: Here many books are written by many authors and many
authors write many books.
Participation Constraints
B.ChandraSekhar@Dept. of IT,
As the complexity of data increased in the late 1980s, it became more and
more difficult to use the traditional ER Model for database modelling. Hence some
Hence, as part of the Enhanced ER Model, three new concepts were added to the
2. Specialization.
3. Aggregation.
Generalization
are combined to form a higher-level entity if they have some common attributes.
B.ChandraSekhar@Dept. of IT,
Specialization
Aggregation
It is a process when relation between two entities is treated as a single entity. Simply
it is used when we need to express a relationship among other relationships.
(or)
Aggregation is an abstraction in which relationship sets (along with their associated
entity sets) are treated as higher-level entity sets, and can participate in relationships.
B.ChandraSekhar@Dept. of IT,
In the diagram above, the relationship between College and Course together, is
acting as an Entity, which is in relationship with another entity Student. Now in real
world, if a Student visits College, he/she will never enquire about the College only
or just about the Course, rather he/she will enquire about both.
An entity set that does not have a primary key is referred to as a weak entity
set.
The existence of a weak entity set depends on the existence of an identifying
strong entity set on which the weak entity set is existence dependent, plus the
weak entity set’s discriminator.
We depict a weak entity set by double rectangles and underline the
Example: When the loan is approved, the customer begins payment. In this case,
the loan and payment are the two entities where the loan is a strong entity and
5. Draw complete E-R diagram with all attributes including Primary Key
Step1:Entity Identification.
1. Student.
2. Course.
3. Professor.
B.ChandraSekhar@Dept. of IT,
Step5: Draw complete E-Rdiagram with all attributes including Primary key.
B.ChandraSekhar@Dept. of IT,
Assumptions:
2. Student.
3. Course.
4. Faculty.
Step2:Find the relationships:
One course is enrolled by multiple students and one student enrolls for
multiple courses, hence the cardinality between course and student is Many
to Many.
The department offers many courses and each course belongs to only one
B.ChandraSekhar@Dept. of IT,
One department has multiple instructors and one instructor belongs to one
and only one department, hence the cardinality between department and
courses, hence the cardinality between course and instructor is Many to One.
For the Department entity, the attributes are dept_id, dname, loc and here
For the Course entity, the attributes are course-id, cname, duration, pre-
For the Student entity, the attributes are roll_no, sname, dob, address, mobile-
Step5:Draw complete E-R diagram with all attributes including Primary Key
B.ChandraSekhar@Dept. of IT,
Assumptions:
Where bank consists of many branches and every bank branch is situated in different
cities and can be uniquely identified by unique name. Each of these branches keeps
the tally of all the deposits and loans given to its customers. Bank customer have a
unique customer identifier, name, and postal address. A customer can have a
checking or a saving account and could also take loans. For loan customer may have
get services from personal bankers or loan officers. Each bank employee has a unique
identifier. Each employee has a manager, name, postal address, joining date, location
of branch. Accounts can be held by more than one customer and one customer can
have many accounts as well. Saving accounts has an interest rate where as Checking
account only keeps the record of deposits dates, amounts and check numbers.
B.ChandraSekhar@Dept. of IT,
***********EndofUNIT-II***********
B.ChandraSekhar@Dept. of IT,