DBMS Notes by Sanju
DBMS Notes by Sanju
Source links
File System vs DBMS: Key Differences (guru99.com)
What is DBMS?
Database Management System (DBMS) is a software for storing and retrieving
user’s data while considering appropriate security measures. It consists of a group
of programs that manipulate the database. The DBMS accepts the request for
data from an application and instructs the DBMS engine to provide the specific
data. In large systems, a DBMS helps users and other thirdparty software to store
and retrieve data.
KEY DIFFERENCES:
• A file system is a software that manages and organizes the files in a storage
medium, whereas DBMS is a software application that is used for accessing,
creating, and managing databases.
• The file system doesn’t have a crash recovery mechanism on the other hand,
DBMS provides a crash recovery mechanism.
• Data inconsistency is higher in the file system. On the contrary Data
inconsistency is low in a database management system.
• File system does not provide support for complicated transactions, while in the
DBMS system, it is easy to implement complicated transactions using SQL.
• File system does not offer concurrency, whereas DBMS provides a concurrency
facility.
Features of a File system
Here are important elements of the file system:
• It helps you to store data in a group of files.
• Files data are dependent on each other.
• C/C++ and COBOL languages were used to design the files.
• Shared File System Support
• Fast File System Recovery.
Features of DBMS
Here, are essential features of DBMS:
• A user-accessible catalogue of data
• Transaction support
• Concurrency control with Recovery services
• Authorization services
• The value of data is the same at all places.
• Offers support for data communication
• Independent utility services
• Allows multiple users to share a file at the same time
5. Security
A DBA needs to know potential weaknesses of the database software and the
company’s overall system and work to minimise risks. No system is one hundred per
cent immune to attacks, but implementing best practices can minimise risks.
In the case of a security breach or irregularity, the DBA can consult audit logs to see
who has done what to the data. Audit trails are also important when working with
regulated data.
6. Authentication
Setting up employee access is an important aspect of database security. DBAs control
who has access and what type of access they are allowed. For instance, a user may
have permission to see only certain pieces of information, or they may be denied the
ability to make changes to the system.
7. Capacity Planning
The DBA needs to know how large the database currently is and how fast it is growing
in order to make predictions about future needs. Storage refers to how much room the
database takes up in server and backup space. Capacity refers to usage level.
If the company is growing quickly and adding many new users, the DBA will have to
create the capacity to handle the extra workload.
8. Performance Monitoring
Monitoring databases for performance issues is part of the on-going system
maintenance a DBA performs. If some part of the system is slowing down processing,
the DBA may need to make configuration changes to the software or add additional
hardware capacity. Many types of monitoring tools are available, and part of the DBA’s
job is to understand what they need to track to improve the system. 3rd party
organisations can be ideal for outsourcing this aspect, but make sure they offer modern
DBA support.
9. Database Tuning
Performance monitoring shows where the database should be tweaked to operate as
efficiently as possible. The physical configuration, the way the database is indexed, and
how queries are handled can all have a dramatic effect on database performance.
With effective monitoring, it is possible to proactively tune a system based on
application and usage instead of waiting until a problem develops.
10. Troubleshooting
DBAs are on call for troubleshooting in case of any problems. Whether they need to
quickly restore lost data or correct an issue to minimise damage, a DBA needs to
quickly understand and respond to problems when they occur.
If you would like to know more about what the Oracle Support & SQL Server
Support DBAs do here at DSP-Explorer, then please get in touch with us.
DBMS Architecture
• 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.
• The client/server architecture consists of many PCs and a
workstation which are connected via the network.
• DBMS architecture depends upon how users are connected
to the database to get their request done.
Types of DBMS Architecture
2Tier Architecture
• The 2Tier architecture is same as basic clientserver. In the
twotier 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.
• The user interfaces and application programs are run on the
clientside.
• The server side is responsible to provide the functionalities
like: query processing and transaction management.
• To communicate with the DBMS, clientside application
establishes a connection with the server side.
Data Independence
A database system normally contains a lot of data in
addition to users’ data. For example, it stores data about
data, known as metadata, to locate and retrieve data
easily. It is rather difficult to modify or update a set of
metadata once it is stored in the database. But as a DBMS
expands, it needs to change over time to satisfy the
requirements of the users. If the entire data is dependent,
it would become a tedious and highly complex job.
Metadata itself follows a layered architecture, so that when
we change data at one layer, it does not affect the data at
another level. This data is independent but mapped to
each other.
From
<https://www.tutorialspoint.com/dbms/dbms_quick_guide.ht
m>
Data Models
Data Model is the modeling of the data description, data semantics,
and consistency constraints of the data. It provides the conceptual tools
for describing the design of a database at each level of data abstraction.
Therefore, there are following four data models used for understanding
the structure of the database:
1) Relational Data Model: This type of model designs the data in the
form of rows and columns within a table. Thus, a relational model uses
tables for representing data and inbetween relationships. Tables are
also called relations. This model was initially described by Edgar F.
Codd, in 1969. The relational data model is the widely used model
which is primarily used by commercial data processing applications.
ACID Properties
The expansion of the term ACID defines for:
1) Atomicity: The term atomicity defines that the data remains atomic.
It means if any operation is performed on the data, either it should be
performed or executed completely or should not be executed at all. It
further means that the operation should not break in between or
execute partially. In the case of executing operations on the transaction,
the operation should be completely executed and not partially.
In the above diagram, it can be seen that after crediting $10, the
amount is still $100 in account B. So, it is not an atomic transaction.
The below image shows that both debit and credit operations are done
successfully. Thus the transaction is atomic.
Thus, when the amount loses atomicity, then in the bank systems, this
becomes a huge issue, and so the atomicity is the main focus in the
bank systems.
2) Consistency: The word consistency means that the value should
remain preserved always. In DBMS, the integrity of the data should be
maintained, which means if a change in the database is made, it should
remain preserved always. In the case of transactions, the integrity of
the data is very essential so that the database remains consistent
before and after the transaction. The data should always be correct.
Example:
ER model
• ER model stands for an EntityRelationship model. It is a
highlevel data model. This model is used to define the data
elements and relationship for a specified system.
• It develops a conceptual design for the database. It also
develops a very simple and easy to design view of data.
• In ER modeling, the database structure is portrayed as a
diagram called an entityrelationship diagram.
Component of ER Diagram
1. Entity:
An entity may be any object, class, person or place. In the ER
diagram, an entity can be represented as rectangles.
Consider an organization as an example manager, product,
employee, department etc. can be taken as an entity.
a. Weak Entity
An entity that depends on another entity called a weak entity.
The weak entity doesn't contain any key attribute of its own.
The weak entity is represented by a double rectangle.
2. Attribute
The attribute is used to describe the property of an entity.
Eclipse is used to represent an attribute.
For example, id, age, contact number, name, etc. can be
attributes of a student.
a. Key Attribute
The key attribute is used to represent the main characteristics
of an entity. It represents a primary key. The key attribute is
represented by an ellipse with the text underlined.
b. Composite Attribute
An attribute that composed of many other attributes is known
as a composite attribute. The composite attribute is
represented by an ellipse, and those ellipses are connected
with an ellipse.
c. Multivalued Attribute
An attribute can have more than one value. These attributes
are known as a multivalued attribute. The double oval is used
to represent multivalued attribute.
For example, a student can have more than one phone
number.
d. Derived Attribute
An attribute that can be derived from other attribute is known
as a derived attribute. It can be represented by a dashed
ellipse.
For example, A person's age changes over time and can be
derived from another attribute like Date of birth.
3. Relationship
A relationship is used to describe the relation between entities.
Diamond or rhombus is used to represent the relationship.
b. Onetomany relationship
When only one instance of the entity on the left, and more
than one instance of an entity on the right associates with the
relationship then this is known as a onetomany relationship.
For example, Scientist can invent many inventions, but the
invention is done by the only specific scientist.
c. Manytoone relationship
When more than one instance of the entity on the left, and
only one instance of an entity on the right associates with the
relationship then it is known as a manytoone relationship.
For example, Student enrolls for only one course, but a course
can have many students.
d. Manytomany relationship
When more than one instance of the entity on the left, and
more than one instance of an entity on the right associates with
the relationship then it is known as a manytomany
relationship.
For example, Employee can assign by many projects and
project can have many employees.
Notation of ER diagram
Database can be represented using the notations. In ER diagram, many notations are used to
express the cardinality. These notations are as follows:
ER Model Basic Concepts
The ER model defines the conceptual view of a database. It works around real-world
entities and the associations among them. At view level, the ER model is considered a
good option for designing databases.
Entity
An entity can be a real-world object, either animate or inanimate, that can be easily
identifiable. For example, in a school database, students, teachers, classes, and
courses offered can be considered as entities. All these entities have some attributes or
properties that give them their identity.
An entity set is a collection of similar types of entities. An entity set may contain entities
with attribute sharing similar values. For example, a Students set may contain all the
students of a school; likewise a Teachers set may contain all the teachers of a school
from all faculties. Entity sets need not be disjoint.
Attributes
Entities are represented by means of their properties, called attributes. All attributes
have values. For example, a student entity may have name, class, and age as
attributes.
There exists a domain or range of values that can be assigned to attributes. For
example, a student's name cannot be a numeric value. It has to be alphabetic. A
student's age cannot be negative, etc.
Types of Attributes
• Simple attribute − Simple attributes are atomic values, which cannot be divided
further. For example, a student's phone number is an atomic value of 10 digits.
• Composite attribute − Composite attributes are made of more than one simple
attribute. For example, a student's complete name may have first_name and
last_name.
• Derived attribute − Derived attributes are the attributes that do not exist in the
physical database, but their values are derived from other attributes present in the
database. For example, average_salary in a department should not be saved
directly in the database, instead it can be derived. For another example, age can
be derived from data_of_birth.
• Single-value attribute − Single-value attributes contain single value. For example −
Social_Security_Number.
• Multi-value attribute − Multi-value attributes may contain more than one values. For
example, a person can have more than one phone number, email_address, etc.
These attribute types can come together in a way like −
• simple single-valued attributes
• simple multi-valued attributes
• composite single-valued attributes
• composite multi-valued attributes
Entity-Set and Keys
Key is an attribute or collection of attributes that uniquely identifies an entity among
entity set.
For example, the roll_number of a student makes him/her identifiable among students.
• Super Key − A set of attributes (one or more) that collectively identifies an entity in
an entity set.
• Candidate Key − A minimal super key is called a candidate key. An entity set may
have more than one candidate key.
• Primary Key − A primary key is one of the candidate keys chosen by the database
designer to uniquely identify the entity set.
Relationship
The association among entities is called a relationship. For example, an
employee works_at a department, a student enrolls in a course. Here, Works_at and
Enrolls are called relationships.
Relationship Set
A set of relationships of similar type is called a relationship set. Like entities, a
relationship too can have attributes. These attributes are called descriptive attributes.
Degree of Relationship
The number of participating entities in a relationship defines the degree of the
relationship.
• Binary = degree 2
• Ternary = degree 3
• n-ary = degree
Mapping Cardinalities
Cardinality defines the number of entities in one entity set, which can be associated with
the number of entities of other set via relationship set.
• One-to-one − One entity from entity set A can be associated with at most one
entity of entity set B and vice versa.
• One-to-many − One entity from entity set A can be associated with more than one
entities of entity set B however an entity from entity set B, can be associated with
at most one entity.
• Many-to-one − More than one entities from entity set A can be associated with at
most one entity of entity set B, however an entity from entity set B can be
associated with more than one entity from entity set A.
• Many-to-many − One entity from A can be associated with more than one entity
from B and vice versa.
ER Diagram Representation
Let us now learn how the ER Model is represented by means of an ER diagram. Any
object, for example, entities, attributes of an entity, relationship sets, and attributes of
relationship sets, can be represented with the help of an ER diagram.
Entity
Entities are represented by means of rectangles. Rectangles are named with the entity
set they represent.
Attributes
Attributes are the properties of entities. Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is directly connected to its entity (rectangle).
If the attributes are composite, they are further divided in a tree like structure. Every
node is then connected to its attribute. That is, composite attributes are represented by
ellipses that are connected with an ellipse.
Multivalued attributes are depicted by double ellipse.
• Many-to-one − When more than one instance of entity is associated with the
relationship, it is marked as 'N:1'. The following image reflects that more than one
instance of an entity on the left and only one instance of an entity on the right can
be associated with the relationship. It depicts many-to-one relationship.
• Many-to-many − The following image reflects that more than one instance of an
entity on the left and more than one instance of an entity on the right can be
associated with the relationship. It depicts many-to-many relationship.
Participation Constraints
• Total Participation − Each entity is involved in the relationship. Total participation is
represented by double lines.
• Partial participation − Not all entities are involved in the relationship. Partial
participation is represented by single lines.
Generalization Aggregation
Let us now learn how the ER Model is represented by means of an ER diagram. Any
object, for example, entities, attributes of an entity, relationship sets, and attributes of
relationship sets, can be represented with the help of an ER diagram.
Entity
Entities are represented by means of rectangles. Rectangles are named with the entity
set they represent.
Attributes
Attributes are the properties of entities. Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is directly connected to its entity (rectangle).
If the attributes are composite, they are further divided in a tree like structure. Every
node is then connected to its attribute. That is, composite attributes are represented by
ellipses that are connected with an ellipse.
Multivalued attributes are depicted by double ellipse.
• Many-to-one − When more than one instance of entity is associated with the
relationship, it is marked as 'N:1'. The following image reflects that more than one
instance of an entity on the left and only one instance of an entity on the right can
be associated with the relationship. It depicts many-to-one relationship.
• Many-to-many − The following image reflects that more than one instance of an
entity on the left and more than one instance of an entity on the right can be
associated with the relationship. It depicts many-to-many relationship.
Participation Constraints
• Total Participation − Each entity is involved in the relationship. Total participation is
represented by double lines.
• Partial participation − Not all entities are involved in the relationship. Partial
participation is represented by single lines.
Generalization Aggregation
The ER Model has the power of expressing database entities in a conceptual
hierarchical manner. As the hierarchy goes up, it generalizes the view of entities, and as
we go deep in the hierarchy, it gives us the detail of every entity included.
Going up in this structure is called generalization, where entities are clubbed together to
represent a more generalized view. For example, a particular student named Mira can
be generalized along with all the students. The entity shall be a student, and further, the
student is a person. The reverse is called specialization where a person is a student,
and that student is Mira.
Generalization
As mentioned above, the process of generalizing entities, where the generalized entities
contain the properties of all the generalized entities, is called generalization. In
generalization, a number of entities are brought together into one generalized entity
based on their similar characteristics. For example, pigeon, house sparrow, crow and
dove can all be generalized as Birds.
Specialization
Specialization is the opposite of generalization. In specialization, a group of entities is
divided into sub-groups based on their characteristics. Take a group ‘Person’ for
example. A person has name, date of birth, gender, etc. These properties are common
in all persons, human beings. But in a company, persons can be identified as employee,
employer, customer, or vendor, based on what role they play in the company.
Similarly, in a school database, persons can be specialized as teacher, student, or a
staff, based on what role they play in school as entities.
Inheritance
We use all the above features of ER-Model in order to create classes of objects in
object-oriented programming. The details of entities are generally hidden from the user;
this process known as abstraction.
Inheritance is an important feature of Generalization and Specialization. It allows lower-
level entities to inherit the attributes of higher-level entities.
For example, the attributes of a Person class such as name, age, and gender can be
inherited by lower-level entities such as Student or Teacher.
From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>