DBMS Architecture 1-level, 2-Level, 3-Level
A Database stores a lot of critical information to access data quickly and securely. Hence it is important to select
the correct architecture for efficient data management. DBMS Architecture helps users to get their requests done
while connecting to the database. We choose database architecture depending on several factors like the size of the
database, number of users, and relationships between the users. There are two types of database models that we
generally use, logical model and physical model. Several types of architecture are there in the database which we
will deal with in the next section.
Types of DBMS Architecture
There are several types of DBMS Architecture that we use according to the usage requirements. Types of DBMS
Architecture are discussed here.
1-Tier Architecture
2-Tier Architecture
3-Tier Architecture
1-Tier Architecture
In 1-Tier Architecture the database is directly available to the user, the user can directly sit on the DBMS and use it
that is, the client, server, and Database are all present on the same machine. For Example: to learn SQL we set up
an SQL server and the database on the local system. This enables us to directly interact with the relational database
and execute operations. The industry won’t use this architecture they logically go for 2-tier and 3-tier Architecture.
DBMS 1-Tier Architecture
Advantages of 1-Tier Architecture
Below mentioned are the advantages of 1-Tier Architecture.
Simple Architecture: 1-Tier Architecture is the most simple architecture to set up, as only a single machine is
required to maintain it.
Cost-Effective: No additional hardware is required for implementing 1-Tier Architecture, which makes it
cost-effective.
Easy to Implement: 1-Tier Architecture can be easily deployed, and hence it is mostly used in small projects.
2-Tier Architecture
The 2-tier architecture is similar to a basic client-server model. The application at the client end directly
communicates with the database on the server side. APIs like ODBC and JDBC are used for this interaction. The
server side is responsible for providing query processing and transaction management functionalities. On the client
side, the user interfaces and application programs are run. The application on the client side establishes a
connection with the server side to communicate with the DBMS.
An advantage of this type is that maintenance and understanding are easier, and compatible with existing systems.
However, this model gives poor performance when there are a large number of users.
DBMS 2-Tier Architecture
Advantages of 2-Tier Architecture
Easy to Access: 2-Tier Architecture makes easy access to the database, which makes fast retrieval.
Scalable: We can scale the database easily, by adding clients or upgrading hardware.
Low Cost: 2-Tier Architecture is cheaper than 3-Tier Architecture and Multi-Tier Architecture.
Easy Deployment: 2-Tier Architecture is easier to deploy than 3-Tier Architecture.
Simple: 2-Tier Architecture is easily understandable as well as simple because of only two components.
3-Tier Architecture
In 3-Tier Architecture, there is another layer between the client and the server. The client does not directly
communicate with the server. Instead, it interacts with an application server which further communicates with the
database system and then the query processing and transaction management takes place. This intermediate layer
acts as a medium for the exchange of partially processed data between the server and the client. This type of
architecture is used in the case of large web applications.
DBMS 3-Tier Architecture
Advantages of 3-Tier Architecture
Enhanced scalability: Scalability is enhanced due to the distributed deployment of application servers. Now,
individual connections need not be made between the client and server.
Data Integrity: 3-Tier Architecture maintains Data Integrity. Since there is a middle layer between the client
and the server, data corruption can be avoided/removed.
Security: 3-Tier Architecture Improves Security. This type of model prevents direct interaction of the client
with the server thereby reducing access to unauthorized data.
Disadvantages of 3-Tier Architecture
More Complex: 3-Tier Architecture is more complex in comparison to 2-Tier Architecture. Communication
Points are also doubled in 3-Tier Architecture.
Difficult to Interact: It becomes difficult for this sort of interaction to take place due to the presence of
middle layers.
For more, you can refer to the Advantages and Disadvantages of 3-Tier Architecture in DBMS.
Conclusion
When it comes to choosing a DBMS architecture, it all comes down to how complex and scalable the system is.
The 3-level structure has the best features and is perfect for modern, big database systems.
Introduction of ER Model
Peter Chen developed the ER diagram in 1976 .The ER model was created to provide a simple and
understandable model for representing the structure and logic of databases. It has since evolved into
variations such as the Enhanced ER Model and the Object Relationship Model
The Entity Relational Model is a model for identifying entities to be represented in the database and
representation of how those entities are related. The ER data model specifies enterprise schema that
represents the overall logical structure of a database graphically.
The Entity Relationship Diagram explains the relationship among the entities present in the database.
ER models are used to model real-world objects like a person, a car, or a company and the relation
between these real-world objects. In short, the ER Diagram is the structural format of the database.
Why Use ER Diagrams In DBMS?
ER diagrams are used to represent the E-R model in a database, which makes them easy to convert
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 the ER Model.
Ellipses: Ellipses represent Attributes in the 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.
Symbols used in ER Diagram
Components of ER Diagram
ER Model consists of Entities, Attributes, and Relationships among Entities in a Database System.
Components of ER Diagram
Entity
An Entity may be an object with a physical existence – a particular person, car, house, or employee – or
it may be an object with a conceptual existence – a company, a job, or a university course.
Entity are of two types
1.Tangible Entity – Which can be touched like car , person etc.
2.Non – tangible Entity – Which can’t be touched like air , bank account etc.
Entity Set: An Entity is an object of Entity Type and a set of all entities is called an entity set. For
Example, E1 is an entity having Entity Type Student and the set of all students is called Entity Set. In
ER diagram, Entity Type is represented as:
Entity Set
We can represent the entity set in ER Diagram but can’t represent entity in ER Diagram because entity
is row and column in the relation and ER Diagram is graphical representation of data.
1. Strong Entity
A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not depend on other
Entity in the Schema. It has a primary key, that helps in identifying it uniquely, and it is represented by
a rectangle. These are called Strong Entity Types.
2. Weak Entity
An Entity type has a key attribute that uniquely identifies each entity in the entity set. But some entity
type exists for which key attributes can’t be defined. These are called Weak Entity types.
For Example, A company may store the information of dependents (Parents, Children, Spouse) of an
Employee. But the dependents can’t exist without the employee. So Dependent will be a Weak Entity
Type and Employee will be Identifying Entity type for Dependent, which means it is Strong Entity
Type.
A weak entity type is represented by a Double Rectangle. The participation of weak entity types is
always total. The relationship between the weak entity type and its identifying strong entity type is
called identifying relationship and it is represented by a double diamond.
Strong Entity and Weak Entity
Attributes
Attributes are the properties that define the entity type. For example, Roll_No, Name, DOB, Age,
Address, and Mobile_No are the attributes that define entity type Student. In ER diagram, the attribute
is represented by an oval.
Attribute
1. Key Attribute
The attribute which uniquely identifies each entity in the entity set is called the key attribute. For
example, Roll_No will be unique for each student. In ER diagram, the key attribute is represented by an
oval with underlying lines.
Key Attribute
2. Composite Attribute
An attribute composed of many other attributes is called a composite attribute. For example, the
Address attribute of the student Entity type consists of Street, City, State, and Country. In ER diagram,
the composite attribute is represented by an oval comprising of ovals.
Composite Attribute
3. Multivalued Attribute
An attribute consisting of more than one value for a given entity. For example, Phone_No (can be more
than one for a given student). In ER diagram, a multivalued attribute is represented by a double oval.
Multivalued Attribute
4. Derived Attribute
An attribute that can be derived from other attributes of the entity type is known as a derived attribute.
e.g.; Age (can be derived from DOB). In ER diagram, the derived attribute is represented by a dashed
oval.
Derived Attribute
The Complete Entity Type Student with its Attributes can be represented as:
Entity and Attributes
Relationship Type and Relationship Set
A Relationship Type 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.
Relationship Set
Degree of a 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.
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.
Binary Relationship
3. Ternary Relationship: When there are n entities set participating in a relation, the relationship is
called an n-ary relationship.
Cardinality
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
entity and the total number of tables that can be used in this is 2. Let us assume that one surgeon
department can accommodate many doctors. So the Cardinality will be 1 to M. It means one department
has many Doctors.
total number of tables that can used is 3.
one to many cardinality
Using sets, one-to-many cardinality can be represented as:
Set Representation of One-to-Many
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:
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
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.
Participation Constraint
Participation Constraint is applied to the entity participating in the relationship set.
1. Total Participation – Each entity in the entity set must participate in the relationship. If each student
must enroll in a course, the participation of students will be total. Total participation is shown by a
double line in the ER diagram.
2. Partial Participation – The entity in the entity set may or may NOT participate in the relationship. If
some courses are not enrolled by any of the students, the participation in the course will be partial.
The diagram depicts the ‘Enrolled in’ relationship set with Student Entity set having total participation
and Course Entity set having partial participation.
Total Participation and Partial Participation
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.
How to Draw ER Diagram?
The very first step is Identifying all the Entities, and place them in a Rectangle, and labeling them
accordingly.
The next step is to identify the relationship between them and place 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 colors to highlight the data present in the database.
What is Join in DBMS?
Join in DBMS is a binary operation which allows you to combine join product and selection in one single
statement. The goal of creating a join condition is that it helps you to combine the data from two or more
DBMS tables. The tables in DBMS are associated using the primary key and foreign keys.
Types of Join
There are mainly two types of joins in DBMS:
1. Inner Joins: Theta, Natural, EQUI
2. Outer Join: Left, Right, Full
Inner Join
Inner Join is used to return rows from both tables which satisfy the given condition. It is the most widely
used join operation and can be considered as a default join-type
An Inner join or equijoin is a comparator-based join which uses equality comparisons in the join-
predicate. However, if you use other comparison operators like “>” it can’t be called equijoin.
Inner Join further divided into three subtypes:
Theta join
Natural join
EQUI join
Theta Join
Theta Join allows you to merge two tables based on the condition represented by theta. Theta joins
work for all comparison operators. It is denoted by symbol θ. The general case of JOIN operation is
called a Theta join.
00:00
Syntax:
A ⋈θ B
Theta join can use any conditions in the selection criteria.
Consider the following tables.
Table A Table B
column 1 column 2 column 1 column 2
1 1 1 1
1 2 1 3
For example:
A ⋈ A.column 2 > B.column 2 (B)
A ⋈ A.column 2 > B.column 2 (B)
column 1 column 2
1 2
EQUI Join
EQUI Join is done when a Theta join uses only the equivalence condition. EQUI join is the most difficult
operation to implement efficiently in an RDBMS, and one reason why RDBMS have essential
performance problems.
For example:
A ⋈ A.column 2 = B.column 2 (B)
A ⋈ A.column 2 = B.column 2 (B)
column 1 column 2
1 1
Natural Join (⋈)
Natural Join does not utilize any of the comparison operators. In this type of join, the attributes should
have the same name and domain. In Natural Join, there should be at least one common attribute
between two relations.
It performs selection forming equality on those attributes which appear in both relations and eliminates
the duplicate attributes.
Example:
Consider the following two tables
C
Num Square
2 4
3 9
D
Num Cube
2 8
3 18
C ⋈ D
C⋈D
Num Square Cu
2 4 8
3 9 18
Outer Join
An Outer Join doesn’t require each record in the two join tables to have a matching record. In this type
of join, the table retains each record even if no other matching record exists.
Three types of Outer Joins are:
Left Outer Join
Right Outer Join
Full Outer Join
Left Outer Join (A ⟕ B)
Left Outer Join returns all the rows from the table on the left even if no matching rows have been found
in the table on the right. When no matching record is found in the table on the right, NULL is returned.
Consider the following 2 Tables
A
Num Square
2 4
3 9
4 16
B
Num Cube
2 8
3 18
5 75
A B
A⋈B
Num Square Cu
2 4 8
3 9 18
4 16 –
Right Outer Join ( A ⟖ B )
Right Outer Join returns all the columns from the table on the right even if no matching rows have been
found in the table on the left. Where no matches have been found in the table on the left, NULL is
returned. RIGHT outer JOIN is the opposite of LEFT JOIN
In our example, let’s assume that you need to get the names of members and movies rented by them.
Now we have a new member who has not rented any movie yet.
A B
A⋈B
Num Cube Square
2 8 4
3 18 9
5 75 –
Full Outer Join ( A ⟗ B)
In a Full Outer Join , all tuples from both relations are included in the result, irrespective of the
matching condition.
Example:
A B
A⋈B
Num Square
2 4
3 9
4 16
5 –
Summary
There are mainly two types of joins in DBMS 1) Inner Join 2) Outer Join
An inner join is the widely used join operation and can be considered as a default join-type.
Inner Join is further divided into three subtypes: 1) Theta join 2) Natural join 3) EQUI join
Theta Join allows you to merge two tables based on the condition represented by theta
When a theta join uses only equivalence condition, it becomes an equi join.
Natural join does not utilize any of the comparison operators.
An outer join doesn’t require each record in the two join tables to have a matching record.
Outer Join is further divided into three subtypes are: 1)Left Outer Join 2) Right Outer Join 3) Full
Outer Join
The LEFT Outer Join returns all the rows from the table on the left, even if no matching rows have
been found in the table on the right.
The RIGHT Outer Join returns all the columns from the table on the right, even if no matching rows
have been found in the table on the left.
In a full outer join, all tuples from both relations are included in the result, irrespective of the
matching condition.