0% found this document useful (0 votes)
46 views92 pages

DBMS Complete Unit 1 Material

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)
46 views92 pages

DBMS Complete Unit 1 Material

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/ 92

For complete DBMS subject tutorials visit : ns lectures youtube channel

DATABASE MANAGEMENT SYSTEMS


UNIT – I

Database System Applications: A Historical Perspective, File Systems versus a


DBMS, the Data Model, Levels of Abstraction in a DBMS, Data Independence,
Structure of a DBMS

Introduction to Database Design: Database Design and ER Diagrams, Entities,


Attributes, and Entity Sets, Relationships and Relationship Sets, Additional Features
of the ER Model, Conceptual Design With the ER Model

UNIT – II

Introduction to the Relational Model: Integrity constraint over relations, enforcing


integrity constraints, querying relational data, logical data base design, introduction
to views, destroying/altering tables and views.

Relational Algebra, Tuple relational Calculus, Domain relational calculus.

UNIT - III

SQL: QUERIES, CONSTRAINTS, TRIGGERS: form of basic SQL query, UNION,


INTERSECT, and EXCEPT, Nested Queries, aggregation operators, NULL values,
complex integrity constraints in SQL, triggers and active data bases.

Schema Refinement: Problems caused by redundancy, decompositions, problems


related to decomposition, reasoning about functional dependencies, FIRST,
SECOND, THIRD normal forms, BCNF, lossless join decomposition, multi-valued
dependencies, FOURTH normal form, FIFTH normal form.

UNIT – IV

Transaction Concept, Transaction State, Implementation of Atomicity and Durability,


Concurrent Executions, Serializability, Recoverability, Implementation of Isolation,
Testing for serializability, Lock Based Protocols, Timestamp Based Protocols,
Validation- Based Protocols, Multiple Granularity, Recovery and Atomicity, Log–
Based Recovery, Recovery with Concurrent Transactions.

UNIT - V

Data on External Storage, File Organization and Indexing, Cluster Indexes, Primary
and Secondary Indexes, Index data Structures, Hash Based Indexing, Tree base
Indexing, Comparison of File Organizations, Indexes and Performance Tuning,
Intuitions for tree Indexes, Indexed Sequential Access Methods (ISAM), B+ Trees: A
Dynamic Index Structure.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Chapter-1

Part-1 : Database System Applications

1. Database System Applications


2. A Historical Perspective
3. File Systems versus a DBMS
4. the Data Model
5. Levels of Abstraction in a DBMS
6. Data Independence
7. Structure of a DBMS

Part-2 : Introduction to Database Design

1. Database Design and ER Diagrams


2. Entities, Attributes, and Entity Sets
3. Relationships and Relationship Sets
4. Additional Features of the ER Model
5. Conceptual Design With the ER Model
For complete DBMS subject tutorials visit : ns lectures youtube channel

Database & DBMS


Data is raw, unorganized, unprocessed information.

Information is the processed, organized data that is beneficial in providing useful


knowledge.

here's a simple example of data and information:


Let's say you have a list of numbers:

2, 7, 9, 3, 5

This is an example of data. It's just raw, unprocessed facts or figures that don't have much
meaning on their own.

Now, let's say you organize this list of numbers from smallest to largest and add a label to
indicate that they represent the scores of five different students on a test:

Student Scores: 2, 3, 5, 7, 9

This is an example of information. The data has been organized and given context so that
it now has meaning and can be used to draw conclusions or make decisions.

What is a Database:
A database is an organized collection of structured information, typically stored
electronically in a computer system. A database is usually controlled by a database
management system (DBMS). A Database is a collection of related data organised in a
way that data can be easily accessed, managed and updated. Database can be software
based or hardware based, with one sole purpose, storing data. Databases can store data
in the form of tables depending upon the type of database.

During early computer days, data was collected and stored on tapes, which were mostly
write-only, which means once data is stored on it, it can never be read again. They were
slow and bulky, and soon computer scientists realised that they needed a better solution to
this problem. databases provide a powerful tool for managing data, enabling organizations
to store and access large amounts of information in an efficient and reliable manner.

What is DBMS:

A Database Management System (DBMS) is a software that allows creation, definition and
manipulation of database, allowing users to store, process and analyse data easily. DBMS
provides us with an interface or a tool, to perform various operations like creating
database, storing data in it, updating data, creating tables in the database and a lot more.

DBMS also provides protection and security to the databases. It also maintains data
consistency in case of multiple users.

Here are some examples of popular DBMS used these days:


For complete DBMS subject tutorials visit : ns lectures youtube channel

 MySql
 Oracle
 SQL Server
 IBM DB2
 PostgreSQL
 Amazon SimpleDB (cloud based) etc.

Edgar F. Codd is credited with being the founder of the relational database management
system (RDBMS), which is a type of DBMS. In the early 1970s, Codd developed the
concept of a relational database, which is a database that organizes data into one or more
tables with a unique key identifying each row. This concept laid the foundation for modern
DBMSs, and many of the principles he developed are still in use today.

Characteristics/ features of Database Management System

A database management system has following characteristics:

1. Data stored into Tables:

Data is never directly stored into the database. Data is stored into tables, created inside
the database. DBMS also allows to have relationships between tables which makes the
data more meaningful and connected. You can easily understand what type of data is
stored where by looking at all the tables created in a database.

2. Reduced Redundancy:

In the modern world hard drives are very cheap, but earlier when hard drives were too
expensive, unnecessary repetition of data in database was a big problem. But DBMS
follows Normalisation which divides the data in such a way that repetition is minimum.

3. Data Consistency:

On Live data, i.e. data that is being continuously updated and added, maintaining the
consistency of data can become a challenge. But DBMS handles it all by itself.

4. Support Multiple user and Concurrent Access:

DBMS allows multiple users to work on it(update, insert, delete data) at the same time and
still manages to maintain the data consistency.

5. Query Language:

DBMS provides users with a simple Query language, using which data can be easily
fetched, inserted, deleted and updated in a database.

6. Security:

The DBMS also takes care of the security of data, protecting the data from un-authorised
access. In a typical DBMS, we can create user accounts with different access permissions,
using which we can easily secure our data by restricting user access.

7. Data Integrity:
For complete DBMS subject tutorials visit : ns lectures youtube channel

DBMS ensures data integrity by providing mechanisms to maintain the correctness and
completeness of the data.

8. Backup and Recovery:

DBMS provides backup and recovery mechanisms to ensure that data can be restored in
the event of a failure or disaster.

Database tasks in a DBMS


A Database Management System (DBMS) performs several tasks related to managing
databases. Some of the common tasks performed by a DBMS include:

1. Data Definition:

The DBMS allows users to define the structure of the database, including tables, fields,
and relationships between tables. This task is also referred to as schema definition.

2. Data Manipulation:

The DBMS allows users to insert, update, delete, and retrieve data from the database.
This task is also known as query processing.

3. Data Retrieval:

The DBMS provides a query language that allows users to retrieve data from the
database. The most common query language used in DBMS is SQL (Structured Query
Language).

4. Data Security:

The DBMS provides mechanisms to ensure data security and prevent unauthorized
access to the database.

5. Data Integrity:

The DBMS ensures data integrity by enforcing data constraints, such as primary key and
foreign key constraints.

6. Backup and Recovery:

The DBMS provides mechanisms to backup and restore the database in case of data loss
or corruption.

7. Concurrency Control:

The DBMS ensures that multiple users can access the database simultaneously without
conflicts. This is achieved through techniques such as locking and transaction
management.

Advantages of DBMS
1. Improved Data Sharing:
For complete DBMS subject tutorials visit : ns lectures youtube channel

DBMS enables multiple users to access and share data simultaneously from different
locations, leading to increased collaboration and better decision-making.
2. Data Security:
DBMS provides various mechanisms to ensure data security, including access controls,
authentication, and encryption.
3. Data Consistency:
DBMS enforces data constraints, ensuring that data is consistent and accurate.

4. Backup:
It automatically backs up data to maintain its integrity in case of failure.
5. Controls database redundancy:
All the data is stored in one place, and that recorded in the database and hence controls
the redundancy in the database.
6. Data Integrity:
DBMS ensures that data is complete and accurate, helping to maintain the quality of data.
7. Easy Data Backup and Recovery:
DBMS provides mechanisms for backing up and restoring data, making it easier to
recover from data loss or corruption.

Disadvantages of DBMS
1. Cost of software and hardware:
It requires a number of high powered processors and large size memory to run DBMS.
2. Complexity:
DBMS can be complex and require specialized knowledge and expertise to set up and
maintain.
3. Size:
a Large amount of storage size is required to run DBMS efficiently.

4. Dependence on DBMS vendor:


Users are dependent on the DBMS vendor for support and updates, which can be a
disadvantage if the vendor goes out of business or discontinues support for the product.
5. Data Security Risks:
If the DBMS is not configured or maintained properly, it can pose a security risk, resulting
in data breaches and loss of sensitive information.
6. Higher impact of failure:
DBMS faces a higher risk of losing the data since all the data is stored at a single location
and a catastrophic failure can wipe it all.

Applications of DBMS
In so many fields, we will use a database management system.
Let’s see some of the applications where database management system uses −
1. Railway Reservation System –
The railway reservation system database plays a very important role by keeping record of
ticket booking, train’s departure time and arrival status and also gives information
regarding train late to people through the database.
2. Library Management System –
For complete DBMS subject tutorials visit : ns lectures youtube channel

Now-a-days it’s become easy in the Library to track each book and maintain it because of
the database. This happens because there are thousands of books in the library. It is very
difficult to keep a record of all books in a copy or register. Now DBMS used to maintain all
the information related to book issue dates, name of the book, author and availability of the
book.
3. Banking –
Banking is one of the main applications of databases. We all know there will be a thousand
transactions through banks daily and we are doing this without going to the bank. This is
all possible just because of DBMS that manages all the bank transactions.
4. Universities and colleges –
Now-a-days examinations are done online. So, the universities and colleges are
maintaining DBMS to store Student’s registrations details, results, courses and grade all
the information in the database. For example, telecommunications. Without DBMS there is
no telecommunication company. DBMS is most useful to these companies to store the call
details and monthly postpaid bills.
5. Credit card transactions –
The purchase of items and transactions of credit cards are made possible only by DBMS.
A credit card holder has to know the importance of their information that all are secured
through DBMS.
6. Social Media Sites –
By filling the required details we are able to access social media platforms. Many users
sign up daily on social websites such as Facebook, Pinterest and Instagram. All the
information related to the users are stored and maintained with the help of DBMS.
7. Finance –
Now-a-days there are lots of things to do with finance like storing sales, holding
information and finance statement management etc. these all can be done with database
systems.
8. Military –
In military areas the DBMS is playing a vital role. Military keeps records of soldiers and it
has so many files that should be kept secure and safe. DBMS provides a high security to
military information.
9. Online Shopping –
Now-a-days we all do Online shopping without wasting the time by going shopping with the
help of DBMS. The products are added and sold only with the help of DBMS like Purchase
information, invoice bills and payment.
10. Human Resource Management –
The management keeps records of each employee’s salary, tax and work through DBMS.
11. Manufacturing –
Manufacturing companies make products and sell them on a daily basis. To keep records
of all those details DBMS is used.
12. Airline Reservation system –
Just like the railway reservation system, airlines also need DBMS to keep records of flights
arrival, departure and delay status.

So finally, we can clearly conclude that the DBMS is playing a very important role in each
and every field.
For complete DBMS subject tutorials visit : ns lectures youtube channel

History of Database System (DBMS)


A database management system (DBMS) is a software system that allows users to create,
store, manage, and retrieve data from a database. DBMSs have a long and interesting
history, dating back to the early days of computing.

In the early 1960s, the first DBMSs were developed to manage large amounts of data for
scientific and military applications. These early systems were primarily used for data
storage and retrieval, and were designed for use on mainframe computers.

One of the earliest DBMSs was the Integrated Data Store (IDS) developed by General
Electric in the early 1960s. IDS was one of the first DBMSs to provide a high-level data
definition language (DDL) and a high-level data manipulation language (DML).

In the 1970s, the development of the relational model by Edgar F. Codd revolutionized the
field of DBMSs. The relational model provided a way to represent data in a tabular format,
with each row representing a single entity and each column representing a single attribute
of that entity. The relational model also introduced the concept of normalization, which is a
way to eliminate redundancy and improve data integrity.

The first commercial relational DBMS was the System R system developed by IBM in the
mid-1970s. Other popular relational DBMSs include Oracle, Microsoft SQL Server, and
MySQL.

In the 1980s, object-oriented DBMSs were developed to address the limitations of


relational DBMSs. Object-oriented DBMSs store data in the form of objects, which can
contain both data and the procedures that operate on that data.

In the 1990s, web-based DBMSs emerged, allowing users to access data through a web
browser. This made it easier to share data across different systems and locations.
For complete DBMS subject tutorials visit : ns lectures youtube channel

In the early 2000s, NoSQL databases were developed to address the need for scalable,
high-performance databases that could handle large volumes of unstructured data. NoSQL
databases use non-relational data models and can be used in distributed computing
environments.

Today, DBMSs are an essential part of modern computing, used in a wide range of
applications, from banking and finance to healthcare and scientific research. They
continue to evolve, with new features and capabilities being added to address the ever-
increasing demands of modern data-driven applications.

Difference between File System and DBMS

File System Approach:

File based systems were an early attempt to computerize the manual system. It is also
called a traditional based approach in which a decentralized approach was taken where
each department stored and controlled its own data with the help of a data processing
specialist. The main role of a data processing specialist was to create the necessary
computer file structures, and also manage the data within structures and design some
application programs that create reports based on file data.

In the above figure:

Consider an example of a student's file system. The student file will contain information
regarding the student (i.e. roll no, student name, course etc.). Similarly, we have a subject
file that contains information about the subject and the result file which contains the
information regarding the result.

Some fields are duplicated in more than one file, which leads to data redundancy. So to
overcome this problem, we need to create a centralized system, i.e. DBMS approach.

DBMS:

A database approach is a well-organized collection of data that are related in a meaningful


way which can be accessed by different users but stored only once in a system. The
For complete DBMS subject tutorials visit : ns lectures youtube channel

various operations performed by the DBMS system are: Insertion, deletion, selection,
sorting etc.

In the above figure,

In the above figure, duplication of data is reduced due to centralization of data.

These are the following differences between DBMS and File systems:

Basis File System DBMS

The file system is software that


manages and organizes the files in DBMS is software for
a storage medium within a managing the database.
Structure computer.

Data Redundant data can be present in In DBMS there is no


Redundancy a file system. redundant data.

It provides backup and


It doesn’t provide backup and
Backup and recovery of data even if it is
recovery of data if it is lost.
Recovery lost.

Query There is no efficient query Efficient query processing


processing processing in the file system. is there in DBMS.

There is more data


There is less data consistency in
consistency because of the
the file system.
Consistency process of normalization.

It has more complexity in


It is less complex as compared to
handling as compared to
DBMS.
Complexity the file system.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Basis File System DBMS

DBMS has more security


File systems provide less security
Security mechanisms as compared
in comparison to DBMS.
Constraints to file systems.

It has a comparatively
It is less expensive than DBMS. higher cost than a file
Cost system.

Data In DBMS data


There is no data independence.
Independence independence exists.

Only one user can access data at a Multiple users can access
User Access time. data at a time.

The user has to write procedures The user not required to


Meaning for managing databases write procedures.

Data is distributed in many files. Due to centralized nature


Sharing So, not easy to share data sharing is easy

Data It give details of storage and It hides the internal details


Abstraction representation of data of Database

Integrity Integrity Constraints are difficult to Integrity constraints are


Constraints implement easy to implement

Example Cobol, C++ Oracle, SQL Server

Data Model
Data Model gives us an idea that how the final system will look like after its complete
implementation. It defines the data elements and the relationships between the data
elements. Data Models are used to show how data is stored, connected, accessed and
updated in the database management system. Here, we use a set of symbols and text to
represent the information so that members of the organisation can communicate and
understand it. Though there are many data models being used nowadays but the
Relational model is the most widely used model. Apart from the Relational model, there
are many other types of data models about which we will study in details in this blog.
Some of the Data Models in DBMS are:

1. Hierarchical Model
2. Network Model
3. Entity-Relationship Model
4. Relational Model
5. Object-Oriented Data Model
6. Object-Relational Data Model
7. Flat Data Model
8. Semi-Structured Data Model
For complete DBMS subject tutorials visit : ns lectures youtube channel

9. Associative Data Model


10. Context Data Model

1. Hierarchical Model:
Hierarchical Model was the first DBMS model. This model organises the data in the
hierarchical tree structure. The hierarchy starts from the root which has root data and
then it expands in the form of a tree adding child node to the parent node. This model
easily represents some of the real-world relationships like food recipes, sitemap of a
website etc. Example: We can represent the relationship between the shoes present on
a shopping website in the following way:

Features of a Hierarchical Model

1. One-to-many relationship: The data here is organised in a tree-like structure where the
one-to-many relationship is between the datatypes. Also, there can be only one path
from parent to any node. Example: In the above example, if we want to go to the
node sneakers we only have one path to reach there i.e through men's shoes node.
2. Parent-Child Relationship: Each child node has a parent node but a parent node can
have more than one child node. Multiple parents are not allowed.
3. Deletion Problem: If a parent node is deleted then the child node is automatically
deleted.
4. Pointers: Pointers are used to link the parent node with the child node and are used to
navigate between the stored data. Example: In the above example the ' shoes ' node
points to the two other nodes ' women shoes ' node and ' men's shoes ' node.
Advantages of Hierarchical Model

 It is very simple and fast to traverse through a tree-like structure.


 Any change in the parent node is automatically reflected in the child node so, the
integrity of data is maintained.
Disadvantages of Hierarchical Model

 Complex relationships are not supported.


 As it does not support more than one parent of the child node so if we have some
complex relationship where a child node needs to have two parent node then that can't
be represented using this model.
 If a parent node is deleted then the child node is automatically deleted.
For complete DBMS subject tutorials visit : ns lectures youtube channel

2. Network Model:
This model is an extension of the hierarchical model. It was the most popular model
before the relational model. This model is the same as the hierarchical model, the only
difference is that a record can have more than one parent. It replaces the hierarchical
tree with a graph. Example: In the example below we can see that node student has two
parents i.e. CSE Department and Library. This was earlier not possible in the hierarchical
model.

Features of a Network Model

1. Ability to Merge more Relationships: In this model, as there are more relationships so
data is more related. This model has the ability to manage one-to-one relationships as
well as many-to-many relationships.
2. Many paths: As there are more relationships so there can be more than one path to the
same record. This makes data access fast and simple.
3. Circular Linked List: The operations on the network model are done with the help of the
circular linked list. The current position is maintained with the help of a program and this
position navigates through the records according to the relationship.
Advantages of Network Model

 The data can be accessed faster as compared to the hierarchical model. This is because
the data is more related in the network model and there can be more than one path to
reach a particular node. So the data can be accessed in many ways.
 As there is a parent-child relationship so data integrity is present. Any change in parent
record is reflected in the child record.
Disadvantages of Network Model

 As more and more relationships need to be handled the system might get complex. So, a
user must be having detailed knowledge of the model to work with the model.
 Any change like updation, deletion, insertion is very complex.
For complete DBMS subject tutorials visit : ns lectures youtube channel

3. Entity-Relationship Model:
Entity-Relationship Model or simply ER Model is a high-level data model diagram. In this
model, we represent the real-world problem in the pictorial form to make it easy for the
stakeholders to understand. It is also very easy for the developers to understand the
system by just looking at the ER diagram. We use the ER diagram as a visual tool to
represent an ER Model. ER diagram has the following three components:

 Entities: Entity is a real-world thing. It can be a person, place, or even a


concept. Example: Teachers, Students, Course, Building, Department, etc are some of
the entities of a School Management System.
 Attributes: An entity contains a real-world property called attribute. This is the
characteristics of that attribute. Example: The entity teacher has the property like teacher
id, salary, age, etc.
 Relationship: Relationship tells how two attributes are related. Example: Teacher works
for a department.
Example:

In the above diagram, the entities are Teacher and Department. The attributes
of Teacher entity are Teacher_Name, Teacher_id, Age, Salary, Mobile_Number. The
attributes of entity Department entity are Dept_id, Dept_name. The two entities are
connected using the relationship. Here, each teacher works for a department.

Features of ER Model:

 Graphical Representation for Better Understanding: It is very easy and simple to


understand so it can be used by the developers to communicate with the stakeholders.
 ER Diagram: ER diagram is used as a visual tool for representing the model.
 Database Design: This model helps the database designers to build the database and is
widely used in database design.
Advantages of ER Model:

 Simple: Conceptually ER Model is very easy to build. 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 designers
for communicating their ideas.
For complete DBMS subject tutorials visit : ns lectures youtube channel

 Easy Conversion to any Model : This model maps well to the relational model and can
be easily converted relational model by converting the ER model to the table. This model
can also be converted to any other model like network model, hierarchical model etc.
Disadvatages of ER Model:

 No industry standard for notation: There is no industry standard for developing an ER


model. So one developer might use notations which are not understood by other
developers.
 Hidden information: Some information might be lost or hidden in the ER model. As it is
a high-level view so there are chances that some details of information might be hidden.

4. Relational Model:
Relational Model is the most widely used model. In this model, the data is maintained in
the form of a two-dimensional table. All the information is stored in the form of row and
columns. The basic structure of a relational model is tables. So, the tables are also
called relations in the relational model. Example: In this example, we have an Employee
table.

Features of Relational Model:

 Tuples : Each row in the table is called tuple. A row contains all the information about
any instance of the object. In the above example, each row has all the information about
any specific individual like the first row has information about John.
 Attribute or field: Attributes are the property which defines the table or relation. The
values of the attribute should be from the same domain. In the above example, we have
different attributes of the employee like Salary, Mobile_no, etc.
Advnatages of Relational Model

 Simple: This model is more simple as compared to the network and hierarchical model.
 Scalable: This model can be easily scaled as we can add as many rows and columns
we want.
 Structural Independence: We can make changes in database structure without
changing the way to access the data. When we can make changes to the database
structure without affecting the capability to DBMS to access the data we can say that
structural independence has been achieved.
Disadvantages of Relatinal Model
For complete DBMS subject tutorials visit : ns lectures youtube channel

 Hardware Overheads: For hiding the complexities and making things easier for the user
this model requires more powerful hardware computers and data storage devices.
 Bad Design: As the relational model is very easy to design and use. So the users don't
need to know how the data is stored in order to access it. This ease of design can lead to
the development of a poor database which would slow down if the database grows.
But all these disadvantages are minor as compared to the advantages of the relational
model. These problems can be avoided with the help of proper implementation and
organisation.

5. Object-Oriented Data Model:

The Object-Oriented Model in DBMS or OODM is the data model where data is stored in
the form of objects. This model is used to represent real-world entities. The data and data
relationship is stored together in a single entity known as an object in the Object Oriented
Model. The Object-Oriented Database Management System is built on top of Object
Oriented Model.

As we have discussed earlier, we can use the Object Oriented Model in DBMS to
store real-world entities. Here, we can store pictures, audio, video, and other types of data,
which was previously impossible to store with the relational approach (Even though we
can store video and audio in the relational database, it is generally not recommended).

Example

Now let us consider an example given below.

 Here Transport, Bus, Ship, and Plane are objects.


 Bus has Road Transport as the attribute.
 Ship has Water Transport as the attribute.
 Plane has Air Transport as the attribute.
 The Transport object` is the base object and the Bus, Ship, and Plane objects derive from
it.

Take a look at another example-


For complete DBMS subject tutorials visit : ns lectures youtube channel

As you can see, here Student and Department are two different objects. Each one of them
has its attributes and methods. They are linked by a common attribute Dept_no which
establishes a relationship between objects.

Features:

Objects: In OODM, data is represented as objects, which are instances of classes. Each
object has its own set of attributes and methods.

Encapsulation: OODM uses encapsulation to hide the implementation details of an object.


Encapsulation allows objects to be treated as a single entity, with a well-defined interface.

Inheritance: OODM supports inheritance, which allows classes to inherit attributes and
methods from their parent classes. Inheritance helps in code reuse and simplifies the
design.

Polymorphism: OODM supports polymorphism, which allows objects of different classes to


be treated as if they were of the same class. Polymorphism helps in writing generic code
that can work with different types of objects.

Advantages:

Reusability: OODM promotes code reuse through inheritance. Classes can be derived
from existing classes, inheriting their attributes and methods.

Modularity: OODM allows for the design of complex systems to be divided into smaller,
more manageable modules. This makes it easier to maintain and update the system.

Flexibility: OODM allows for the creation of new classes that can be tailored to specific
needs. This flexibility allows for the system to be adapted to changing requirements.

Disadvantages:
For complete DBMS subject tutorials visit : ns lectures youtube channel

Complexity: OODM can be more complex than other data models, making it more difficult
for developers to learn and use. This can lead to longer development times and higher
costs.

Performance: OODM can be slower than other data models because of the overhead
associated with creating and managing objects.

Scalability: OODM can be less scalable than other data models, as the number of objects
and the size of the system increases, the overhead associated with managing objects can
become significant.

OODM offers several advantages such as code reuse, modularity, and flexibility, but it can
also be more complex and less performant than other data models. Therefore, it is
important to consider the specific needs of the project before choosing an appropriate data
model.

6. Object-Relational Model:
As the name suggests it is a combination of both the relational model and the object-
oriented model. This model was built to fill the gap between object-oriented model and
the relational model. We can have many advanced features like we can make complex
data types according to our requirements using the existing data types. The problem with
this model is that this can get complex and difficult to handle. So, proper understanding
of this model is required.

An Object relational model is a combination of a Object oriented database model and a


Relational database model. So, it supports objects, classes, inheritance etc. just like
Object Oriented models and has support for data types, tabular structures etc. like
Relational data model.
One of the major goals of Object relational data model is to close the gap between
relational databases and the object oriented practises frequently used in many
programming languages such as C++, C#, Java etc.

History of Object Relational Data Model

Both Relational data models and Object oriented data models are very useful. But it was
felt that they both were lacking in some characteristics and so work was started to build a
model that was a combination of them both. Hence, Object relational data model was
created as a result of research that was carried out in the 1990’s.

Advantages of Object Relational model

The advantages of the Object Relational model are −


Inheritance
The Object Relational data model allows its users to inherit objects, tables etc. so that they
can extend their functionality. Inherited objects contains new attributes as well as the
attributes that were inherited.
Complex Data Types
Complex data types can be formed using existing data types. This is useful in Object
relational data model as complex data types allow better manipulation of the data.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Extensibility
The functionality of the system can be extended in Object relational data model. This can
be achieved using complex data types as well as advanced concepts of object oriented
model such as inheritance.

Disadvantages of Object Relational model

The object relational data model can get quite complicated and difficult to handle at times
as it is a combination of the Object oriented data model and Relational data model and
utilizes the functionalities of both of them.

7. Flat Data Model:


It is a simple model in which the database is represented as a table consisting of rows
and columns. To access any data, the computer has to read the entire table. This makes
the modes slow and inefficient.

8. Semi-Structured Model:

The Semi-Structured Data Model is a data model used in database management systems
(DBMS) that allows for the representation of data in a flexible, hierarchical, and loosely
structured manner. Unlike traditional relational database models, where data is organized
into tables with pre-defined columns and data types, semi-structured data models allow for
the storage of data with varying and evolving schema.

Features :

Flexibility: Semi-structured data model allows for the representation of data with varying
schema, making it suitable for handling complex and heterogeneous data.

Hierarchical structure: Semi-structured data model is often represented in a hierarchical


structure such as XML or JSON, which allows for nested and hierarchical data to be stored
and queried efficiently.

Loosely structured: Semi-structured data model does not impose strict constraints on the
data schema, making it easier to handle data with evolving or unpredictable structures.

No fixed schema: Semi-structured data model does not require a predefined schema,
and the schema can evolve as the data changes or new data is added.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Advantages:

Flexibility: The semi-structured data model allows for flexibility in handling data with
varying structures, making it easier to handle complex and heterogeneous data.

Scalability: Semi-structured data model can be easily scaled to handle large and complex
data sets.

Easy integration: Semi-structured data can be easily integrated with other systems and
technologies, making it ideal for interoperability.

Reduced development time: The loosely structured nature of the semi-structured data
model reduces development time as schema changes can be made without affecting the
entire database.

Disadvantages:

Query complexity: Querying semi-structured data can be complex, as the data may be
stored in a nested and hierarchical format.

Lack of standardization: There is no standardization in the structure and format of semi-


structured data, which can make it difficult to handle and process data across different
systems.

Storage overhead: The flexibility of the semi-structured data model can lead to increased
storage overhead, as redundant data may be stored in different formats.
For complete DBMS subject tutorials visit : ns lectures youtube channel

9. Associative Data Model:


Associative Data Model is a model in which the data is divided into two parts. Everything
which has independent existence is called an entity and the relationship among these
entities are called association. The data divided into two parts are called items and links.

 Item: Items contain the name and the identifier (some numeric value).
 Links: Links contain the identifier, source, verb and subject.

10. Context Data Model:


Context Data Model is a collection of several models. This consists of models like
network model, relational models etc. Using this model we can do various types of tasks
which are not possible using any model alone.

Data Abstraction in DBMS


Schema:
The design of the database is called a schema. This tells us about the structural
view of the database. It gives us an overall description of the database. A database
schema defines how the data is organised using the schema diagram. A schema
diagram is a diagram which contains entities and the attributes that will define that
schema. A schema diagram only shows us the database design. It does not show
the actual data of the database. Schema can be a single table or it can have more
than one table which is related. The schema represents the relationship between
these tables.

Example: Let us suppose we have three tables Employee, Department and Project.
So, we can represent the schema of these three tables using the schema diagram
as follows. In this schema diagram, Employee and Department are related and the
Employee and Project table are related.

Data Abstraction is a process of hiding unwanted or irrelevant details from the end user.
The developers keep away the complex data from the user and remove the complications
so that the user can comfortably access data in the database and can only access the
data they want, which is done with the help of data abstraction.
For complete DBMS subject tutorials visit : ns lectures youtube channel

The main purpose of data abstraction is to hide irrelevant data and provide an abstract
view of the data. With the help of data abstraction, developers hide irrelevant data from the
user and provide them the relevant data. By doing this, users can access the data without
any pressure, and the system will also work efficiently.

In DBMS, data abstraction is performed in layers which means there are levels of data
abstraction in DBMS that we will further study in this article. Based on these levels, the
database management system is designed.

Levels of abstraction for DBMS (or) three levels of the schema (or)
Three tier schema Architecture:
Database systems include complex data-structures. In terms of retrieval of data, reduce
complexity in terms of usability of users and in order to make the system efficient,
developers use levels of abstraction that hide irrelevant details from the users. Levels of
abstraction simplify database design.
Mainly there are three levels of abstraction for DBMS, which are as follows −
 Physical or Internal Level
 Logical or Conceptual Level
 View or External Level
In DBMS, there are three levels of data abstraction, which are as follows:

.1. Physical or Internal Level or physical schema:

The physical or internal layer is the lowest level of data abstraction in the database
management system. It is the layer that defines how data is actually stored in the
database. It defines methods to access the data in the database. It defines complex data
structures in detail, so it is very complex to understand, which is why it is kept hidden from
the end user.

Data Administrators (DBA) decide how to arrange data and where to store data. The Data
Administrator (DBA) is the person whose role is to manage the data in the database at the
physical or internal level. There is a data center that securely stores the raw data in detail
on hard drives at this level.

2. Logical or Conceptual Level or logical schema:


For complete DBMS subject tutorials visit : ns lectures youtube channel

In database design, the conceptual level refers to the highest level of abstraction,
where the focus is on understanding the overall structure and meaning of the data
being stored, rather than the specific implementation details of the database system.

At the conceptual level, the database designer creates a data model, which defines the
entities, attributes, and relationships of the data. This schema is independent of any
specific database management system (DBMS), and serves as a blueprint for the
design and implementation of the database system. In the logical level, the data model
is transformed into a logical schema, which includes the specific tables, columns, and
constraints needed to implement the database.

It describes the structure of the entire data in the form of tables. The logical level or
conceptual level is less complex than the physical level. In software companies, the
conceptual level of the database is typically handled by a team of database designers or
data architects. These individuals are responsible for understanding the data requirements
of the organization and creating a conceptual schema that reflects those requirements.
However, the database designers may continue to be involved in the ongoing maintenance
and evolution of the database, to ensure that it continues to meet the needs of the
organization over time.

After the data model has been created, the logical database design phase typically
follows, where the data model is translated into a physical schema that includes
specific tables, columns, and constraints, along with any necessary optimization and
indexing for performance and scalability. This phase is typically handled by database
developers, rather than database architects.

Example: If we have to define an employee schema then it will have attributes like
Emlpoyee_id, Name, Age, Salary, Phone_no etc. So, the data types for these attributes
would be defined here. Also, if we have more than one table in our schema then how
these tables would be related is also defined here. Like if we have some more tables
like department table and project table then how these tables would be related is
defined here.

3. View or External Level or view schema :


View Schema defines the design of the database at the view level of the data
abstraction. It defines how an end-user will interact with the database system. There
are many view schema for a database system. Each view schema defines the view
of data for a particular group of people. It shows only those data to a view group in
which they are interested and hides the remaining details from them.

Example : A website has different views depending upon the user's authorization. A
college website has a different view for students, faculty and dean. Similarly, a
companies website would have a different view for the employee, accountant and
manager.

Advantages of data abstraction in DBMS:

o Users can easily access the data based on their queries.


o It provides security to the data stored in the database.
For complete DBMS subject tutorials visit : ns lectures youtube channel

o Database systems work efficiently because of data abstraction.

Features of data abstraction in DBMS:

1.Multiple levels:

Data abstraction provides multiple levels of abstraction, including external, conceptual,


and internal, which enable different users to view the database system at different
levels of complexity.

2.Separation of concerns:

Data abstraction separates the concerns of different users and stakeholders, such as
users, designers, and administrators, by providing a clear separation between the
logical and physical implementation of the database system.

3.Mapping between levels:

Data abstraction provides a mapping between the different levels of abstraction, which
ensures that changes made at one level do not affect the other levels.

4.Transparency: (Transparency mean clearness)

Data abstraction provides transparency to the users by hiding the implementation


details and complexity of the database system, and providing a consistent view of the
data.

Data Independence
The ability to modify the schema definition of a DBMS at one level, without affecting the
schema definition of the next higher level is called data independence. Its goal is to
make data independent of the user. Data independence is one of the important
characteristics of database management system. The database contains a tremendous
amount of data which is hard to handle if it is stored in one place. But with the usage
database management system expanding, there is a need to change the data over time
to satisfy the requirements.

So there is a multilayer architecture, such that modifications done at one level won’t
affect another. We have two types of data independence-Logical data independence
and physical data independence which can be explained by various levels. The various
levels of abstraction -physical level, logical level, and view level.
For complete DBMS subject tutorials visit : ns lectures youtube channel

The list of data independence in DBMS


data independence in DBMS are two types of data independence there are:

1. physical Data Independence

This is defined as the ability to modify the physical schema of the database without
the modification causing any changes in the logical/conceptual or view/external level.

Physical Data Independence means changing the physical level without affecting the
logical level or conceptual level. Using this property, we can change the storage
device of the database without affecting the logical schema.

Examples of Physical Data Independence:

 Changing from one data structure to another.


 Making use of new storage technology, such as a hard drive or magnetic
tapes
 Change the location of the database from one drive to another.
 Changing the database's file organization.

2. Logical Data Independence:


For complete DBMS subject tutorials visit : ns lectures youtube channel

Logical data independence is the ability to modify logical schema without causing
any unwanted modifications to the external schema or the application programs to
be rewritten. In other words, changes to the way the data is organized, structured, or
represented in the database can be made without requiring changes to the application
programs that use the data.

When compared to Physical Data independence, it is challenging to achieve logical


data independence.

Examples of changes under Logical Data Independence:


Due to Logical independence, any of the below change will not affect the
external layer.

1. Add/Modify/Delete a new attribute, entity or relationship is possible


without a rewrite of existing application programs
2. Merging two records into one
3. Breaking an existing record into two or more records

Parameters Physical Data Independence Logical Data Independence

Basics Physical data independence is Logical data independence is concerned


concerned mainly with how a set of mainly with the changing definition of the
data/ info gets stored in a given data in a system or its structure as a
system. whole.

Ease of Retrieving We can easily retrieve it. Retrieving is very difficult because the
data mainly depends on its logical
structure and not its physical location.

Ease of Achieving Achieving physical data Achieving logical data independence is


independence is much easier as more difficult as compared to physical
compared to logical data data independence.
independence.

Degree of Changes The changes made at the physical Any changes made at the physical level
level need not be made at the need to be made at the application level
For complete DBMS subject tutorials visit : ns lectures youtube channel

Required application level. as well.

Internal We may or may not need the Making modifications at the logical level
Modification modifications at the internal level for is a prerequisite whether we want to
improving the performance of a change the database structure or not.
system’s structure.

Type of Schema The internal schema is the primary The conceptual schema is the primary
concern. concern.

Examples For example, storage devices For example, adding, deleting, or


changes. modifying any attribute in a system.

Instance
Instance or extension or database state is a collection of information that stored in a
database at a particular moment is called an instance of the database. The
Database instance refers to the information stored in the database at a given point of
time. Thus, it is a dynamic value which keeps on changing.
Example:
A database instance for the Person database can be
(User1,emai.com,11345679,addr) So the person construct will contain their
individual entities in the attributes called as instance. This is shown below −
Person
Name Email Phone no

BOB [email protected] 2343435

JANU [email protected] 5345464

PRIYA [email protected] 2342342

differences between schema and instance :


Database Schema Database Instance

It is the definition of the database or it is defined It is a snapshot of a database at a specific moment.


as the description of the database.

It rarely changes. It changes frequently.

Example” We take two tables emp table and At a moment, what is the value of the database
dept table.Emp schema is called instance.At t=8 A.M

Id Empid name salary did


For complete DBMS subject tutorials visit : ns lectures youtube channel

Database Schema Database Instance

Name 1 A 5000 d1

Salary 2 B 2000 d2

At t=9 A.M
dept
3
Dept

C
Dept_id

3000
dname

d3

Emp and dept both called as schemas as It Empid 1 and 2 are called as Instance 1At time 9 A.M
gives database definition instance 2 changes

This corresponds to the variable declaration of a The value of the variable in a program at a point in
programming language. time corresponds to an instance of the database
schema.

DBMS Architecture
o The DBMS design depends upon its architecture. The basic client/server
architecture is used to deal with a large number of PCs, web servers,
database servers and other components that are connected with networks.
o The client/server architecture consists of many PCs and a workstation which
are connected via the network.
o DBMS architecture depends upon how users are connected to the database
to get their request done.

Types of DBMS Architecture

Database architecture can be seen as a single tier or multi-tier. But logically,


database architecture is of two types like: 2-tier architecture and 3-tier
architecture.
For complete DBMS subject tutorials visit : ns lectures youtube channel

1-Tier Architecture:
o In this architecture, the database is directly available to the user. It means the
user can directly sit on the DBMS and uses it.
o Any changes done here will directly be done on the database itself. It doesn't
provide a handy tool for end users.
o The 1-Tier architecture is used for development of the local application, where
programmers can directly communicate with the database for the quick
response.

2-Tier Architecture:
o The 2-Tier architecture is same as basic client-server. In the two-tier
architecture, applications on the client end can directly communicate with the
database at the server side. For this interaction, API's like: ODBC, JDBC are
used.
o The user interfaces and application programs are run on the client-side.
o The server side is responsible to provide the functionalities like: query
processing and transaction management.
o To communicate with the DBMS, client-side application establishes a
connection with the server side.

Fig: 2-tier Architecture

3-Tier Architecture:
o The 3-Tier architecture contains another layer between the client and server. In this
architecture, client can't directly communicate with the server.
o The application on the client-end interacts with an application server which further
communicates with the database system.
o End user has no idea about the existence of the database beyond the application
server. The database also has no idea about any other user beyond the
application.
o The 3-Tier architecture is used in case of large web application.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Fig: 3-tier Architecture

Difference Between Two-Tier And Three-Tier Database Architecture:


S.NO Two-Tier Database Architecture Three-Tier Database Architecture
1 It is a Client-Server Architecture. It is a Web-based application.

In two-tier, the application logic is


In three-tier, the application logic or process
either buried inside the user
2 resides in the middle-tier, it is separated from
interface on the client or within the
the data and the user interface.
database on the server (or both).

Two-tier architecture consists of


Three-tier architecture consists of three layers
3 two layers : Client Tier and
: Client Layer, Business Layer and Data Layer.
Database (Data Tier).

4 It is easy to build and maintain. It is complex to build and maintain.

5 Two-tier architecture runs slower. Three-tier architecture runs faster.

It is less secured as client can


It is secured as client is not allowed to
6 communicate with database
communicate with database directly.
directly.

It results in performance loss It results in performance loss whenever the


7 whenever the users increase system is run on Internet but gives more
rapidly. performance than two-tier architecture.

Example – Contact Management


Example – Designing registration form which
System created using MS-Access
8 contains text box, label, button or a large
or Railway Reservation System,
website on the Internet, etc.
etc.

Database System architecture


• Used by the computer system on which the database system runs.
• Database systems can be centralized, or client-server.
• A database system is divided into modules that deal with different responsibilities of the
For complete DBMS subject tutorials visit : ns lectures youtube channel

overall system.
• The functional components are broadly divided into the users, interface, query processor
components, and the storage manager.
Primary goal:- retrieving information from and storing new information into the database

It is the job of the database system to translate updates and queries written in a
nonprocedural language, at the logical level, into an efficient sequence of operations at the
physical level.

I. SYSTEM USERS:
four different types of database-system users,
1. Application programmers
2. Naive users
3. Sophisticated users and Specialized users:-
4. Database Administrator
For complete DBMS subject tutorials visit : ns lectures youtube channel

1. Application Developers:

Application developers are responsible for creating software applications that


interact with the database. They Develop APIs to communicate with the database.

2. Naive users
• Naive users are unsophisticated users.
• Interact with the system by the permanent application programs that have been
written previously.
• For example, the clerk at the ticket booking window, he uses an application
program to do his job of making reservations for a passenger.

3.Sophisticated users:

Sophisticated users interact with the system without writing programs. Instead, they
form their requests in a database query language.

They submit each such query to a query processor, whose function is to break down
DML statements into instructions that the storage manager understands.

4.Specialized users :

Specialized users are sophisticated users who write specialized database


applications like computer-aided design Systems, knowledgebase, and expert
systems, etc.
• The user uses complex data types (for example, graphics data and audio data).

5. Database Administrator (DBA):

A Database Administrator (DBA) is a professional responsible for managing and


maintaining an organization's database system. The DBA plays a critical role in
ensuring that the database system is running smoothly, securely, and efficiently. The
DBA's role and responsibilities typically include:

Database installation and configuration: The DBA is responsible for installing and
configuring the database software on the servers that will host the database. This
includes setting up the database parameters, file structures, and security settings.

Database backup and recovery: The DBA is responsible for ensuring that the
database system is regularly backed up, and there is a disaster recovery plan in
place to recover the system in case of a failure or disaster.

Database security: The DBA is responsible for managing the database security,
including setting up user accounts and permissions, encrypting sensitive data, and
implementing security protocols to prevent unauthorized access or data breaches.

Database performance tuning: The DBA is responsible for monitoring the


database system's performance and identifying and resolving performance
bottlenecks. This includes optimizing the database schema, tuning queries, and
managing database resources such as memory, CPU, and storage.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Database maintenance and upgrades: The DBA is responsible for performing


regular maintenance tasks such as database defragmentation, index optimization,
and database statistics update. The DBA also needs to plan and execute database
upgrades or migrations to ensure the database system's scalability and stability.

the DBA's role is crucial in maintaining the database system's integrity, security, and
performance. They need to work closely with other stakeholders such as developers,
system administrators, and end-users to ensure that the database system meets the
organization's business requirements and provides reliable and efficient services.

The functional components of a database system can be broadly divided


into the storage manager and the query processor components.

I. Query Processor:
In database architecture, a query processor is a crucial component responsible for
interpreting and executing user queries against the database. Its primary function is
to transform high-level queries expressed in a database query language (such as
SQL) into a sequence of low-level operations that can be efficiently executed by the
database engine.Its tasks include parsing and validating queries, optimizing query
execution plans, coordinating data retrieval and manipulation, and formatting and
delivering the query results. The efficiency and effectiveness of the query processor
directly impact the performance and scalability of the database system.

• A query processor helps the database system simplify and facilitate data access.
• System users are not required to know physical details of the implementation of
the system.
• Quick processing of updates.

Query Processor Components: -


These components are used in evaluating DDL and DML queries. These are:-

(i) DDL Interpreter:

In database management systems, a Data Definition Language (DDL) interpreter is a


component responsible for processing and executing commands that define and
manipulate the structure of a database. It specifically handles statements related to
creating, altering, and dropping database objects such as tables, indexes, views, and
constraints. The DDL interpreter plays a vital role in managing the schema and overall
structure of the database.

(ii) DML Compiler and Organizer:

In a database management system (DBMS), the DML compiler and organizer are
components responsible for processing and executing Data Manipulation Language
(DML) queries and coordinating the associated data manipulation operations.

a) DML Compiler:
For complete DBMS subject tutorials visit : ns lectures youtube channel

In database management systems, a Data Manipulation Language (DML) compiler is a


component responsible for processing and executing commands that manipulate the
data stored in a database. It specifically handles statements such as INSERT,
UPDATE, DELETE, and SELECT, which are used to retrieve, modify, and delete data
within database tables. The DML compiler translates these high-level DML statements
into low-level operations that can be executed by the database engine.

b) DML Organizer:

The DML organizer, also known as the query executor or coordinator, is responsible
for executing the execution plan generated by the DML compiler.

(iii) Application Program Object Code:

an Application Program Object Code (APOC) component refers to the compiled,


machine-readable version of an application program. It is the output of the compilation
process, which converts the human-readable source code into a form that can be
directly executed by a computer or a specific hardware platform.

(iv) Compiler and Linker:


• Application programmer writes program application.
• The source codes compiled by the compiler and linker-linked application program object
code to DML queries and send to query evolution engine.

(v) Query evaluation Engine:

The query evaluation engine, also known as the query execution engine or query
processor, is a crucial component in a database management system (DBMS). It is
responsible for executing user queries and retrieving the requested data from the
database. Here are some key uses of the query evaluation engine:

a) Query Parsing and Validation: The query evaluation engine parses the user's
query and validates its syntax and structure. It checks for proper query formation,
keywords, and adherence to the query language's grammar rules. If the query is
invalid, the engine generates an error message to alert the user.

b) Query Optimization: The query evaluation engine optimizes the execution plan
of the query to ensure efficient and fast data retrieval. It considers various factors
such as available indexes, statistics, and cost estimates to determine the most
optimal strategy for query execution. The optimization process aims to minimize the
use of system resources and reduce the query's response time.

c) Query Plan Generation: Based on the optimization process, the query


evaluation engine generates an execution plan or query plan. The query plan
specifies the sequence of operations and algorithms to be used to retrieve the
requested data. It determines how the query will be executed, including which
tables to access, which indexes to use, and how to join and filter the data.

d) Data Retrieval and Manipulation: The query evaluation engine coordinates the
retrieval and manipulation of data according to the generated query plan. It
For complete DBMS subject tutorials visit : ns lectures youtube channel

interacts with other components of the DBMS, such as the storage manager and
buffer manager, to efficiently access and retrieve data from disk or memory. The
engine performs operations like table scans, index lookups, join operations,
aggregations, and sorting to retrieve the requested data.

e) Concurrency Control and Transaction Management: The query evaluation


engine ensures the proper execution of queries in a multi-user environment. It
handles concurrency control to prevent conflicts and data inconsistencies when
multiple queries are executed concurrently. It also manages transactions, ensuring
the atomicity, consistency, isolation, and durability (ACID) properties of the
executed queries.

f) Result Formatting and Delivery: After executing the query, the query evaluation
engine formats the result set according to the specified output format. It may format
the results as tables, reports, or other appropriate formats based on user
requirements. The engine then delivers the formatted results to the user or
application that initiated the query.

The query evaluation engine plays a vital role in processing user queries and
retrieving data from a database. It ensures efficient execution, optimization, and
coordination of queries, providing users with accurate and timely access to the
desired information.

II. 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 raw data are stored on the disk using the file system, which is usually provided
by a conventional operating system.
• The storage manager translates the various DML statements into low-level file
system commands.
• The storage manager is responsible for storing, retrieving, and updating data in the
database.
• A large amount of storage space is required for storing corporate databases (which
may range from hundreds to gigabytes to terabytes of data) and to manage this
storage manager is required.
• We need to move data from disk storage to main memory as per requirement
because the main memory of the computer cannot store this much information

The storage manager components include:

Authorization and integrity manager, which tests for the satisfaction of integrity
constraints and checks the authority of users to access data.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Transaction manager, which ensures that the database remains in a consistent


(correct) state despite system failures, and that concurrent transaction executions
proceed without conflicting.

File manager, which manages the allocation of space on disk storage and the data
structures used to represent information stored on disk.

Buffer manager, which is responsible for fetching data from disk storage into main
memory, and deciding what data to cache in main memory. The buffer manager is a
critical part of the database system, since it enables the database to handle data
sizes that are much larger than the size of main memory.

Disk Storage:
• A DBMS can use several kinds of data structures as a part of physical system
implementation in the form of disk storage.
• Each structure has its own importance.
• Following are some common data structures.
• Disk storage is the central repository for storing all kinds of data in the database.

(i) Data
• It stores the database itself on the disk in the Data files.

(ii) Data Dictionary


It Stores metadata about the structure of the database.
The data dictionary stores:
• Names of relations
• Names of the attributes of each relation
• lengths of attributes
• Names of views defined on the database, and definitions of those views
• Names of authorized users
• Accounting information about users
• Number of records in each relation
• Method of storage used for each relation
• Name of the index
• Name of the relation being indexed
• Attributes on which the index is defined

(iii) Indices
• Indices, which can provide fast access to data items.
• A database index provides pointers to those data items that hold a particular value.
• Hashing is an alternative to indexing that is faster in some but not all cases.

(iv) Statistical Data


• It stores statistical information about the data stored in the database, like the
number of records, blocks, etc. in a table.
• This information can be used to execute a query efficiently.
Six steps of Database design process
Database design
The database design process consists of a number of steps. The general aim of a
database design process is to develop an efficient, high quality database that meets
For complete DBMS subject tutorials visit : ns lectures youtube channel

the needs and demands of the application and business stakeholders. Once you
have a solid design, you can build the database quickly. In most organizations,
database architects and database administrators (DBAs) are responsible for
designing a database. Their responsibility is to understand the business and
operational requirements of an organization, model the database based on those
requirements, and establishing who and how the database will be used. They simply
take the lead on the database design project and are responsible for the
management and control of the overall database design process.
The database design process can usually be broken down into six phases, as listed
below:
Requirement collection and analysis phase
Conceptual design phase
Logical design phase
Physical design phase
Implementation and loading phase
Testing and evaluation phase
Note: ER Model is much relevant to first three steps
The following figure briefly illustrates the database design process:

1. Requirement collection and analysis phase

In this phase, you interview the prospective users, gather their requirements, and
discuss their expectations from the new database application. Your objective in this
phase is to gather as much information as possible from potential users and then
documenting those requirements. This phase results in a concise set of user and
functional requirements, which should be detailed and complete. Functional
requirements typically include user operations to be applied to the database,
information flow, type of operation, the frequency of transactions and data updates.
You can document functional requirements using diagrams such as sequence
diagrams, data flow diagrams (DFDs), scenarios, etc.
Requirement collection and analysis phase can take a significant amount of time;
however, it plays a vital role in the success of the new database application. The
outcome of this phase is the document that contains the user’s specifications, which
is then used as the basis for the design of the new database application.

2. Conceptual design phase


For complete DBMS subject tutorials visit : ns lectures youtube channel

Your goal during the conceptual design phase is to develop the conceptual schema
of the database, which is then used to ensure that all user requirements are met and
do not conflict. In this step, you select appropriate data model and then translate the
requirements arising from the preceding phase into the conceptual database schema
by applying the concepts of chosen data model, which does not depend on RDBMS.
The most general data model used in this phase is the entity-relationship (ER)
model, which is usually used to represent the conceptual database design.
Conceptual schema includes the clear description of the user’s data requirements,
including the detailed description of the entity types, relationships, and constraints.
Conceptual design phase does not include implementation details. Thus, end users
can easily understand them, and hence, can be used as a communication tool. The
information you gather during the conceptual design phase is critical to the success
of your database design.

3. Logical design phase

In logical design phase, you start mapping entity-relationship (ER) model into a
relational schema. During this phase, you translate the high-level conceptual schema
implementation data model of the selected RDBMS constructs. The data model
chosen will be representing the company and its operations. The data model of
logical design will be a more detailed framework than that one developed during the
conceptual design phase. This phase provides specific guidelines, which you can
use to create the physical database design.

4. Physical design phase

During the physical design phase, you make decisions about the database
environment (database server), application development environment, database files
organisation, physical database objects, etc. Physical design phase is a very
technical stage of the database design process. The result of this phase is a physical
design specification that is used to build and deploy your database solution.

5. Implementation and loading phase

During this phase, you implement the proposed database is implemented. The
phase includes activities such as, the creation of the database, compilation and
execution of DDL statements to create the database schema and database files,
manually or automatically load the data into a new database system from a previous
system, and finally configure database and application security.

6. Testing and evaluation phase

In this phase, you perform testing of your database solution to tune it for
performance, integrity, concurrent access, and security restrictions. Typically this is
done in parallel with application programming phase. If the test fails, you take
several actions such as adjusting performance based on a reference manual,
physical design modification, logical design modification, upgrade or change the SQL
Server software and database server hardware.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Entities, Attributes and Entity Sets


Introduction of ER Model

Why Use ER Diagrams In DBMS?

 ER diagrams are used to represent the E-R model in a database, which


makes them easy to be converted into relations (tables).
 ER diagrams provide the purpose of real-world modeling of objects which
makes them intently useful.
 ER diagrams require no technical knowledge and no hardware support.
 These diagrams are very easy to understand and easy to create even for a
naive user.
 It gives a standard solution for visualizing the data logically.

Symbols Used in ER Model

ER Model is used to model the logical view of the system from a data perspective
which consists of these symbols:
 Rectangles: Rectangles represent Entities in ER Model.
 Ellipses: Ellipses represent Attributes in ER Model.
 Diamond: Diamonds represent Relationships among Entities.
 Lines: Lines represent attributes to entities and entity sets with other
relationship types.
 Double Ellipse: Double Ellipses represent Multi-Valued Attributes.
 Double Rectangle: Double Rectangle represents a Weak Entity.

Fig- Symbols used in ER Diagram


For complete DBMS subject tutorials visit : ns lectures youtube channel

The components /features of an ER diagram:

ER Diagrams re composed of entities, relationships and attributes. They also depict


cardinality, which defines relationships in terms of numbers. Here’s a glossary:
The features of the ER model are as follows −

 It is widely used to develop the initial design of the database.


 It provides a collection of basic concepts that can be easily implemented in a
database system.
 It describes data as a set of entities, attributes, and relationships.
 It provides the graphical view of the database design.
ER Model consists of Entities, Attributes, and Relationships among Entities in a
Database System.

fig- Components of ER Diagram

Entity in DBMS
Entity:

An entity is referred to as an object or thing that exists in the real world. For example,
customer, car, pen, etc.
Entities are stored in the database, and they should be distinguishable, i.e., they
should be easily identifiable from the group. For example, a group of pens that are
from the same company cannot be identified, so they are only objects, but pens with
different colours become unique and will be called an entity like a red pen, green
pen, blue pen, black pen, etc.
In a group of pens, we can easily identify any pen because of its different
colours, so a pen of different colours is an entity.
For extracting data from the database, each data must be unique in its own way so
that it becomes easier to differentiate between them. Distinct and unique data is
known as an entity.
For complete DBMS subject tutorials visit : ns lectures youtube channel

An entity has some attributes which depict the entity's characteristics. For example,
an entity "Student" has attributes such as "Student_roll_no", "Student_name",
"Student_subject", and "Student_marks".

Example of Entity in DBMS in tabular form:


Student_roll Student_na Student_subje Student_mark
no me ct s
1 Rahul DBMS 85
2 Krishna JAVA 75
3 Ramesh Python 80
4 Karthik c++ 70
Some entities are related to other entities in the table. For example, the "Student"
entity is related to the "University" entity. The ERD (Entity Relationship Diagram)
model comes to light to visually show the relationship between several entities.Kinds
of Entity:
There are two kinds of entities, which are as follows:
1. Tangible Entity:
It is an entity in DBMS, which is a physical object that we can touch or see. In simple
words, an entity that has a physical existence in the real world is called a tangible
entity.
For example, in a database, a table represents a tangible entity because it contains
a physical object that we can see and touch in the real world. It includes colleges,
bank lockers, mobiles, cars, watches, pens, paintings, etc.
2. Intangible Entity:
It is an entity in DBMS, which is a non-physical object that we cannot see or touch. In
simple words, an entity that does not have any physical existence in the real world is
known as an intangible entity.
For example, a bank account logically exists, but we cannot see or touch it.

Entity Type:

A collection of entities with general characteristics is known as an entity type.


For example, a database of a corporate company has entity types such as
employees, departments, etc. In DBMS, every entity type contains a set of attributes
that explain the entity.
The Employee entity type can have attributes such as name, age, address, phone
number, and salary.
The Department entity type can have attributes such as name, number, and location
in the department.

Kinds of Entity Type


There are two kinds of entity type, which are as follows:
For complete DBMS subject tutorials visit : ns lectures youtube channel

1. Strong Entity Type:


It is an entity that has its own existence and is independent.
The entity relationship diagram represents a strong entity type with the help of a
single rectangle. Below is the ERD of the strong entity type:

In the above example, the "Customer" is the entity type with attributes such as ID,
Name, Gender, and Phone Number. Customer is a strong entity type as it has a
unique ID for each customer.
2. Weak Entity Type:
It is an entity that does not have its own existence and relies on a strong entity for its
existence.
The Entity Relationship Diagram represents the weak entity type using double
rectangles. Below is the ERD of the weak entity type:

In the above example, "Address" is a weak entity type with attributes such as House
No., City, Location, and State.
The relationship between a strong and a weak entity type is known as an identifying
relationship.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Using a double diamond, the Entity-Relationship Diagram represents a relationship


between the strong and the weak entity type.
Let us see an example of the relationship between the Strong entity type and weak
entity type with the help of ER Diagram:

Entity Set
An entity set is a group of entities of the same entity type.
For example, an entity set of students, an entity set of motorbikes, an entity of
smartphones, an entity of customers, etc.
Entity sets can be classified into two types:
1. Strong Entity Set:
For example, an entity of motorbikes with the attributes, motorbike's registration
number, motorbike's name, motorbike's model, and motorbike's colour.
Below is the representation of a strong entity set in tabular form:
For complete DBMS subject tutorials visit : ns lectures youtube channel

Example of Entity Relationship Diagram representation of the above strong entity


set:

2. Weak Entity Set:


In a DBMS, a weak entity set does not contain a primary key.
For example, An entity of smartphones with its attributes, phone's name, phone's
colour, and phone's RAM.
Below is the representation of a weak entity set in tabular form:

Example of Entity Relationship Diagram representation of the above weak entity set:
For complete DBMS subject tutorials visit : ns lectures youtube channel

Difference between Strong and Weak Entity:

Dominant and subordinate entities


For complete DBMS subject tutorials visit : ns lectures youtube channel

Attributes in DBMS
An attribute is a property or characteristic of an entity. An entity may contain any
number of attributes. One of the attributes is considered as the primary key. In an
Entity-Relation model, attributes are represented in an elliptical shape.
Example: Student has attributes like name, age, roll number, and many more. To
uniquely identify the student, we use the primary key as a roll number as it is not
repeated. Attributes can also be subdivided into another set of attributes.
For example, in a customer database table, the attributes might be name, address,
and phone number. In a product database table, the attributes might be name, price,
and date of manufacture. Each attribute has a specific data type, such as string,
integer, or date.

Types of Attributes in DBMS

We always represent attributes in DBMS in an elliptical shape. We can refer to


the above image where we have an ER model diagram, and the student represented
in a rectangle shape is our entity object. Student entity has different attributes:
Roll_No, Name, DOB, Phone_No, Age, Address, Country, State, City, and Street.
Note that to uniquely identify the student entity, we may use the primary key as
Roll_No as it is not repeated. Here, Phone_No is a multi-valued attribute represented
by a co-centric elliptical shape, and similarly, we will study and learn more about
these different types of attributes in detail as we move through the course of this
article :)
For complete DBMS subject tutorials visit : ns lectures youtube channel

In DBMS, there are six such types of attributes available:

 Simple Attributes
 Composite Attributes
 Single Valued Attributes
 Multi-Valued Attributes
 Derived Attributes
 Key Attributes
 Complex Attributes (Rarely used attributes)

Now, we will study all of these different types of attributes in DBMS in detail along
with their diagrams and examples :)

1. Simple Attributes

Simple attributes in an ER model diagram are independent attributes that can't be


classified further and also, can't be subdivided into any other component. These
attributes are also known as atomic attributes.

Example Diagram:

As we can see in the above example, Student is an entity represented by a rectangle,


and it consists of attributes: Roll_no, class, and Age. Also, there is a point to be noted
For complete DBMS subject tutorials visit : ns lectures youtube channel

that we can't further subdivide the Roll_no attribute and even the other two attributes
into sub-attributes. Hence, they are known as simple attributes of the Student entity.

Composite Attributes

Composite attributes have opposite functionality to that of simple attributes as we


can further subdivide composite attributes into different components or sub-parts that
form simple attributes. In simple terms, composite attributes are composed of one or
more simple attributes.

Example Diagram:

As we can see in the above example, Address is a composite


attribute represented by an elliptical shape, and it can be further subdivided into
many simple attributes like Street, City, State, Country, Landmark, etc.

2. Single-Valued Attributes

Single valued attributes are those attributes that consist of a single value for each
entity instance and can't store more than one value. The value of these single-valued
attributes always remains the same, just like the name of a person.

Example Diagram:

As we can see in the above example, Student is an entity instance, and it consists of
attributes: Roll_no, Age, DOB, and Gender. These attributes can store only one
value from a set of possible values. Each entity instance can have only one Roll_no,
which is a unique, single DOB by which we can calculate age and also fixed gender.
Also, we can't further subdivide these attributes, and hence, they are simple as well
as single-valued attributes.
For complete DBMS subject tutorials visit : ns lectures youtube channel

3. Multi-Valued Attributes

Multi-valued attributes have opposite functionality to that of single-valued attributes,


and as the name suggests, multi-valued attributes can take up and store more than
one value at a time for an entity instance from a set of possible values. These
attributes are represented by co-centric elliptical shape, and we can also
use curly braces { } to represent multi-valued attributes inside it.

Example Diagram:

As we can see in the above example, the Student entity has four attributes: Roll_no and Age
are simple as well as single-valued attributes as discussed above
but Mob_no and Email_id are represented by co-centric ellipse are multi-valued
attributes. Each student in the real world can provide more than one email-id as well as a
mobile contact number, and therefore, we need these attributes to be multi-valued so that they
can store multiple values at a time for an entity instance.

4. Derived Attributes

Derived attributes in DBMS are those attributes whose values can be derived from
the values of other attributes. They are always dependent upon other attributes for
their value.

For example, As we were discussing above, DOB is a single-valued attribute and


remains constant for an entity instance. From DOB, we can derive the Age attribute,
which changes every year, and can easily calculate the age of a person from his/her
date of birth value. Hence, the Age attribute here is derived attribute from
the DOB single-valued attribute.

Example Diagram:

Derived attributes are always represented by dashed or dotted elliptical shapes.


For complete DBMS subject tutorials visit : ns lectures youtube channel

5. Key Attributes

Key attributes are special types of attributes that act as the primary key for an entity
and they can uniquely identify an entity from an entity set. The values that key
attributes store must be unique and non-repeating.

Example Diagram:

As we can see in the above example, we can say that the Roll_no attribute of the
Student entity is not only simple and single-valued attribute but also, a key valued
attribute as well. Roll_no of a student will always be unique to identify the student. Also
note that the Gender and Age of two or more persons can be same and overlapping in
nature and obviously, we can't identify a student on the basis of them.
Hence, gender and age are not key-valued attributes.

6. Complex Attributes
The complex attribute in DBMS involves both multivalued and composite attributes.
For example, someone might have more than one house, and each house might
have more than one phone. The phone is then considered a complex attribute.

In the example above, the phone number is a composite attribute of the area code,
exchange, and line number. Complex attributes are often used in database design
to represent relationships between entities. Here is a complex attribute example
explained in the form of a diagram.

Difference Between Simple and Composite Attributes in DBMS


Simple and composite are two types of attributes in database management
systems.
For complete DBMS subject tutorials visit : ns lectures youtube channel

A simple attribute cannot be further broken down into sub-parts. A composite


attribute, on the other hand, is made up of two or simpler attributes. For example, a
customer's address might be a composite attribute that consists of the street
number, city, state, and zip code.

Composite attributes can themselves be made up of other composite attributes,


as in the case of a customer's address, which could be composed of a zip code,
streets, etc. However, they can also make data entry and retrieval more complex,
as all of the component attributes must be considered when performing these
operations.

When defining a database, it is important to understand the difference between


simple and composite attributes, as this will affect how the data is structured.

Attribute set:

Relationship and Relationship Set


A Relationship represents the association between entity types. For example,
‘Enrolled in’ is a relationship type that exists between entity type Student and
Course. In ER diagram, the relationship type is represented by a diamond and
connecting the entities with lines.

Entity-Relationship Set
A set of relationships of the same type is known as a relationship set. The following
relationship set depicts S1 as enrolled in C2, S2 as enrolled in C1, and S3 as
registered in C3.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Relationship Set

Degree of a Relationship Set (or) Types of Relationship Sets-

On the basis of degree of a relationship set, a relationship set can be classified into
the following types-
1. Unary relationship set
2. Binary relationship set
3. Ternary relationship set
4. N-ary relationship set
The number of different entity sets participating in a relationship set is called the
degree of a relationship set.
1. Unary Relationship: When there is only ONE entity set participating in a relation,
the relationship is called a unary relationship. For example, one person is married to
only one person.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Fig-Unary Relationship
2. Binary Relationship:When there are TWO entities set participating in a
relationship, the relationship is called a binary relationship. For example, a Student is
enrolled in a Course.

Fig- Binary Relationship

3. Ternary Relationship Set-

Ternary relationship set is a relationship set where three entity sets participate in a
relationship set.

Example-

4. n-ary Relationship: When there are n entities set participating in a relation, the
relationship is called an n-ary relationship.

Cardinality Constraints
Constraints are used for modeling limitations on the relations between
entities.
There are two types of constraints on the Entity Relationship (ER) model −
 Mapping cardinality or cardinality ratio.
 Participation constraints.

Mapping Cardinality
For complete DBMS subject tutorials visit : ns lectures youtube channel

It is expressed as the number of entities to which another entity can be associated


via a relationship set.
For the binary relationship set there are entity set A and B then the mapping
cardinality can be one of the following −
 One-to-one
 One-to-many
 Many-to-one
 Many-to-many
The number of times an entity of an entity set participates in a relationship set is
known as cardinality. Cardinality can be of different types:
1. One-to-One:When each entity in each entity set can take part only once in the
relationship, the cardinality is one-to-one. Let us assume that a male can marry one
female and a female can marry one male. So the relationship will be one-to-one.
the total number of tables that can be used in this is 2.

One-to-One Cardinality
Using Sets, it can be represented as:

Set Representation of One-to-One


2. One-to-Many:In one-to-many mapping as well where each entity can be related to
more than one relationship and the total number of tables that can be used in this is
For complete DBMS subject tutorials visit : ns lectures youtube channel

One to Many Cardinality


Using sets, one-to-many cardinality can be represented as:

3. Many-to-One:When entities in one entity set can take part only once in the
relationship set and entities in other entity sets can take part more than once in the
relationship set, cardinality is many to one. Let us assume that a student can take
only one course but one course can be taken by many students. So the cardinality
will be n to 1. It means that for one course there can be n students but for one
student, there will be only one course.
The total number of tables that can be used in this is 3.

Many-to-One Cardinality
Using Sets, it can be represented as:
For complete DBMS subject tutorials visit : ns lectures youtube channel

Set Representation of Many-to-One


In this case, each student is taking only 1 course but 1 course has been taken by
many students.
4. Many-to-Many: When entities in all entity sets can take part more than once in
the relationship cardinality is many to many. Let us assume that a student can take
more than one course and one course can be taken by many students. So the
relationship will be many to many.
the total number of tables that can be used in this is 3.

Many-to-Many Cardinality:
Using Sets, it can be represented as:

Many-to-Many Set Representation


For complete DBMS subject tutorials visit : ns lectures youtube channel

In this example, student S1 is enrolled in C1 and C3 and Course C3 is enrolled by


S1, S3, and S4. So it is many-to-many relationships.

2. Participation Constraints:
In a Relationship, Participation constraint specifies the presence of an entity when it
is related to another entity in a relationship type. It is also called the minimum
cardinality constraint.

This constraint specifies the number of instances of an entity that are


participating in the relationship type.

 There are two types of Participation constraint:


o Total participation
o Partial participation

Total participation constraint

 It specifies that each entity present in the entity set must mandatorily
participate in at least one relationship instance of that relationship
set,for this reason, it is also called as mandatory participation
 It is represented using a double line between the entity set and relationship
set

Example of total participation constraint

It specifies that each student must be enrolled in at least one course where
the “student” is the entity set and relationship “enrolled in” signifies total
participation .It means that every student must have enrolled at least in one
course
For complete DBMS subject tutorials visit : ns lectures youtube channel

Partial participation

 It specifies that each entity in the entity set may or may not participate in
the relationship instance of the relationship set, is also called as optional
participation
 It is represented using a single line between the entity set and relationship
set in the ER diagram

Example of partial participation


A single line between the entities i.e courses and enrolled in a relationship
signifies the partial participation,which means there might be some courses
where enrollments are not made i.e enrollments are optional in that case

Using Set, it can be represented as,

Set representation of Total Participation and Partial Participation


Every student in the Student Entity set participates in a relationship but there exists a
course C4 that is not taking part in the relationship.

types of constraints In an Entity-Relationship (ER) model


In an Entity-Relationship (ER) model, there are three main types of constraints:
For complete DBMS subject tutorials visit : ns lectures youtube channel

 Entity Constraints
 Attribute Constraints

I. Entity Constraints:
These constraints define the rules for creating instances of an entity. There are
two types of entity constraints:

1. Key Constraints:

2. Participation Constraint

1. key Constraints:
This constraint ensures that each instance of an entity has a unique identifier, which
is called a primary key. This means that no two instances of the entity can have the
same primary key value.The entity key constraint states that primary key value can't
be null.This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those rows.
A table can contain a null value other than the primary key field.

Example:

2. Participation Constraints:
In a Relationship, Participation constraint specifies the presence of an entity when it
is related to another entity in a relationship type. It is also called the minimum
cardinality constraint.

This constraint specifies the number of instances of an entity that are


participating in the relationship type.

 There are two types of Participation constraint:


o Total participation: which means that each instance of an entity must
participate in the relationship
o Partial participation: which means that some instances of an entity may
not participate in the relationship.

II. Attribute Constraints:


These constraints define the rules for creating instances of an attribute. There are
two types of attribute constraints:
For complete DBMS subject tutorials visit : ns lectures youtube channel

1) Domain Constraints: This constraint specifies the set of valid values that an
attribute can have.

o The data type of domain includes string, character, integer, time, date,
currency, etc. The value of the attribute must be available in the
corresponding domain.

Example:

2) Key Constraints: This constraint ensures that each instance of an attribute has a
unique identifier, which is called a primary key. This means that no two instances of
the attribute can have the same primary key value.

III. Relationship Constraints:


Relationship Constraints: These constraints define the rules for creating instances of
a relationship. There are two types of relationship constraints:

1) Cardinality Constraints:

This constraint specifies the number of instances of one entity that can be related to
the number of instances of another entity. There are four types of cardinality
constraints: one-to-one, one-to-many, many-to-one, and many-to-many.

2) Participation Constraints:
In a Relationship, Participation constraint specifies the presence of an entity when it
is related to another entity in a relationship type. It is also called the minimum
cardinality constraint.

This constraint specifies the number of instances of an entity that are


participating in the relationship type.

 There are two types of Participation constraint:


o Total participation: which means that each instance of an entity must
participate in the relationship
o Partial participation: which means that some instances of an entity may
not participate in the relationship.

How to Draw ER Diagram?


For complete DBMS subject tutorials visit : ns lectures youtube channel

 The very first step is identifying all the Entities, and place them in a Rectangle,
and labelling them accordingly.
 The next step is to identify the relationship between them and pace them
accordingly using the Diamond, and make sure that, Relationships are not
connected to each other.
 Attach attributes to the entities properly.
 Remove redundant entities and relationships.
 Add proper colours to highlight the data present in the database.

Generalization, Specialization and Aggregation in ER Model


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
improvements or enhancements were made to the existing ER Model to make it able
to handle the complex applications better.
Hence, as part of the Enhanced ER Model, along with other improvements, three
new concepts were added to the existing ER Model, they were:
1. Generalization
2. Specialization
3. Aggregration
Let's understand what they are, and why were they added to the existing ER Model.

1. Generalization
Generalization is the process of extracting common properties from a set of entities
and create 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 as shown in Figure 1. In this case, common attributes
like P_NAME, P_ADD become part of higher entity (PERSON) and specialized
attributes like S_FEE become part of specialized entity (STUDENT).
For complete DBMS subject tutorials visit : ns lectures youtube channel

Example-2 of Generalization –
Consider two entities Student and Patient. These two entities will have some
characteristics of their own. For example Student entity will have Roll_No, Name and
Mob_No while patient will have PId, Name and Mob_No characteristics. Now in this
example Name and Mob_No of both Student and Patient can be combined as a
Person to form one higher level entity and this process is called as Generalization
Process.

2. Specialization –In specialization, an entity is divided into sub-entities based


on their characteristics. It is a top-down approach where higher level entity is
specialized into two or more lower level entities. For Example, EMPLOYEE entity in
an Employee management system can be specialized into DEVELOPER, TESTER
etc. as shown in Figure 2. In this case, common attributes like E_NAME, E_SAL etc.
become part of higher entity (EMPLOYEE) and specialized attributes like TES_TYPE
become part of specialized entity (TESTER).
For complete DBMS subject tutorials visit : ns lectures youtube channel

Example-2:
Consider an entity Account. This will have some attributes consider them Acc_No
and Balance. Account entity may have some other attributes like Current_Acc and
Savings_Acc. Now Current_Acc may have Acc_No, Balance and Transactions while
Savings_Acc may have Acc_No, Balance and Interest_Rate henceforth we can say
that specialized entities inherits characteristics of higher level entity.

After applying generalization and specialization, the structure of resultant figures are
same

Difference between Generalization and Specialization :


GENERALIZATION SPECIALIZATION

Generalization works in Bottom-Up


Specialization works in top-down approach.
approach.

In Generalization, size of schema gets In Specialization, size of schema gets


reduced. increased.

Generalization is normally applied to We can apply Specialization to a single


group of entities. entity.

Generalization can be defined as a


Specialization can be defined as process of
process of creating groupings from
creating subgrouping within an entity set
various entity sets

In Generalization process, what actually Specialization is reverse of Generalization.


happens is that it takes the union of two Specialization is a process of taking a
For complete DBMS subject tutorials visit : ns lectures youtube channel

GENERALIZATION SPECIALIZATION

or more lower-level entity sets to subset of a higher level entity set to form a
produce a higher-level entity sets. lower-level entity set.

Generalization process starts with the


Specialization process starts from a single
number of entity sets and it creates high-
entity set and it creates a different entity
level entity with the help of some
set by using some different features.
common features.

In Generalization, the difference and


In Specialization, a higher entity is split to
similarities between lower entities are
form lower entities.
ignored to form a higher entity.

There is no inheritance in
There is inheritance in Specialization.
Generalization.

3. Aggregation:
Aggregation in DBMS (Database Management System) is the process of combining
two or more entities to form a more meaningful new entity. When the entities do not
make sense on their own, the aggregation process is used. A relationship is
established and the resulting product is created into a new entity in order to create
aggregation between two entities that cannot be used for their individual qualities.
The relationship can be of any type, such as SUM, AVG, AND, OR, and so on.
Aggregation on tables can be done with a variety of tools available on the market.
When using numerical values as data, the following operations can be used to
perform DBMS aggregation:
 AVG: This function returns the mean or average of the data values.
 Sum: After the data values have been added, this function returns a total
value.
 Count: This field returns the number of records.
 Maximum (Max): This function returns the greatest value from a given set of
data.
 Minimum (Min): This function returns the smallest value in a given set of
data.

Example of Aggregation in DBMS


Assume a patient has visited a doctor in the hospital to seek treatment for a specific
type of illness. The process flow for aggregation in the hospital is depicted in the
diagram below.
For complete DBMS subject tutorials visit : ns lectures youtube channel

We will use the simple ER model described above. There are three entities in the
diagram above: patient history, doctor, and patient. Filing and diagnosis are
examples of relationships. The patient is diagnosed by the doctor.
The database stores information about this diagnosis as well as any other patient
information. Filing is required to make it easier for the doctor to retrieve the patient’s
information in the future. In this case, the patient is unable to work alone. To get a
diagnosis, he needs to build a relationship with the doctor. A diagnosis cannot be
made by the doctor without the presence of the patient. In the future, the doctor will
need information about the patient’s history, which he will have to gather from a filing
system.
The final entity (the patient’s history) ensures that the system as a whole is
operational. Without a doctor’s diagnosis and a filing system, obtaining the patient’s
history is impossible.

When Aggregation in DBMS is Used?


Aggregation in dbms is used when you need to summarize or analyze data from a
database. Some common use cases for aggregation in DBMS include:
 Generating reports: Aggregation functions can be used to summarize data
and generate reports for various business purposes.
 Business intelligence: Aggregation functions are used in business
intelligence applications to analyze large datasets and extract insights.
 Statistical analysis: Aggregation functions can be used in statistical analysis
to calculate measures of central tendency, such as the mean, median or
mode.
 Data visualization: Aggregated data can be visualized in charts and graphs
to provide a better understanding of the underlying trends and patterns.
 Many insignificant entities: A DBMS may contain many insignificant entities
that do not provide meaningful information. In this case, the trivial entities can
be aggregated into a single complex entity. For example, many insignificant
entities known as rooms can be combined to form a single entity known as a
hotel.
For complete DBMS subject tutorials visit : ns lectures youtube channel

In aggregation, the relation between two entities is treated as a single entity. In


aggregation, relationship with its corresponding entities is aggregated into a higher
level entity.
Example 2: Center entity offers the Course entity act as a single entity in the
relationship which is in a relationship with another entity visitor. In the real world, if a
visitor visits a coaching center then he will never enquiry about the Course only or
just about the Center instead he will ask the enquiry about both.

example-3:

Consider a ternary relationship Works_On between Employee, Branch and Manager.


Now the best way to model this situation is to use aggregation, So, the relationship-
set, Works_On is a higher level entity-set. Such an entity-set is treated in the same
manner as any other entity-set. We can create a binary relationship, Manager,
between Works_On and Manager to represent who manages what tasks.
Difference between Generalization and Specialization and Aggregation in
DBMS :
The difference between Generalization and Specialization are:-
For complete DBMS subject tutorials visit : ns lectures youtube channel

Generalization in DBMS Specialization in DBMS Aggregation in DBMS

Generalization is the
process of defining a higher-
Specialization is the Aggregation is the process of
level entity that
process of defining one combining two or more entities
encompasses two or more
or more sub-entities from into a single entity.
lower-level entities that
a single entity.
share common attributes or
characteristics.
The purpose of
The purpose of
specialization is to divide
generalization is to simplify The purpose of aggregation is to
a more generic entity into
the database structure by combine entities into a higher-
more specific entities that
grouping similar entities into level concept.
have unique attributes or
a more generic entity.
characteristics.
An example of
An example of
generalization in an
specialization in the same An example of aggregation in the
employee database is to
database would be to same database would be to
define a more generic entity
divide the "employee" combine the "department" entity
called "employee" that
entity into sub-entities and the "employee" entity into a
includes all types of
such as new entity called "department-
employees such as
"manager,""clerk," and employee."
managers, clerks, and
"executive."
executives.
Generalization, Specialization example:
For complete DBMS subject tutorials visit : ns lectures youtube channel

Class hierarchy:
the concepts of Generalization, Specialization and Aggregation are the class
hierarchies of “is a” relationship.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Class hierarchy can be viewed one of two ways

 Specialization (Top Down Approach)


 Generalization (Bottom Up Approach)
For complete DBMS subject tutorials visit : ns lectures youtube channel
For complete DBMS subject tutorials visit : ns lectures youtube channel

Database Languages (or) query languages (or)


data query languages (or) sql languages
Database languages are programming languages that developers use to interact
with databases. A database is a collection of organized data that can be accessed
electronically. These languages help users perform various tasks like controlling
access to data, defining and updating data, and searching for information within the
database.

A database management system (DBMS) is a technology that interacts with users,


applications, and the database itself. It records and analyzes data and allows users
to store, access, and retrieve data efficiently.

syntax to create database :

CREATE database database_name;

Example:

CREATE database college;

Above command will create database with name college

syntax to use database :

Before you create any table inside database at first you need to use that database ,
so that whatever the table you create, that table will be stored in that particular
database.

Syntax:

Use database_name;

Example:

Use college;

syntax to delete database :

we can delete database using drop command

syntax:

Drop database database_name;

Example:

Drop database college;

The DBMS provides specific database languages that enable users to express their
needs to update or retrieve data. One popular example is SQL, which is widely used
as the standard programming language for many databases.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Database languages consist of four sub-languages that serve different functions to


carry out tasks. These sub-languages help users communicate their requirements to
the DBMS effectively.

4 categories of database languages:

1. Data definition language (DDL):


Data Definition Language (DDL) is a type of database language that helps create the
basic framework of a database. It is used to define the structure of the database,
which includes things like tables, files, indexes, and columns.

DDL statements are used to perform various actions, such as creating new objects in
the database, altering existing objects, deleting objects, or renaming them.

Here's a simplified explanation of DDL statements:

a) CREATE: It is used to create new objects in the database, like tables, indexes, or
columns.

Syntax for creating a new table:

CREATE TABLE table_name (

column1 datatype,

column2 datatype,

...

);

Example:

CREATE TABLE students (

rollno INT,

name VARCHAR(50),
For complete DBMS subject tutorials visit : ns lectures youtube channel

age INT

);

b) ALTER: The ALTER command is used to modify the structure or properties of


existing database objects. It allows you to make changes to tables, columns,
indexes, constraints, and other elements.

Syntax for altering an existing table:

ALTER TABLE table_name

ADD column column_name datatype;

Example:

ALTER TABLE students

ADD column backlogs INT;

Syntax for modifying a column:

ALTER TABLE table_name

MODIFY column_name new_datatype;

Example:

ALTER TABLE students

MODIFY COLUMN backlogs INT;

Syntax for deleting a column:

ALTER TABLE table_name

DROP COLUMN column_name;

Example:

ALTER TABLE students

DROP COLUMN backlogs INT;

Syntax for renaming a column:

ALTER TABLE table_name

RENAME COLUMN old_column_name TO new_column_name;

Example:

ALTER TABLE students

RENAME COLUMN name TO stdname;


For complete DBMS subject tutorials visit : ns lectures youtube channel

c) DROP: In a database management system (DBMS), the DROP command is used


to remove or delete database objects. It allows you to eliminate tables, indexes,
views, or other database

Syntax for dropping a table:

DROP TABLE table_name;

Example:

DROP TABLE students;

d)TRUNCATE: The TRUNCATE command is used to quickly and efficiently remove


all data from a table in a database.

Syntax for removing all data from a table:

TRUNCATE TABLE table_name;

Example:

TRUNCATE TABLE students;

e) RENAME: The RENAME statement in DDL allows you to change the name of an
existing table.

Syntax for renaming a table:

RENAME TABLE old_table_name TO new_table_name;

Example:

RENAME TABLE students TO cse_students;

2. Data manipulation language (DML):


Data manipulation language (DML) is a type of programming language that allows
users to interact with and manipulate the data stored in a database. It provides
commands for inserting, updating, deleting, and retrieving data. Here's a simplified
explanation of DML statements:

a) INSERT: The INSERT statement is used to add new data into an existing
database table. It allows users to insert new records or rows with specified values
into the table.

Syntax for inserting data into a table:


INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
Example:
INSERT INTO students (name,rollno, section) VALUES (“sai”, 25,”A”);
b) UPDATE: The UPDATE statement is used to modify or update existing data in the
table. It allows users to change the values of specific columns in one or more rows.
For complete DBMS subject tutorials visit : ns lectures youtube channel

Syntax for updating data in a table:


UPDATE table_name SET column1 = new_value1, column2 = new_value2
Example:
UPDATE students SET name = “nagendra” WHERE rollno = 25;
c) DELETE: The DELETE statement is used to remove records or rows from the
table. It allows users to delete specific rows based on specified conditions.

Syntax for deleting data from a table:


DELETE FROM table_name WHERE condition;
Example:
DELETE FROM employees WHERE age > 30;
d) SELECT: The SELECT statement is used to retrieve data from the table or
multiple tables. It allows users to query the database and retrieve specific data
based on specified criteria.

Syntax for retrieving data from a table:


SELECT column1, column2, ... FROM table_name WHERE condition;
To retrieve the names of all employees from the "employees" table:
SELECT name FROM employees;

3. Transaction control language (TCL):


Transaction control language (TCL) is a set of commands used to manage
transactions within a database. Transactions group multiple database operations into
a single logical unit. Here's a simplified explanation of the TCL statements:

Command to start transaction: START TRANSACTION;

a) COMMIT: The COMMIT statement is used to make changes permanent and


finalize a transaction. When a COMMIT is issued, all the changes made within the
transaction are saved in the database.

Syntax:

commit;

Example:

start transaction;

create database college;

use college;

create table if not exists students(name text, rollno int primary key);
For complete DBMS subject tutorials visit : ns lectures youtube channel

commit;

INSERT INTO students VALUES (“sai”, 25,”A”),(“shiva”,26,”B”);

commit;

In the above example after creating table with name students and inserting data in
my table I written ‘ commit’, only if I write commit, even if I close my application(
mysql software) , my table and data will be permanently stored in my database. Or
else if you don’t use “commit” data will be permanently deleted once if you close
application

b) ROLLBACK: The ROLLBACK statement is used to undo or cancel a transaction.


If any part of the transaction encounters an error or fails to execute, the ROLLBACK
command restores the database to its state before the transaction started, effectively
undoing all the changes made.

Syntax: rollback;

Example:

start transaction;

create database college;

use college;

create table if not exists students(name text, rollno int primary key);

rollback;

note:

rollback will undo above transaction i.e.., it will not create table

c) SAVEPOINT: The SAVEPOINT statement sets a named point within a


transaction. It allows you to create intermediate markers to save the progress of a
transaction. If subsequent operations encounter issues, you can use the ROLLBACK
TO SAVEPOINT command to rollback the transaction to a specific savepoint,
discarding changes made after that point.

Syntax: SAVEPOINT savepoint_name;

4. Data control language (DCL):


Data Control Language (DCL) is a type of database language that controls the
access and permissions to data stored in a database. It manages the rights and
privileges within the database system. DCL statements are used to grant or revoke
permissions for users.

Certainly! Here are simplified syntax examples for the GRANT and REVOKE
commands in SQL:
For complete DBMS subject tutorials visit : ns lectures youtube channel

a) GRANT Command:

The GRANT command is used to grant specific privileges or permissions to users or


roles in a database.

Syntax for granting privileges:

GRANT privilege1, privilege2, ... ON table_name TO user_or_role;

b) REVOKE Command:

The REVOKE command is used to revoke previously granted privileges or


permissions from users or roles in a database.

Syntax for revoking privileges:

REVOKE privilege1, privilege2, ... ON table_name FROM user_or_role;


Coneptu dei a the ERMt

Lonceptusk dotign is he Secornd phole in the chlobne


desan
vort ehoicos staribute 2
o
omodeled os, on ntity
shauld Contapt he or relaionShip
relahmShip
modeled o an 'ontity
shdd a Conast be
toemary
hul (ontapt e modele: oanbinary

an tagvéaotien or
modled as
Sheuldo (ontapt e
ternory velotonShip 2

entySets:
Atbute
a tbute
whle icentying he
whety a propeihy
t Sornarbrnas ot cleov
of o
radesed
mdeed a on acttibute

Cons de adling
an
errtty Set to etompde
addrs iotmatiro othe y enbty Ct

e oddak al an attibute

eing an Atnbute:
va abte we naedb vetord
my One
ddossG allva: kydevabad) per
employo
cees
vnpp (Crlane)
Mploy4

ng htty

T w hove vetol addresles per employe

hose noa-96 e...), hen addr!


mut be an entty
T e chure CtHy Stoat,etr.)
importantt addves mue be modeled ol

(rDEronu) C hreut) kayeno)

Epays. Ho Addren

et V Yelohomskip

GnaabpetDPe
manoges Deportrrut
St (onstste Ttultos ondi
he en
afsorlate eloenp DYXornple
ith
a odatee with
alocatec
eb tie
enbstie
ond epostrmant oha me
ploye
yployee

dah otheh
manoged yekonSksp.
w
w i th
h
is oocioleed
O4Socottd

elhonSp
o Managas
noal th empley
manegoY beCat
Con (reobe
will
mamge buelgeE So we

n Stead relationskhp
monage an
er TA kep
staish
nd we nded

enbte
nd
manage y
poyee

ermplunryes
ASA
ncr
Dpld p t r o
Singd b u k

fortment

monaq
ina Ve n elahoSp
nachu
Yelshonskips Searns
Agh biney
Senehenos
in caltty it
ertbes
neces Souy to Cooneet hvee oore

onn ect hvn entite

ernyelaenSps eguwred

whn
ino veehorSkpe

attuvetely/ desribe the Sermantics


h r e esutey
on

Tor example
h a aa bole r a Connpon
uppose y
PRODUC
artank he tst hy
might be
SupPER he uyelaionSkps might be
PRopu SorPER we ta lompan

pctssocoapphertt a
Pracbets
rom

relatinskp. intersethrn. artmbute


oinany

PRODUct/SuPPuER ishlessle.prs
Splitnem o

Sppler

wesprte

enti ad hat

wtruYbuy produc. utomaypa


ome Poce o a
PrDelues Yecordle1

Sappes Simple bina


bchween (uSToMER andRoDuT

USTOMER PAoDUdelshmSkp

intrseetion atnbute is retallpn'tR


ro ( T
(Produt-j).
raluwt nort)
wtomey

( Yetal-Pie

ternon, Yelahionsp'
inqye
(onside C A4*na C nano

o Surphra utoma

pyodw
Procuut bosed on a
i e , So insttsd

2ttng binom latm Sept

Suphevd-predut nd (utumas

Produt, weon otoblsh


toney elatienShop behoan odwt

Splie-(hm hotwi ho
intr'section Aue piaCPp
( PAa
Podu
Suppe
o d u t i ( P r o s u u t - r e r r e

(ustver id
For complete DBMS subject tutorials visit : ns lectures youtube channel

1. ER Diagram of Company
For complete DBMS subject tutorials visit : ns lectures youtube channel

2. ER Diagram for Library Management System


For complete DBMS subject tutorials visit : ns lectures youtube channel

3. ER Diagram for online Shopping


For complete DBMS subject tutorials visit : ns lectures youtube channel

4. ER Diagram for hospital management system

5. ER Diagram for University management system


For complete DBMS subject tutorials visit : ns lectures youtube channel

6. ER Diagram for hotel management system

7. ER Diagram for Bank management system


ER diagram of Bank has the following description :

 Bank have Customer.


 Banks are identified by a name, code, address of main office.
 Banks have branches.
 Branches are identified by a branch_no., branch_name, address.
 Customers are identified by name, cust-id, phone number, address.
 Customer can have one or more accounts.
 Accounts are identified by account_no., acc_type, balance.
 Customer can avail loans.
 Loans are identified by loan_id, loan_type and amount.
 Account and loans are related to bank’s branch.

ER Diagram of Bank Management System :


For complete DBMS subject tutorials visit : ns lectures youtube channel

This bank ER diagram illustrates key information about bank, including entities such
as branches, customers, accounts, and loans. It allows us to understand the
relationships between entities.
Entities and their Attributes are :

 Bank Entity : Attributes of Bank Entity are Bank Name, Code and Address.
Code is Primary Key for Bank Entity.
 Customer Entity : Attributes of Customer Entity are Customer_id, Name, Phone
Number and Address.
Customer_id is Primary Key for Customer Entity.
 Branch Entity : Attributes of Branch Entity are Branch_id, Name and Address.
Branch_id is Primary Key for Branch Entity.
 Account Entity : Attributes of Account Entity are Account_number,
Account_Type and Balance.
Account_number is Primary Key for Account Entity.
 Loan Entity : Attributes of Loan Entity are Loan_id, Loan_Type and Amount.
Loan_id is Primary Key for Loan Entity.
Relationships are :

 Bank has Branches => 1 : N


One Bank can have many Branches but one Branch can not belong to many
Banks, so the relationship between Bank and Branch is one to many relationship.
For complete DBMS subject tutorials visit : ns lectures youtube channel

 Branch maintain Accounts => 1 : N


One Branch can have many Accounts but one Account can not belong to many
Branches, so the relationship between Branch and Account is one to many
relationship.

 Branch offer Loans => 1 : N


One Branch can have many Loans but one Loan can not belong to many
Branches, so the relationship between Branch and Loan is one to many
relationship.

 Account held by Customers => M : N


One Customer can have more than one Accounts and also One Account can be
held by one or more Customers, so the relationship between Account and
Customers is many to many relationship.

 Loan availed by Customer => M : N


(Assume loan can be jointly held by many Customers).
One Customer can have more than one Loans and also One Loan can be availed
by one or more Customers, so the relationship between Loan and Customers is
many to many relationship.

8. ER Diagram for Railway reservation system

.
For complete DBMS subject tutorials visit : ns lectures youtube channel

9. ER Diagram for Car Rental system

10. ER Diagram for Car insurance company


For complete DBMS subject tutorials visit : ns lectures youtube channel

UNIT-1

IMPORTANT QUESTIONS
1. What is database and DBMS?
2. Explain Characteristics/ features, Database tasks, Advantages, Disadvantages,
Applications, history of DBMS?
3. Explain Difference between file system and DBMS?
4. Explain Various Data Models in DBMS? (Hint :- Hierarchical Model, Network Model,
Entity-Relationship Model, Relational Model, Object-Oriented Data Model, Object-Relational
Data Model, Flat Data Model , Semi-Structured Data Model)
5. What is Schema and Data Abstraction in DBMS?
6. What are various Levels of abstraction for DBMS (or) three levels of the schema (or) Three
tier schema Architecture ?
7. What is Data Independence ? Explain Difference between Physical and Logical data
independence ?
8. What is an instance ?
9. Explain DBMS Architecture and types of DBMS Architectures ?( hint: 1- tier, 2- tier, 3- tier )
10. Explain Database System architecture and various components we use in this database
system architecture in detail.
11. What are Six steps of Database design process and which steps are relevant to ER model?
12. Why Use ER Diagrams In DBMS? Various Symbols Used in ER Model and The components
/features of an ER diagram?
13. Explain entities and types of entities, entity set , attributes and types of attributes,
relationship, relationship set, Degree of a Relationship Set (or) Types of Relationship Sets?
14. What are Cardinality Constraints? types of constraints on the Entity Relationship (ER)
model?(hint :- Mapping cardinality or cardinality ratio, Participation constraints)
15. Explain various types of constraints In an Entity-Relationship (ER) model?
16. Generalization, Specialization and Aggregation in ER Model with an examples?
17. What is Class hierarchy? Define SQL? Explain how to convert ER Model to a Relational Model
with an example?
18. What are Database Languages (or) query languages (or) data query languages (or) sql
languages? ( hint: DDL, DML, DCL, TCL )
19. Explain Difference between entity and Attribute, Entity set vs Relationship set, Binary vs
ternary relationship
20. Draw ER Diagram for
a) Company
b) Library Management System
c) online Shopping
d) hospital management system
e) University management system
f) hotel management system
g) Bank management system
h) Railway reservation system
i) Car Rental system
j) Car insurance company

You might also like