Class Notes DBMS 1
Class Notes DBMS 1
Introduction to Database
What is Database?
A database is an organized collection of data, generally stored and accessed
electronically from a computer system.
What is Data?
Data is a raw and unorganized fact that required to be processed to make it
meaningful. Data can be simple at the same time unorganized unless it is organized.
Generally, data comprises facts, observations, perceptions numbers, characters,
symbols, image, etc.
What is Information?
Information is a set of data which is processed in a meaningful way according to the
given requirement. Information is processed, structured, or presented in a given
context to make it meaningful and useful.
Information assigns meaning and improves the reliability of the data. It helps to ensure
undesirability and reduces uncertainty. So, when the data is transformed into
information, it never has any useless details.
Data vs Information
Page |2
Well-known DBMSs include MySQL, PostgreSQL, Microsoft SQL Server, Oracle, Sybase
and IBM DB2.
Database management systems are often classified according to the database model
that they support; the most popular database systems since the 1980s have all
supported the relational model as represented by the SQL language.
Application of DBMS
Sector Use of DBMS
End-Users The end users are the people who interact with the
database management system. They conduct various
operations on database like retrieving, updating,
deleting, etc.
Components of a DBMS
Buffer management
Stored data manager
DDL compiler
Interactive query interface
Query compiler
Query optimizer
Pre-compiler
Runtime database processor
System catalog
Concurrency control system
Backup and recovery system
Advantages of DBMS
DBMS offers a variety of techniques to store & retrieve data
DBMS serves as an efficient handler to balance the needs of multiple
applications using the same data
Uniform administration procedures for data
A DBMS uses various powerful functions to store and retrieve data efficiently.
Offers Data Integrity and Security
Page |5
The DBMS implies integrity constraints to get a high level of protection against
prohibited access to data.
A DBMS schedules concurrent access to the data in such a manner that only one
user can access the same data at a time
Reduced Application Development Time
Disadvantage of DBMS
DBMS may offer plenty of advantages but, it has certain flaws-
Cost of Hardware and Software of a DBMS is quite high which increases the
budget of your organization.
Most database management systems are often complex systems, so the training
for users to use the DBMS is required.
In some organizations, all data is integrated into a single database which can be
damaged because of electric failure or database is corrupted on the storage
media
Use of the same program at a time by many users sometimes lead to the loss of
some data.
Types of DBMS
Four Types of DBMS systems are:
Hierarchical DBMS
Network Model
Page |6
The network database model allows each child to have multiple parents. It helps you
to address the need to model more complex relationships like as the orders/parts
many-to-many relationship. In this model, entities are organized in a graph which can
be accessed through several paths.
Relational model
Relational DBMS is the most widely used DBMS model because it is one of the easiest.
This model is based on normalizing data in the rows and columns of the tables.
Relational model stored in fixed structures and manipulated using SQL.
Object-Oriented Model
In Object-oriented Model data stored in the form of objects. The structure which is
called classes which display data within it. It defines a database as a collection of
objects which stores both data members values and operations.
Page |7
DBMS Architecture
DBMS architecture helps in design, development, implementation, and maintenance
of a database. A database stores critical information for a business.
Selecting the correct Database Architecture helps in quick and secure access to this
data.
1 tier Architecture
2-tier Architecture
3-tier Architecture
1 tier Architecture
The simplest of Database Architecture are 1 tier where the Client, Server, and
Database all reside on the same machine.
In 1-tier architecture, the DBMS is the only entity where the user directly sits on the
DBMS and uses it. Any changes done here will directly be done on the DBMS itself. It
does not provide handy tools for end-users. Database designers and programmers
normally prefer to use single-tier architecture.
2 tier Architecture
If the architecture of DBMS is 2-tier, then it must have an application through which
the DBMS can be accessed.
3-tier Architecture
A 3-tier architecture separates its tiers from each other based on the complexity of
the users and how they use the data present in the database. It is the most widely
used architecture to design a DBMS.
Data Models
Data models define how the logical structure of a database is modeled. Data Models
are fundamental entities to introduce abstraction in a DBMS. Data models define how
data is connected to each other and how they are processed and stored inside the
system.
The very first data model could be flat data-models, where all the data used are to be
kept in the same plane. Earlier data models were not so scientific, hence they were
prone to introduce lots of duplication and update anomalies.
Entity-Relationship Model
Entity-Relationship (ER) Model is based on the notion of real-world entities and
relationships among them. The ER Model creates entity set, relationship set, general
attributes and constraints.
ER Model is best used for the conceptual design of a database.
ER Model is based on −
Entity − An entity in an ER Model is a real-world entity having properties
called attributes. Every attribute is defined by its set of values called domain.
For example, in a school database, a student is considered as an entity. Student
has various attributes like name, age, class, etc.
Relationship − The logical association among entities is called relationship.
Relationships are mapped with entities in various ways. Mapping cardinalities
define the number of association between two entities.
Mapping cardinalities −
o one to one
o one to many
o many to one
o many to many
Page |9
Relational data model is the primary data model, which is used widely around the
world for data storage and processing. This model is simple and it has all the
properties and capabilities required to process data with storage efficiency.
Concepts
1. Attribute: Each column in a Table. Attributes are the properties which define a
relation. e.g., Student_Rollno, NAME,etc.
2. Tables – In the Relational model the, relations are saved in the table format. It is
stored along with its entities. A table has two properties rows and columns. Rows
represent records and columns represent attributes.
3. Tuple – It is nothing but a single row of a table, which contains a single record.
4. Relation Schema: A relation schema represents the name of the relation with its
attributes.
5. Degree: The total number of attributes which in the relation is called the degree of
the relation.
6. Cardinality: Total number of rows present in the Table.
P a g e | 10
7. Column: The column represents the set of values for a specific attribute.
8. Relation instance – Relation instance is a finite set of tuples in the RDBMS system.
Relation instances never have duplicate tuples.
9. Relation key - Every row has one, two or multiple attributes, which is called
relation key.
10. Attribute domain – Every attribute has some pre-defined value and scope which is
known as attribute domain
Constraints
Every relation has some conditions that must hold for it to be a valid relation. These
conditions are called Relational Integrity Constraints. There are three main integrity
constraints −
Key constraints
Domain constraints
Referential integrity constraints
Key Constraints
There must be at least one minimal subset of attributes in the relation, which can
identify a tuple uniquely. This minimal subset of attributes is called key for that
relation.
Key constraints force that −
In a relation with a key attribute, no two tuples can have identical values for key
attributes.
A key attribute cannot have NULL values.
Domain Constraints
Attributes have specific values in real-world scenario. For example, age can only be a
positive integer. The same constraints have been tried to employ on the attributes of
a relation. Every attribute is bound to have a specific range of values.
For example, age cannot be less than zero and telephone numbers cannot contain a
digit outside 0-9.
P a g e | 11
ER Diagram Representation
Entities
Attributes
Relationships
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).
P a g e | 12
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.
Relationship
Relationships are represented by diamond-shaped box. Name of the relationship is
written inside the diamond-box. All the entities (rectangles) participating in a
relationship, are connected to it by a line.
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.