DBMS Unit 1 Notes
DBMS Unit 1 Notes
Database
A database is a collection of data, typically describing the activities of one or more related
organizations.
1. It is a software system that manages 1. It is a software system used for creating and managing the
and controls the data files in a computer databases. DBMS provides a systematic way to access, update,
system. and delete data.
5. File system is used for storing the 5. Database management system is used for storing the
unstructured data. structured data.
9. Cost of a file system is less than the 9. Cost of database management system is more than the file
DBMS. system.
10. If one application fails, it does not 10. If the database fails, it affects all application which depends
affect other application in a system. on it.
11. In the file system, data cannot be
11. In DBMS, data can be shared as it is stored at one place in a
shared because it is distributed in
database.
different files.
ADVANTAGES OF A DBMS
Data Independence: The DBMS provides an abstract view of the data that hides data
representation and storage details.
Efficient Data Access: A DBMS utilizes a variety of sophisticated techniques to store and
retrieve data efficiently.
Data Integrity and Security: If data is always accessed through the DBMS, the DBMS can
enforce integrity constraints. For example, before inserting salary information for an employee,
the DBMS can check that the department budget is not exceeded. Also, it can enforce access
controls that govern what data is visible to different classes of users.
Data Administration: When several users share the data, centralizing the administration of data
can offer significant improvements.
Concurrent Access and Crash Recovery: A DBMS schedules concurrent accesses to the data
in such a manner that users can think of the data as being accessed by only one user at a time.
Further, the DBMS protects users from the effects of system failures.
Reduced Application Development Time: The high-level interface to the data, facilitates quick
application development.
DATA MODEL
● A data model is a collection of high-level data description constructs that hide many
low-level storage details.
● A DBMS allows a user to define the data to be stored in terms of a data model.
● Most database management systems today are based on the relational data model.
● A semantic data model is a more abstract, high-level data model that makes it easier for
a user to come up with a good initial description of the data in an enterprise.
● A widely used semantic data model called the entity-relationship (ER) model allows us to
pictorially denote entities and the relationships among them.
● The central data description construct in this model is a relation, which can be thought of
as a set of records.
● A description of data in terms of a data model is called a schema.
● In the relational model, the schema for a relation specifies its name, the name of each
field (or attribute or column), and the type of each field.
● Students ( sid: string, name: string, login: string, age: integer, gpa: real)
Entity-Relationship Model
● 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.
● The real-world problems are more closely represented through the object-oriented data
model.
● In this model, both the data and relationship are present in a single structure known as an
object.
● We can store audio, video, images, etc in the database which was not possible in the
relational model (although you can store audio and video in relational database, it is
advised not to store in the relational database).
● In this model, two are more objects are connected through links. We use this link to relate
one object to other object.
Hierarchical Model
● 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.
Network Model
Logical level: describes data stored in database, and the relationships among the data.
View level: application programs hide details of data types. Views can also hide information
(such as an employee’s salary) for security purposes.
DATA INDEPENDENCE
The ability to modify the schema in one level without affecting the schema in next higher level is
called data independence.
• Logical data independence: The ability to modify the logical schema without affecting
the schema in next higher level (external schema.)
• Physical Data Independence – the ability to modify the physical schema without
changing the logical schema
STRUCTURE OF DBMS
● A database system is partitioned into modules that deal with each of the responsibilities
of the overall system.
● The functional components of a database system can be broadly divided into the storage
manager and the query processor components.
● The storage manager is important because databases typically require a large amount of
storage space.
● The query processor is important because it helps the database system to simplify and
facilitate access to data.
● 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.
1. Query Processor:
It interprets the requests (queries) received from end user via an application program into
instructions. It also executes the user request which is received from the DML compiler.
● DML Compiler –
It processes the DML statements into low level instruction (machine language), so
that they can be executed.
● DDL Interpreter –
It processes the DDL statements into a set of table containing meta data (data
about data).
● Embedded DML Pre-compiler –
It processes DML statements embedded in an application program into procedural
calls.
● Query Optimizer –
It executes the instruction generated by DML Compiler.
2. Storage Manager :
● Storage Manager is a program that provides an interface between the data stored in the
database and the queries received.
● It is also known as Database Control System.
● It maintains the consistency and integrity of the database by applying the constraints and
executes the DCL statements.
● It is responsible for updating, storing, deleting, and retrieving data in the database.
● Authorization Manager –
It ensures role-based access control, i.e. it checks whether the particular person is privileged
to perform the requested operation or not.
● Integrity Manager –
It checks the integrity constraints when the database is modified.
● Transaction Manager –
It controls concurrent access by performing the operations in a scheduled way that it receives
the transaction. Thus, it ensures that the database remains in the consistent state before and
after the execution of a transaction.
● File Manager –
It manages the file space and the data structure used to represent information in the database.
● Buffer Manager –
It is responsible for cache memory and the transfer of data between the secondary storage
and main memory.
3. Disk Storage:
It contains the following components –
Data Files –
It stores the data.
● Data Dictionary –
It contains the information about the structure of any database object. It is the repository of
information that governs the metadata.
● Indices –
It provides faster retrieval of data item.
Data Handling:
• Each company's success today revolves around massive databases.
• Companies nowadays maintain massive databases containing unstructured data types
such as images, documents, or sound and video files.
Monitoring Performance:
• Only implementing a database is not the task of the database administrator.
• Once the database is implemented, they are required to monitor databases for
performance issues. If a system component slows down processing, the DBA may need
to change the software configuration or add more hardware capacity.
Database Security:
• One of the most critical responsibilities of a DBA is identifying and correcting any flaws
in the database software.
• No system is entirely secure; however, DBAs mitigate risks by implementing best
practices.
2. Database Designers:
• Database designers design the appropriate structure for the database, where we share
data.
3. System Analyst:
• System analyst analyses the requirements of end users, especially naïve and parametric
end users.
4. Application Programmers:
• Application programmers are computer professionals, who write application programs.
6. Sophisticated Users:
• Sophisticated users can be engineers, scientists, business analyst, who are familiar with
the database. These users interact with the database but they do not write programs
It provides useful concepts that allow us to move front an informal description of what users
want from their database to a more detailed, precise description that can be implemented in a
DBMS.
The database design process can be divided into six steps. The ER model is most relevant to the
first three steps.
Beyond ER Design
4. Schema Refinement: The fourth step ill database design is to analyze the collection of
relations in our relational database schema to identify potential problems, and to refine it.
5. Physical Database Design: In this step, we consider typical expected workloads that our
database must support and further refine the database design to ensure that it meets desired
performance criteria.
6. Application and Security Design: Any software project that involves a DBMS must
consider aspects of the application that go beyond the database itself.
In this database model, relationships are created by dividing object of interest into entity and its
characteristics into attributes.
Basic Concepts of ER Model in DBMS
As we described in the tutorial Database models, Entity-relationship model is a model used for
design and representation of relationships between data.
The main data objects are termed as Entities, with their details defined as attributes, some of
these attributes are important and are used to identify the entity, and different entities are related
using relationships.
● An entity is an object that exists and is distinguishable from other objects.
– Examples:
• Person: PROFESSOR, STUDENT
• Place: STORE, UNIVERSITY
• Object: MACHINE, BUILDING
• Event: SALE, REGISTRATION
● An entity set is a set of entities of the same type that share the same properties.
ATTRIBUTES
Example:
1. Simple attribute: The attributes with values that are atomic and cannot be broken down
further are simple attributes. For example, student's age.
2. Composite attribute: A composite attribute is made up of more than one simple attribute.
For example, student's address will contain, house no., street name, pin code etc.
3. Derived attribute: These are the attributes which are not present in the whole database
management system, but are derived using other attributes. For example, average age of
students in a class.
Example: age, and its value is derived from the stored attribute Date of Birth.
4. Single-valued attribute: As the name suggests, they have a single value.
Relationship
• Named set of all similar relationships with the same attributes and relating to the same
entity types
• Relationship is represented with DIAMOND
Teaches
• Relationships relate entities within the entity sets involved in the relationship type to each
other.
ER – Relationships
Types of Relationships
• Many-to-many relationship (M:N): exists when one instance of the first entity (parent)
can relate to many instances of the second entity (child), and one instance of the second
entity can relate to many instances of the first entity.
ER Diagram: Relationship
1. Binary Relationship
2. Recursive Relationship
3. Ternary Relationship
1.Binary Relationship
Binary Relationship means relation between two Entities. This is further divided into three types.
One to One Relationship
The above example describes that one student can enroll only for one course and a course will
also have only one Student. This is not what you will usually see in real-world relationships.
The below example showcases this relationship, which means that 1 student can opt for many
courses, but a course can only have 1 student. Sounds weird! This is how it is.
It reflects business rule that many entities can be associated with just one entity. For example,
Student enrolls for only one Course but a Course can have many Students.
A many-to-many relationship occurs when multiple records in a table are associated with
multiple records in another table.
2.Recursive Relationship
3. Ternary Relationship
Strong Entity
The Strong Entity is the one whose existence does not depend on the existence of any other
entity in a schema. It is denoted by a single rectangle. A strong entity always has the primary key
in the set of attributes that describes the strong entity. It indicates that each entity in a strong
entity set can be uniquely identified.
Set of similar types of strong entities together forms the Strong Entity Set. A strong entity holds
the relationship with the weak entity via an Identifying Relationship, which is denoted by double
diamond in the ER diagram. On the other hands, the relationship between two strong entities is
denoted by a single diamond and it is simply called as a relationship.
Weak Entity
A Weak entity is the one that depends on its owner entity i.e. a strong entity for its existence. A
weak entity is denoted by the double rectangle. Weak entities do not have the primary key
instead it has a partial key that uniquely discriminates the weak entities. The primary key of a
weak entity is a composite key formed from the primary key of the strong entity and partial key
of the weak entity.
The collection of similar weak entities is called Weak Entity Set. The relationship between a
weak entity and a strong entity is always denoted with an Identifying Relationship i.e. double
diamond.
Total participation
Partial participation
1. Total Participation
• It specifies that each entity in the entity set must compulsorily participate in at least one
relationship instance in that relationship set.
• That is why, it is also called as mandatory participation.
• Total participation is represented using a double line between the entity set and
relationship set.
● Double line between the entity set “Student” and relationship set “Enrolled in” signifies total
participation.
● It specifies that each student must be enrolled in at least one course.
2. Partial Participation
• It specifies that each entity in the entity set may or may not participate in the relationship
instance in that relationship set.
• That is why, it is also called as optional participation.
• Partial participation is represented using a single line between the entity set and
relationship set.
● Single line between the entity set “Course” and relationship set “Enrolled in” signifies partial
participation.
● It specifies that there might exist some courses for which no enrollments are made.
1. Generalization – generalization is relationship that exist between higher level entity set and
one or more lower level entity sets. Generalization synthesizes these entity sets into single
entity set.
2.Specialization – The process of designating to sub grouping within an entity set is called
specialization.
3.Aggregation: there is a one limitation with E-R model that it cannot express relationships
among relationships. So aggregation is an abstraction through which relationship is treated
as higher level entities.
• Works_In4 does not allow an employee to work in a department for two or more periods.
• Similar to the problem of wanting to record several addresses for an employee:
We want to record several values of the descriptive attributes for each
instance of this relationship. Accomplished by introducing new entity set, Duration.
• First ER diagram OK if a manager gets a separate discretionary budget for each dept.
• What if a manager gets a discretionary budget that covers all managed depts?
• If each policy is owned by just 1 employee, and each dependent is tied to the covering
policy, first diagram is inaccurate.
• Previous example illustrated a case when two binary relationships were better than one
ternary relationship.
• An example in the other direction: a ternary relation Contracts relates entity sets Parts,
Departments and Suppliers, and has descriptive attribute qty.
– S “can-supply” P, D“needs” P, and D“deals- with” S does not imply that D has
agreed to buy P from S.
–
d. Aggregation v/s ternary relationship
• The choice may also be guided by certain integrity constraints that we want to express.