0% found this document useful (0 votes)
59 views52 pages

DBMS Sem-Ii Unit-Ii

The document discusses various data models used in Database Management Systems (DBMS), including hierarchical, network, entity-relationship (ER), relational, and object-oriented models. It outlines the advantages and disadvantages of each model, as well as Codd's rules for relational databases. The document emphasizes the importance of data models in improving business processes, reducing complexity, and facilitating communication among stakeholders.

Uploaded by

chetankosare426
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)
59 views52 pages

DBMS Sem-Ii Unit-Ii

The document discusses various data models used in Database Management Systems (DBMS), including hierarchical, network, entity-relationship (ER), relational, and object-oriented models. It outlines the advantages and disadvantages of each model, as well as Codd's rules for relational databases. The document emphasizes the importance of data models in improving business processes, reducing complexity, and facilitating communication among stakeholders.

Uploaded by

chetankosare426
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/ 52

Database Management System

Unit-II : Data Models – Types of Data Models, Codd’s Rules, Comparison of various Data
Models, Types of Database Systems, Comparison between Client/Server and Distributed
Database Systems, Comparison between DBMS and RDBMS.

ER Models-Basic Concept, Types of Attributes, Relationship Sets, Degree of Relationship sets,


Mapping cardinalities, Keys, Types of Keys, Entity-Relationship Diagram, Advantages and
Limitations of ER Model, Types of Entity Sets, Enhanced Entity Relationship (EER), Super class
and Sub class entity types, Specialization and Generalization, Attribute Inheritance,
Aggregation.

Data Model
A data model can be defined as an integrated collection of concepts describing and
manipulating data, as well as constraints on the data within an organization. A data
model is not just a set of tables; it is a conceptual representation of physical data
stored in the database.
For example, if you have a table with a column for each employee's name, then there
are many possible ways to represent this information: as one row per employee, or as
multiple rows per employee (one row per department), or as multiple rows per person
(one row for each job title). Each of these models has its own strengths and
weaknesses.

The first step in designing a data model is to define what kind of data you want to store
in your database. This usually involves defining the entities involved in your application.
An entity is any object that exists independently of anything else. You might think about
an entity as something like a "person" or an "address." Once you've identified all the
entities, you need to decide how they relate to each other. In most cases, the answer
to this question depends on what type of business process you're modeling.

The next step is to figure out how those entities will interact with each other. In some
applications, you may want to create a single table to hold all the data about a
particular entity. However, you could also use several tables, where each table holds
only part of the data about an individual entity.

In addition, you should consider whether you'll need to perform queries across more
than one table. If so, you'll probably need to link them together using foreign key
columns.

Once you know the basic structure of your data model, you can start thinking about
how best to organize it into tables. There are two main approaches: relational
databases and hierarchical databases. Relational databases are organized around a
set of tables that share common fields. Hierarchical databases are organized around a
tree-like structure called a hierarchy. Both approaches allow you to build complex
structures quickly, but they do so at the cost of flexibility.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 1
Why use Data Models?
Data Models are extremely useful for any organization as it lets business users directly
define core business rules. As a result, fewer revisions are required during
implementation. It also leads to significant reductions in the development time, allowing
businesses to deliver new businesses and projects faster.
Overall, the advantages of using data models can be summed up briefly in the
following way:
1. Helps to cut costs and deliver products faster
2. It improves business processes significantly
3. Reduces complexity and risks in data handling
Now, let's discuss the various types of data models in DBMS in detail.

Types of Data Model in DBMS


There are a variety of models for data. Some of the most well-known models include:
 A Hierarchical model
 Network model
 Model of Entity-Relationship
 Relational Model
 Object-Oriented Data Model
You can describe your database using any of these based on a variety of
variables. The most important thing to consider is the degree to which the database
management software that you're using is compatible with specific models. The
majority of database management systems are designed with a specific database
model and will require users to follow that model, however, some support multiple
models.
Furthermore, there are different models that can be applied to various stages of the
design process for databases. Conceptual data models that are high-level are the best
way to map out relationships between data in the way which people can see the
data. Logical models that are based on records, however, are more closely reflected in
the way the data is stored at the data server.
When choosing a data model, it's equally about setting your priorities in relation to the
database and the strengths of a specific model, regardless of whether your goals are
speed, cost savings usability, or something different.
Let's take a glance at the top popular databases models.

1. A Hierarchical Model
The hierarchical data model was the first DBMS-based model. This model organizes
data in a hierarchical tree structure. The hierarchy begins at the root, which contains
root data. It then expands into a tree adding child nodes to the parent node. This model
can easily represent some real-world relationships, such as sitemaps and recipes for
food, or even website navigation.
Example: The relationship between different kinds of humans can be represented in
the following manner:

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 2
Characteristics of Hierarchical Model:
1. One to many relationships: Here, the data is organized in a tree-like manner
where there is a one-to-many relationship between data types. There can only
be one path from any parent to any node. Example: If we want to get to the root
node, there is only one way to do so. It's through the men's shoe node.
2. Parent-Child Relationship Every child node has its parent node, but a parent can
have more than one child. Multiple parents are prohibited.
3. Deletion Issue: When a parent node has been deleted, the child node will also
be deleted.
4. Pointers: Pointers link the parent and child nodes. They are used for navigation
between stored data.
Example: The visual representation of the basic concepts of the database schema is
shown below where the human node points to two other nodes, the Women, and
the Men. This example is explained by taking real-world entities.

The Advantages of the Hierarchical Model


 It's very easy and quick to navigate through a tree-like structure.
 Changes in the parent node are automatically reflected in child nodes so data
integrity is maintained.
 Easy to find the difference.

The Disadvantages of the Hierarchical Model


 Complex relationships cannot be supported.
 It does not support more than one parent of the child Node. If there is a complex
relationship, where a child Node requires two parent nodes, it cannot be
represented with this model.
 The child node will be deleted automatically if a parent node has been deleted.

2. Network Model
This model is an extension of the hierarchical one. This model was the most well-known
before the relational one. The hierarchical model can have multiple records. This model
is identical to the hierarchical one. It replaces the hierarchical trees with a graph.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 3
Example: In this example, we can see that a node student has two parents, Department
and Library. In the hierarchical structure, this was not possible.

Characteristics Of Network Model


1. Ability to Merge More Relationships: In this model, data is more closely
related to more relationships. This model can manage both one-to-one and
many-to-many relationships.
2. Many routes: Because there are many relationships, there may be multiple
paths to the same record. This allows data access to be quick and easy.
3. Circular Link List: The operations on the network model can be done using the
circular linked list. A program maintains the current position and navigates
through the records based on the relationship. The physical structure of the
network model is
Network Model Advantages
 Data can be accessed more quickly than the hierarchical model. Because the
data in the network model is more closely related, and it is possible to take more
than one route to reach a particular point, this is why the data can be accessed
faster. The data can therefore be accessed in many different ways.
 Data integrity is guaranteed because there is a parent/child relationship. Any
changes in the parent record are reflected in a child record.
Network Model's Disadvantages
 The system can become more complicated as more relationships are needed to
be managed. To be able to use the model, the user must have a good
understanding of it.
 Any type of change, such as updating, deletion, or insertion, is extremely
complex.

3. Entity-Relationship (ER) Data Model


Entity-Relationship Data Model, or simply (E-R) Model UML is a high-level diagram of a
data model. This model shows the real-world problem in a pictorial format to make it
easier for stakeholders to understand.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 4
ER Model diagram makes it easy for developers to see the system. The E-R model
Diagram is used to show an ER Model or domain model. The following components
make up the ER Diagram:
 Entity: A real-world thing, entity. It could be a person, a place, or even an
idea. Examples: Students, Teachers, Courses, Buildings, Departments, etc. are
all examples of entities that make up a School Management system.
 Attributes: An entity can contain a real-world property called an attribute. These
are the attributes of the attribute. Example: An entity student owns the property
student id and age, and so forth.
 Relationship - Relationship shows how two attributes are related. Example: A
student working in a department.
The entities in the diagram are student and course. Student entity attributes are
Student_Id and Student_Age. Entity Course has the attributes Course_Id and
Course_Credits. These entities are linked using the relationship. Each student works in
a specific department.

Characteristics of the ER Model


 Graphical representation for better understanding: It's very simple and easy
to understand, so developers can use it to communicate with stakeholders.
 ERD Diagram: ERD diagram is used to represent the model visually.
 Design of a Database: This model is used by database designers to create a
database.
The Advantages of the ER Model
 Easy: Conceptually, an ER Model can be very simple to create. The ER Diagram
can be easily created if we know the relationships between the entities and
attributes.
 Effective Communication Tools: Database designers use this model to
communicate their ideas.
 Conversion to Any Model: This model is compatible with the relational model. It
can easily be converted to a relational model by converting ER to the table. In
fact, this model can be easily converted to any model such as a hierarchical or
network model.
Disadvantages of the ER Model
 There is no industry standard in notation: It is impossible to develop an ER
model according to industry standards. One developer may use notations that
aren't understood by others.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 5
 Hidden Information: There is some information that might be lost or hidden
within the ER model. It is possible that some information may be lost or hidden
because it is a high-level view.

4. Relational Model
The relational model is the most popular model. It is a model where the information is
stored as two-dimensional tables. All information is stored in rows and columns. The
foundation of a model that is relational is tables. Therefore the tables are known
as relations within the model. Examples: In this example, there is a student data table.

Characteristics of Relational Model


 Tuple: Each row within the table is known as the tuple. Each row is comprised
of all the details regarding any particular specific instance. In the example above
each row is filled with all the information regarding a particular person, just like
the first row contains information regarding Arya.
 Field or attribute: Attributes are the property that defines the table or
relationship. The attributes' values must be within that same domain. In the
example above there are different aspects of an employee such as Salary
Mobile_no, Salary, etc.

Names Roll_No Phone_No Address AGE

Neha 98098 7305758990 Varanasi 20

Narayan 12830 8026288936 Delhi 10

Amit 330989 8583289090 Bihar 16

Khushi 2785790 708687878 Patna 14

Ganesh 17282 902893988 Bangalore 23

Advantages of Relational Model


 Basic: This database model is less complex, compared to the network model
and hierarchical models.
 Scalable: This is a model that can scale easily so that we add as many columns
and rows as we'd like.
 Structural Independence It is possible to alter the structure of the database
without altering the method for accessing the information. If we can make
modifications to the database structure, without altering the ability of DBMS in
accessing data, we can claim that structural independence is attained.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 6
Disadvantages of Relational Model
 Hardware Overheads: For concealing the complexity and making it easier for the
user, this model calls for more powerful hardware computers as well as devices
for storing data.
 Poor Design: Because the model of relationship is extremely easy to create and
utilize. Therefore, users don't have to understand how data is stored for them to
gain access to it. This simplicity of design could cause the development of a bad
database, which could slow down as the database expands.

However, these issues are insignificant when compared to the benefits associated with
the relationship model. The problems could be prevented with the proper
implementation and management.

5. Object-Oriented Database Model


The actual problems are precisely represented by the object-oriented model. Object-
oriented database models combine both data and the relationship are contained in a
single structure referred to as an object. It is possible to store images, audio, videos,
and more in databases that were not possible with the relational model (although you
could save video and audio in a relational database, it is advised not to store them in
relational databases).
The model, in this case, their additional objects that are linked by hyperlinks. This link is
used to connect one object to other objects. This is explained from the example below.

In the example above we have an object of the customer (or a single parent node). The
data and relationships for each object are organized as a single entity. The primary key
such as Bank Account, Pune_Address, and the Delhi_Address as well as the
processes that will be used by that object are recorded in a single entity. The objects
are linked via the same attribute i.e the Customer_Name. The communication between
them is done through this common identification. This is the representation of the
physical model of Object-oriented data model

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 7
Codd Rules
Codd rules were proposed by E.F. Codd which should be satisfied by relational model.
E.F Codd was a Computer Scientist who invented the Relational model for Database
management. Based on relational model, the Relational database was created. Codd
proposed 13 rules popularly known as Codd's 12 rules to test DBMS's concept against
his relational model. Codd's rules actually define what quality a DBMS requires in order
to become a Relational Database Management System (RDBMS). Till now, there is
hardly any commercial product that follows all the 13 Codd's rules. Even Oracle follows
only eight and half(8.5) out of 13. The Codd's 12 rules are as follows.

Rule zero
This rule states that for a system to qualify as an RDBMS, it must be able to manage
database entirely through the relational capabilities.
Rule 1: Information rule

All information (including metadata) is to be represented as stored data in cells of


tables. The rows and columns have to be strictly unordered.

Rule 2: Guaranteed Access


Each unique piece of data (atomic value) should be accessible by : Table Name +
Primary Key(Row) + Attribute(column).
NOTE: Ability to directly access via POINTER is a violation of this rule.

Rule 3: Systematic treatment of NULL


Null has several meanings; it can mean missing data, not applicable or no value. It
should be handled consistently. Also, Primary key must not be null, ever. Expression
on NULL must give null.

Rule 4: Active Online Catalog


Database dictionary (catalog) is the structure description of the complete Database and
it must be stored online. The Catalog must be governed by same rules as rest of the
database. The same query language should be used on catalog as used to query
database.

Rule 5: Powerful and Well-Structured Language


One well structured language must be there to provide all manners of access to the
data stored in the database. Example: SQL, etc. If the database allows access to the
data without the use of this language, then that is a violation.

Rule 6: View Updation Rule


All the view that are theoretically updatable should be updatable by the system as well.

Rule 7: Relational Level Operation


There must be Insert, Delete, and Update operations at each level of relations. Set
operation like Union, Intersection and minus should also be supported.

Rule 8: Physical Data Independence


The physical storage of data should not matter to the system. If say, some file
supporting table is renamed or moved from one disk to another, it should not affect the
application.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 8
Rule 9: Logical Data Independence
If there is change in the logical structure (table structures) of the database the user view
of data should not change. Say, if a table is split into two tables, a new view should give
result as the join of the two tables. This rule is most difficult to satisfy.

Rule 10: Integrity Independence


The database should be able to enforce its own integrity rather than using other
programs. Key and Check constraints, trigger etc, should be stored in Data Dictionary.
This also makes RDBMS independent of front-end.
Rule 11: Distribution Independence
A database should work properly regardless of its distribution across a network. Even if
a database is geographically distributed, with data stored in pieces, the end user should
get an impression that it is stored at the same place. This lays the foundation
of distributed database.

Rule 12: Nonsubversion Rule


If low level access is allowed to a system it should not be able to subvert or bypass
integrity rules to change the data. This can be achieved by some sort of looking or
encryption.

Difference between Hierarchical, Network and Relational Data Model:


SN Hierarchical Data Model Network Data Model Relational Data Model

1. In this model, to store data It organizes records to one It organizes records in the
hierarchy method is used. another through links or form of table and
It is the oldest method and pointers. relationship between
not in use today. tables are set using
common fields.

2. To organize records, it It organizes records in the form It organizes records in the


uses tree structure. of directed graphs. form of tables.

3. It implements 1:1 and 1:n In addition to 1:1 and 1:n it also In addition to 1:1 and 1:n it
relations. implements many to many also implements many to
relationships. many relationships.

4. Pointers are used to A linked list is used to establish The logical representation
establish relationships a relationship among records is used with rows and
among records physically. physically. columns to depict
relationship among
records.

5. Insertion anomaly exits in There is no insertion anomaly. There is no insertion


this model i.e. child node anomaly.
cannot be inserted without
the parent node.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 9
SN Hierarchical Data Model Network Data Model Relational Data Model

Deletion anomaly exists in There is no deletion anomaly. There is no deletion


this model i.e. it is difficult anomaly.
6. to delete the parent node.

Update leads to No such problem as only one Updating a record is easy


inconsistency problems instance of records exist. and simple with the
because of the existence process of normalization,
of multiple instances of a the redundant data gets
7. child record. removed.

This model lacks data There is partial data This model provides data
8. independence. independence in this model. independence.

No such facility for No such facility for querying SQL-based declarative


querying database is database is supported. querying is supported.
9. supported.

It is used to access the It is used to access the data It is used to access the
data which is complex and which is complex and data which is complex and
10. asymmetric. symmetric. symmetric.

Difficult to design a database


and manipulate a database It is easy to comprehend
Difficult to design a because of its complexity. due to concealed physical
database because of its Hence, it imposes a burden on level details from end-
11. complexity. the programmer. users.

It is less flexible. It is flexible as compared to the It is flexible as compared


12. hierarchical model. to the hierarchical model.

&XML and XAML use this VAX-DBMS, DMS-1100 of It is mostly used in real
model. UNIVAC and SUPRADBMS’s world applications. Oracle,
13. use this model. SQL.

Difference between ER model and relational model:

ER model Relational model

Developed by Peter Chen in 1976. Developed by E.F. Codd in 1970.

ER model is the high level or conceptual It is the representational or implementation


model. model.

It is used by people who don’t know how


database is implemented. It is used by programmers.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 10
ER model Relational model

It represents collection of entities and It represent data in the form of tables and
describes relationship between them. describes relationship between them.

It consists of components like Entity, Entity It consists of components like domain,


Type, Entity Set. attributes, tuples.

It is easy to understand the relationship It is less easy to derive the relationship


between entities. between different tables.

It describes cardinality. It does not describe cardinality.

Some of the popular Language and


Notations used-
 Chen Some of the popular Language and
 UML Notations used-
 Crow’s foot  SQL
 Bachman and others.  MySQL

Types of Databases
There are various types of databases used for storing different varieties of data:
1. Centralized Database
2. Distributed Database
3. Relational Database
4. Cloud Database
5. Object Oriented Database
6. Hierarchical Database
7. Network Database
8. Personal Database

1) Centralized Database
It is the type of database that stores data at a centralized database system. It comforts
the users to access the stored data from different locations through several applications.
These applications contain the authentication process to let users access data securely.
An example of a Centralized database can be Central Library that carries a central
database of each library in a college/university.

Advantages of Centralized Database


o It has decreased the risk of data management, i.e., manipulation of data will not
affect the core data.
o Data consistency is maintained as it manages data in a central repository.
o It provides better data quality, which enables organizations to establish data
standards.
o It is less costly because fewer vendors are required to handle the data sets.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 11
Disadvantages of Centralized Database
o The size of the centralized database is large, which increases the response time
for fetching the data.
o It is not easy to update such an extensive database system.
o If any server failure occurs, entire data will be lost, which could be a huge loss.

2) Distributed Database
Unlike a centralized database system, in distributed systems, data is distributed among
different database systems of an organization. These database systems are connected
via communication links. Such links help the end-users to access the data
easily. Examples of the Distributed database are Apache Cassandra, HBase, Ignite,
etc.
We can further divide a distributed database system into:

o Homogeneous DDB: Those database systems which execute on the same


operating system and use the same application process and carry the same
hardware devices.
o Heterogeneous DDB: Those database systems which execute on different
operating systems under different application procedures, and carries different
hardware devices.

Advantages of Distributed Database


o Modular development is possible in a distributed database, i.e., the system can
be expanded by including new computers and connecting them to the distributed
system.
o One server failure will not affect the entire data set.

3) Relational Database
This database is based on the relational data model, which stores data in the form of
rows(tuple) and columns(attributes), and together forms a table(relation). A relational

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 12
database uses SQL for storing, manipulating, as well as maintaining the data. E.F.
Codd invented the database in 1970. Each table in the database carries a key that
makes the data unique from others. Examples of Relational databases are MySQL,
Microsoft SQL Server, Oracle, etc.

Properties of Relational Database


There are following four commonly known properties of a relational model known as
ACID properties, where:

A means Atomicity: This ensures the data operation will complete either with success
or with failure. It follows the 'all or nothing' strategy. For example, a transaction will
either be committed or will abort.

C means Consistency: If we perform any operation over the data, its value before and
after the operation should be preserved. For example, the account balance before and
after the transaction should be correct, i.e., it should remain conserved.

I means Isolation: There can be concurrent users for accessing data at the same time
from the database. Thus, isolation between the data should remain isolated. For
example, when multiple transactions occur at the same time, one transaction effects
should not be visible to the other transactions in the database.

D means Durability: It ensures that once it completes the operation and commits the
data, data changes should remain permanent.

4) Cloud Database
It is a type of database where data is stored in a virtual environment and executes over
the cloud computing platform. It provides users with various cloud computing services
(SaaS, PaaS, IaaS, etc.) for accessing the database. There are numerous cloud
platforms, but the best options are:
o Amazon Web Services(AWS)
o Microsoft Azure
o Kamatera
o PhonixNAP
o ScienceSoft
o Google Cloud SQL, etc.

5) Object-oriented Databases
It is the type of database that uses the object-based data model approach for storing
data in the database system. The data is represented and stored as objects which are
similar to the objects used in the object-oriented programming language.

6) Hierarchical Databases
It is the type of database that stores data in the form of parent-children relationship
nodes. Here, it organizes data in a tree-like structure.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 13
Data get stored in the form of records that are connected via links. Each child record in
the tree will contain only one parent. On the other hand, each parent record can have
multiple child records.

7) Network Databases
It is the database that typically follows the network data model. Here, the representation
of data is in the form of nodes connected via links between them. Unlike the hierarchical
database, it allows each record to have multiple children and parent nodes to form a
generalized graph structure.

8) Personal Database
Collecting and storing data on the user's system defines a Personal Database. This
database is basically designed for a single user.

Advantage of Personal Database


o It is simple and easy to handle.
o It occupies less storage space as it is small in size.

Client-server Database Architecture in DBMS


In client-server architecture many clients connected with one server. The server is
centerlines. It provides services to all clients. All clients request to the server for
different Service. The server displays the results according to the client’s request.
Client/server architecture is a computing model in which the server hosts (computer),
send and manages most of the resources and works to be required by the client. In this
type of architecture has one or more client computers attached to a central server over
a network. This system shares different resources.
Client/server architecture is also called as a networking computing model and client-
server network because all the requests and demands are sent over a network.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 14
Working of Client-server Database Architecture in DBMS

Basically client-server model defines how the server provides services to clients. Server
is a centralized computer that provides services to all attached clients. For example file
server, web server, etc. each the basic work of server to provide services to each client.
The client can be a laptop computer, tablets, and smart phones, etc. The server has
many types of relationship with clients. Many servers have one too many
relationships with clients. In one too many relationships many clients connected with
one server. When one client wants to communicate with the server, the server may be
accepted or rejects the request of clients. When the server computer accepts the
request of clients than server maintains a connection according to a defined protocol.
The protocol rules over the network.
That must be followed for any network connection. If the one client wants to send an
email over the network, it requests the server, the SMTP (the protocol that is SMPT is
standing for simple mail transfer protocol that used to transfer a mail over the network.
SMTP is a set of commands or commands that check authentication and the transfer of
email. When configuring the settings for your e-mail program, you usually need to set
the SMTP server to your local Internet Service Provider’s SMTP settings. After all
process, the server will transfer e-mail to the desired client.
Another example of a client-server model is online gaming.

Structure of Client-server Database Architecture in DBMS


By using this architecture structure this software is divided into three different tiers:
1. Presentation tier
2. Logic tier
3. Data-tier
Each tier type builds and maintains independently.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 15
1-Presentation tier
This is the first and topmost level of the application n. The basic work of this layer
provides user interface .the interface is a graphical user interface. The graphical user
interface is an interface that consists of menus, buttons, and icons, etc. The
presentation tier presents information related to such work as browsing, sales
purchasing, and shopping cart contents. It attaches with other tiers by computing results
to the browser/client tier and all other tiers in the network.
2-Logic tier
The logical tier is also known as data access tier and middle tier. It lies between the
presentation tier and the data tier. It basically controls the application’s functions by
performing processing. The components that build this layer exist on the server, assist
the resources sharing these components also define the business rules like different
government legal rules, data rules, and different business algorithm .which are designed
to keep data structure consistent.
3-Data tier
This is basically the DBMS (database management system) layer. This layer consist of
database. It can be used through the business services layer. In this layer, data is
stored and retrieved .the responsibility of this layer to keep data consistent and
independent.
Providing data its own tier also improves scalability and performance. This layer
consists of data access components.

Advantages of Client-server Database Architecture in DBMS


1. All the data and resources are controlled by server. In this way all data and
resources are very consistent.
2. You can easily increase the number of client in this architecture at any time. This
all increases the scalability of the network.
3. This is very easy to maintain you can easily repair, replace or add clients in this
network. The independence of the changes also known as encapsulation.
4. This network is very easy to use and it is not complicated.

Disadvantages of Client-server Database Architecture in DBMS


1. Traffic is a big problem in this network.
2. When you add large numbers of the client with server this network will be more
complicated.
3. When the server goes down all the clients are not able to send their request. The
whole work will be stopped
4. The hardware and software are very expensive.
5. The client does not have resources for each resource they need to request the
server. Because of all resources exit on server

Difference between Client /Server and Distributed DBMS


1. Client/Server:
Client/server is developed to deal with various computing environments that have a
large number of computers and servers connected together via a network. In this
architecture, a Client is a user machine which provides the user interface and local
processing capabilities. When any client requires additional functionality like database
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 16
access, it can connect to Server that is capable of providing the functionality needed
by the client. Basically Server is a machine that provides services to the Client i.e user
machine.

2. Distributed DBMS :
In Distributed DBMS, data is distributed over the geographical site. Each site is a
complete database system site on its end but the different sites have to work together
because if any user wants to access the data it can easily access data anywhere in
the network as the data is stored at the user’s own computer.

Difference between Client/Server and Distributed DBMS :


SN Client/Server Distributed DBMS

Client can access only one server at a User can access many sites
1. time. simultaneously.

2. It is difficult to manage. It is easy to manage.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 17
SN Client/Server Distributed DBMS

In this data is distributed across


3. In this data is distributed across clients. sites.

Speed of accessing database is


Speed of accessing database is poor as much better than Client/Server
4. compared to Distributed DBMS. Architecture.

If somehow server crashes, the whole The crash of one site does not stop
5. system stops. the entire system.

Accessing of data is difficult to


6. Accessing of data is easy to control. control.

It is less expensive as compared to


7. Distributed DBMS. It is expensive.

8. Maintenance cost is low. Maintenance cost is high.

Difference between DBMS and RDBMS


The main differences between DBMS and RDBMS are given below:
SN DBMS RDBMS
1) DBMS applications store data as RDBMS applications store data in a tabular form.
file.
2) In DBMS, data is generally stored In RDBMS, the tables have an identifier called
in either a hierarchical form or a primary key and the data values are stored in the
navigational form. form of tables.
3) Normalization is not present in Normalization is present in RDBMS.
DBMS.
4) DBMS does not apply any RDBMS defines the integrity constraint for the
security with regards to data purpose of ACID (Atomicity, Consistency, Isolation
manipulation. and Durability) property.
5) DBMS uses file system to store in RDBMS, data values are stored in the form of
data, so there will be no relation tables, so a relationship between these data
between the tables. values will be stored in the form of a table as well.
6) DBMS has to provide some RDBMS system supports a tabular structure of the
uniform methods to access the data and a relationship between them to access
stored information. the stored information.
7) DBMS does not support RDBMS supports distributed database.
distributed database.
8) DBMS is meant to be for small RDBMS is designed to handle large amount of
organization and deal with small data. it supports multiple users.
data. it supports single user.
9) Examples of DBMS are file Example of RDBMS are mysql, postgre, sql
systems, xml etc. server, oracle etc.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 18
ER Model
ER Model stands for Entity Relationship Model is a high-level conceptual data model
diagram. ER model helps to systematically analyze data requirements to produce a
well-designed database. The ER Model represents real-world entities and the
relationships between them. Creating an ER Model in DBMS is considered as a best
practice before implementing the database.
ER Modeling helps to analyze data requirements systematically to produce a well-
designed database. So, it is considered a best practice to complete ER modeling before
implementing your database.
o ER model stands for an Entity-Relationship model. It is a high-level data model.
This model is used to define the data elements and relationship for a specified
system.
o It develops a conceptual design for the database. It also develops a very simple
and easy to design view of data.
o In ER modeling, the database structure is portrayed as a diagram called an
entity-relationship diagram.

Types of Attributes in ER Model

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.
There are six such types of attributes: Simple, Composite, Single-valued, Multi-valued,
and Derived attribute. One more attribute is there, i.e. Complex Attribute, this is the
rarely used attribute.
In ER diagram, attributes associated with an entity set may be of the following types-

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 19
1. Simple attributes
2. Composite attributes
3. Single valued attributes
4. Multi valued attributes
5. Derived attributes
6. Key attributes

1. Simple Attributes-
Simple attributes are those attributes which cannot be divided further.
Example-

Here, all the attributes are simple attributes as they cannot be divided further.
2. Composite attributes
Composite attributes are those attributes which are composed of many other simple
attributes.
Example-

Here, the attributes “Name” and “Address” are composite attributes as they are
composed of many other simple attributes.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 20
3. Single Valued Attributes-
Single valued attributes are those attributes which can take only one value for a given
entity from an entity set.
Example-

Here, all the attributes are single valued attributes as they can take only one specific
value for each entity.

4. Multi Valued Attributes-


Multi valued attributes are those attributes which can take more than one value for a
given entity from an entity set.
Example-

Here, the attributes “Mob_no” and “Email_id” are multi valued attributes as they can
take more than one values for a given entity.

5. Derived Attributes-
Derived attributes are those attributes which can be derived from other attribute(s).
Example-

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 21
Here, the attribute “Age” is a derived attribute as it can be derived from the attribute
“DOB”.

6. Key Attributes-

Key attributes are those attributes which can identify an entity uniquely in an entity set.
Example-

Here, the attribute “Roll_no” is a key attribute as it can identify any student uniquely.

Relationship Set
A relationship set is a set of relationships of same type.
A set of relationships of same type is known as relationship set.
Example-
‘Enrolled in’ is a relationship that exists between entities Student and Course.

Example-
Set representation of above ER diagram is-

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 22
Degree of a Relationship Set-

The number of entity sets that participate in a relationship set is termed as the degree of
that relationship set. Thus,

Degree of a relationship set = Number of entity sets


participating in a relationship set

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

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 23
1. Unary Relationship Set-
Unary relationship set is a relationship set where only one entity set participates in a
relationship set.

Example-
One person is married to only one person

2. Binary Relationship Set-


Binary relationship set is a relationship set where two entity sets participate in a
relationship set.
Example-

3. Ternary Relationship Set-


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

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 24
4. N-ary Relationship Set-
N-ary relationship set is a relationship set where ‘n’ entity sets participate in a
relationship set.
Degree of Relations in DBMS
In DBMS, a degree of relationship represents the number of entity types that associate
in a relationship. For example, we have two entities, one is a student and the other is
a bag and they are connected with the primary key and foreign key. So, here we can
see that the degree of relationship is 2 as 2 entities are associating in a relationship.
Types of degree
Now, based on the number of linked entity types, we have 4 types of degrees of
relationships.
1. Unary
2. Binary
3. Ternary
4. N-ary
Let’s discuss them one by one with the help of examples.
 Unary
In this type of relationship, both the associating entity type are the same. So, we can
say that unary relationships exist when both entity types are the same and we call
them the degree of relationship is 1. Or in other words, in a relation only one entity set
is participating then such type of relationship is known as a unary relationship.
Example: In a particular class, we have many students, there are monitors too. So,
here class monitors are also students. Thus, we can say that only students are
participating here. So the degree of such type of relationship is 1.

 Binary (degree 2)
In a Binary relationship, there are two types of entity associates. So, we can say that a
Binary relationship exists when there are two types of entity and we call them a
degree of relationship is 2. Or in other words, in a relation when two entity sets are
participating then such type of relationship is known as a binary relationship. This is
the most used relationship and one can easily be converted into a relational table.
Example: We have two entity types ‘Student’ and ‘ID’ where each ‘Student’ has his
‘ID’. So, here two entity types are associating we can say it is a binary relationship.
Also, one ‘Student’ can have many ‘daughters’ but each ‘daughter’ should belong to
only one ‘father. We can say that it is a one-to-many binary relationship.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 25
 Ternary (degree 3)
In the Ternary relationship, there are three types of entity associates. So, we can say
that a Ternary relationship exists when there are three types of entity and we call them
a degree of relationship is 3. Since the number of entities increases due to this, it
becomes very complex to turn E-R into a relational table. Now let’s understand with
the examples.
Example: We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The
relationship between these entities is defined as the teacher teaching a particular
course, also the teacher teaches a particular class. So, here three entity types are
associating we can say it is a ternary relationship.

 N-ary (n degree)
In the N-ary relationship, there are n types of entity that associates. So, we can say
that an N-ary relationship exists when there are n types of entities. There is one
limitation of the N-ary relationship, as there are many entities so it is very hard to
convert into an entity, rational table. So, this is very uncommon, unlike binary which is
very much popular.
Example: We have 5 entities Teacher, Class, Location, Salary, Course. So, here five
entity types are associating we can say an n-ary relationship is 5.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 26
Mapping Cardinality
In the view of databases, cardinality refers to the uniqueness of data values that are
contained in a column. High cardinality is nothing but the column contains a large
percentage of totally unique values. Low cardinality is nothing but the column which has
a lot of “repeats” in its data range.
Cardinality between the tables can be of type one-to-one, many-to-one or many-to-
many.
Mapping Cardinality is expressed as the number of entities to which another entity can
be associated via a relationship set.
For 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

One-to-one relationship
One entity of A is associated with one entity of B.

Example
Given below is an example of the one-to-one relationship in the mapping cardinality.
Here, one department has one head of the department (HOD).

One-to-many relationship
An entity set A is associated with any number of entities in B with a possibility of zero
and entity in B is associated with at most one entity in A
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 27
Example
Given below is an example of the one-to-many relationship in the mapping cardinality.
Here, one department has many faculties.

Many-to-one relationship
An entity set A is associated with at most one entity in B and an entity set in B can be
associated with any number of entities in A with a possibility of zero.

Example
Given below is an example of the many-to-one relationship in the mapping cardinality.
Here, many faculties work in one department.

Many-to-many relationship
Many entities of A are associated with many entities of B.
An entity in A is associated with many entities of B and an entity in B is associated with
many entities of A.
Many to many=many to one + one to many

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 28
Example
Given below is an example of the many-to-many relationship in the mapping cardinality.
Here, many employees work on many projects.

Keys in DBMS
A key refers to an attribute/a set of attributes that help us identify a row (or tuple)
uniquely in a table (or relation). A key is also used when we want to establish
relationships between the different columns and tables of a relational database.
o Keys play an important role in the relational database.
o It is used to uniquely identify any record or row of data from the table. It is also
used to establish and identify relationships between tables.

For example, ID is used as a key in the Student table because it is unique for each
student. In the PERSON table, passport_number, license_number, SSN are keys since
they are unique for each person.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 29
Types of keys:

1. Primary key
o It is the first key used to identify one and only one instance of an entity uniquely.
An entity can contain multiple keys, as we saw in the PERSON table. The key
which is most suitable from those lists becomes a primary key.
o In the EMPLOYEE table, ID can be the primary key since it is unique for each
employee. In the EMPLOYEE table, we can even select License_Number and
Passport_Number as primary keys since they are also unique.
o For each entity, the primary key selection is based on requirements and
developers.

2. Candidate key
o A candidate key is an attribute or set of attributes that can uniquely identify a
tuple.
o Except for the primary key, the remaining attributes are considered a candidate
key. The candidate keys are as strong as the primary key.

For example: In the EMPLOYEE table, id is best suited for the primary key. The rest of
the attributes, like SSN, Passport_Number, License_Number, etc., are considered a
candidate key.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 30
3. Super Key
Super key is an attribute set that can uniquely identify a tuple. A super key is a superset
of a candidate key.

For example: In the above EMPLOYEE table, for(EMPLOEE_ID, EMPLOYEE_NAME),


the name of two employees can be the same, but their EMPLYEE_ID can't be the
same. Hence, this combination can also be a key.
The super key would be EMPLOYEE-ID (EMPLOYEE_ID, EMPLOYEE-NAME), etc.

4. Foreign key
o Foreign keys are the column of the table used to point to the primary key of
another table.
o Every employee works in a specific department in a company, and employee and
department are two different entities. So we can't store the department's
information in the employee table. That's why we link these two tables through
the primary key of one table.
o We add the primary key of the DEPARTMENT table, Department_Id, as a new
attribute in the EMPLOYEE table.
o In the EMPLOYEE table, Department_Id is the foreign key, and both the tables
are related.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 31
5. Alternate key
There may be one or more attributes or a combination of attributes that uniquely identify
each tuple in a relation. These attributes or combinations of the attributes are called the
candidate keys. One key is chosen as the primary key from these candidate keys, and
the remaining candidate key, if it exists, is termed the alternate key. In other words, the
total number of the alternate keys is the total number of candidate keys minus the
primary key. The alternate key may or may not exist. If there is only one candidate key
in a relation, it does not have an alternate key.

For example, employee relation has two attributes, Employee_Id and PAN_No, that act
as candidate keys. In this relation, Employee_Id is chosen as the primary key, so the
other candidate key, PAN_No, acts as the Alternate key.

6. Composite key
Whenever a primary key consists of more than one attribute, it is known as a composite
key. This key is also known as Concatenated Key.

For example, in employee relations, we assume that an employee may be assigned


multiple roles, and an employee may work on multiple projects simultaneously. So the
primary key will be composed of all three attributes, namely Emp_ID, Emp_role, and
Proj_ID in combination. So these attributes act as a composite key since the primary
key comprises more than one attribute.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 32
Entity Relationship Diagram
ER Diagram stands for Entity Relationship Diagram, also known as ERD is a diagram
that displays the relationship of entity sets stored in a database. In other words, ER
diagrams help to explain the logical structure of databases. ER diagrams are created
based on three basic concepts: entities, attributes and relationships.

ER Diagrams contain different symbols that use rectangles to represent entities, ovals
to define attributes and diamond shapes to represent relationships.

At first look, an ER diagram looks very similar to the flowchart. However, ER Diagram
includes many specialized symbols, and its meanings make this model unique. The
purpose of ER Diagram is to represent the entity framework infrastructure.

Why use ER Diagrams?


Here, are prime reasons for using the ER Diagram
 Helps you to define terms related to entity relationship modeling
 Provide a preview of how all your tables should connect, what fields are going to
be on each table
 Helps to describe entities, attributes, relationships
 ER diagrams are translatable into relational tables which allows you to build
databases quickly
 ER diagrams can be used by database designers as a blueprint for implementing
data in specific software applications
 The database designer gains a better understanding of the information to be
contained in the database with the help of ERP diagram
 ERD Diagram allows you to communicate with the logical structure of the
database to users

Facts about ER Diagram Model


 ER model allows you to draw Database Design
 It is an easy to use graphical tool for modeling data
 Widely used in Database Design
 It is a GUI representation of the logical structure of a Database
 It helps you to identifies the entities which exist in a system and the relationships
between those entities

ER Diagrams Symbols & Notations


Entity Relationship Diagram Symbols & Notations mainly contains three basic
symbols which are rectangle, oval and diamond to represent relationships between
elements, entities and attributes. There are some sub-elements which are based on
main elements in ERD Diagram. ER Diagram is a visual representation of data that
describes how data is related to each other using different ERD Symbols and Notations.

Following are the main components and its symbols in ER Diagrams:

 Rectangles: This Entity Relationship Diagram symbol represents entity types


 Ellipses : Symbol represent attributes
 Diamonds: This symbol represents relationship types

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 33
 Lines: It links attributes to entity types and entity types with other relationship
types
 Primary key: attributes are underlined
 Double Ellipses: Represent multi-valued attributes

Components
ER diagram basically having three components:
 Entities − It is a real-world thing which can be a person, place, or even a concept.
For Example: Department, Admin, Courses, Teachers, Students, Building, etc are
some of the entities of a School Management System.
 Attributes − An entity which contains a real-world property called an attribute. For
Example: The entity employee has the property like employee id, salary, age, etc.
 Relationship − Relationship tells how two attributes are related. For Example:
Employee works for a department.

ER Diagram Examples
For example, in a University database, we might have entities for Students, Courses,
and Lecturers. Students entity can have attributes like Rollno, Name, and DeptID. They
might have relationships with Courses and Lecturers.

Entity
A real-world thing either living or non-living that is easily recognizable and non
recognizable. It is anything in the enterprise that is to be represented in our database. It
may be a physical thing or simply a fact about the enterprise or an event that happens
in the real world.

An entity can be place, person, object, event or a concept, which stores data in the
database. The characteristics of entities are must have an attribute, and a unique key.
Every entity is made up of some ‘attributes’ which represent that entity.

Examples of entities:
 Person: Employee, Student, Patient
 Place: Store, Building
 Object: Machine, product, and Car
 Event: Sale, Registration, Renewal
 Concept: Account, Course
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 34
Entity set:
An entity set is a group of similar kind of entities. It may contain entities with attribute
sharing similar values. Entities are represented by their properties, which also called
attributes. All attributes have their separate values. For example, a student entity may
have a name, age, class, as attributes.

Example of Entities:
A university may have some departments. All these departments employ various
lecturers and offer several programs.
An entity has a real-world property called attribute and these attributes are defined by a
set of values called domain.
Example 1
In a university,
 A student is an entity,
 University is the database,
 Name and age and sex are the attributes.
 The relationships among entities define the logical association between entities.
Example 2
Given below is another example of ER:

In the above example,


Entities − Employee and Department.
Attributes −
 Employee − Name, id, Age, Salary
 Department − Dept_id, Dept_name
The two entities are connected using the relationship. Here, each employee works for a
department.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 35
Features of ER Model
The features of ER Model are as follows −
 Graphical Representation is Better Understanding − It is easy and simple to
understand so it can be used by the developers to communicate with the
stakeholders.
 ER Diagram − ER diagrams are used as a visual tool for representing the model.
 Database Design − This model helps the database designers to build the
database.
Advantages
The advantages of ER Model are as follows −
 The ER model is easy to build.
 This model is widely used by database designers for communicating their ideas.
 This model can easily convert to any other model like network model, hierarchical
model etc.
 It is integrated with the dominant relational model.
Disadvantages
The disadvantages of ER Model are as follows −
 There is no industry standard for developing an ER model.
 Information might be lost or hidden in the ER model.
 There is no Data Manipulation Language (DML).
 There is limited relationship representation.

For example, Suppose we design a school database. In this database, the student will
be an entity with attributes like address, name, id, age, etc. The address can be another
entity with attributes like city, street name, pin code, etc and there will be a relationship
between them.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 36
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.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 37
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.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 38
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.

Types of relationship are as follows:


a. One-to-One Relationship
When only one instance of an entity is associated with the relationship, then it is known
as one to one relationship.
For example, A female can marry to one male, and a male can marry to one female.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 39
b. One-to-many 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 one-to-many
relationship.

For example, Scientist can invent many inventions, but the invention is done by the
only specific scientist.

c. Many-to-one 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 many-to-one
relationship.
For example, Student enrolls for only one course, but a course can have many
students.

d. Many-to-many 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 many-to-many
relationship.

For example, Employee can assign by many projects and project can have many
employees.

Using the above knowledge of how to make an ER diagram, we can make an ER


diagram for a hospital management system. We will have three entities i.e Doctor,
Patient, Medicine.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 40
In the above diagram, entity Doctor has key attribute 'doctor_id' which will be used to
identify the doctors. It also has two multivalued attributes as 'specialization' and
'qualification' as a doctor may have more than one qualification and may be
specialized in more than one fields. The Doctor and Patient entity have a one-to-many
relationship as a Doctor may treat more than one patient. Similarly, Patient and
Medicine have a many-to-many relationship as a patient may buy more than one
medicine and vice-versa. 'Code' is the key attribute for Medicine which is unique for
every medicine. The Patient has many attributes Patient_id, DOB, Age, etc. 'Age' is
the derived attribute here. Also, it has a composite attribute 'Address' which can
further be divided into two attributes 'Locality' and 'Town'.

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.
 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.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 41
Disadvantages 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.
What is an Entity, Entity Type and Entity Set?
 Entity
An entity is a real-world thing which can be distinctly identified like a person, place or
a concept. It is an object which is distinguishable from others. If we cannot distinguish
it from others then it is an object but not an entity. An entity can be of two types:

Tangible Entity: Tangible Entities are those entities which exist in the real world
physically. Example: Person, car, etc.

Intangible Entity: Intangible Entities are those entities which exist only logically and
have no physical existence. Example: Bank Account, etc.

Example: If we have a table of a Student (Roll_no, Student_name, Age, Mobile_no)


then each student in that table is an entity and can be uniquely identified by their Roll
Number i.e Roll_no.

Note : In E-R model we don't represent the data but we represent the structure or schema.
When we convert E-R model to relational model then data can be stored in tuple or row and
hence, represented as an entity.

Entity Type
The entity type is a collection of the entity having similar attributes. In the above
Student table example, we have each row as an entity and they are having common
attributes i.e each row has its own value for attributes Roll_no, Age, Student_name
and Mobile_no. So, we can define the above STUDENT table as an entity type
because it is a collection of entities having the same attributes. So, an entity type in
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 42
an ER diagram is defined by a name(here, STUDENT) and a set of
attributes(here, Roll_no, Student_name, Age, Mobile_no). The table below shows
how the data of different entities( different students) are stored.

The E-R representation of the above Student Entity Type is done below.

Note: We use a rectangle to represent an entity type in the E-R diagram, not entity.

Types of Entity type


 Strong Entity Type
 Weak Entity Type
Strong Entity Type: Strong entity are those entity types which has a key attribute.
The primary key helps in identifying each entity uniquely. It is represented by a
rectangle. In the above example, Roll_no identifies each element of the table uniquely
and hence, we can say that STUDENT is a strong entity type.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 43
Weak Entity Type : Weak entity type doesn't have a key attribute. Weak entity type
can't be identified on its own. It depends upon some other strong entity for its distinct
identity. This can be understood with a real-life example. There can be children only if
the parent exits. There can be no independent existence of children. There can be a
room only if building exits. There can be no independent existence of a room. A weak
entity is represented by a double outlined rectangle. The relationship between a weak
entity type and strong entity type is called an identifying relationship and shown with a
double outlined diamond instead of a single outlined diamond. This representation can
be seen in the diagram below.

Example : If we have two tables of Customer(Customer_id, Name, Mobile_no, Age,


Gender) and Address(Locality, Town, State, Customer_id). Here we cannot identify
the address uniquely as there can be many customers from the same locality. So, for
this, we need an attribute of Strong Entity Type i.e ‘Customer’ here to uniquely identify
entities of 'Address' Entity Type.

Entity Set
Entity Set is a collection of entities of the same entity type. In the above example of
STUDENT entity type, a collection of entities from the Student entity type would form
an entity set. We can say that entity type is a superset of the entity set as all the
entities are included in the entity type. Let's try to understand this with the help of
an example.
Example 1: In the below example, two entities E1 (2, Angel, 19, 8709054568) and
E2(4, Analisa, 21, 9847852156) form an entity set.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 44
Example 2: We can form another entity set by taking three entities from the table. (2,
Angel, 19, 8709054568) , (3, Priya, 20, 9864257315) and (4, Analisa, 21,
9847852156) can also form a entity set. Similary, we can form any combination of the
entity set using any of the entities from the entity type 'STUDENT'. Also, we can
understand that if we take all the records to the entity set we get the entity type
'STUDENT'. So, we can say that the entity type is the superset of the entity set.

Enhanced ER Model (EER)

Enhanced ER models are advanced database diagrams that are very similar to regular
ER diagrams which represent the requirements and complexities of complex databases.
In a nutshell, it is a hybrid of ER models with some additional complexities.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 45
The Enhanced ER Diagram is a diagrammatic technique used to represent Enhanced
ER Models. They show Sub Class and Super Class, Specialization and Generalization,
Union or Category, Aggregation, and so on.

For Example, The following “sub-class” relationships. There are three types of
employees here: Secretary, Technician, and Engineer. Employee is the super-class of
the other three sets of individual sub-classes, each of which is a subset of the Employee
set.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 46
The Enhanced ER Model:

ER Models
An Entity-Relationship (ER) diagram is a visual representation of data based on the ER
model that describes how entities in the database are related to one another. It is most
commonly used in database or information system organizations.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 47
Whereas, Enhanced Entity-relationship (EER) Models are essentially expanded upon
ER Models. Enhanced ER models are useful tools for creating high-level models for
databases. With their improved features, you can plan databases more thoroughly by
delving deeper into the properties and constraints.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 48
An Enhanced ER diagram includes all of the elements of an ER diagram as well as the
following:
 Inheritance of attributes or relationships
 Categories or union types
 Generalization and Specialization
 Superclasses and Subclasses

An EER diagram expands on an ER diagram by including elements that allow for


aggregation, generalization, and specialization.

Features of EER Model

 EER creates a design more accurate to database schemas.


 It reflects the data properties and constraints more precisely.
 It includes all modeling concepts of the ER model.
 Diagrammatic technique helps for displaying the EER schema.
 It includes the concept of specialization and generalization.
 It is used to represent a collection of objects that is union of objects of different of
different entity types.

Advantages of Enhanced ER Models in DBMS


The advantages of Enhanced ER Models are as follows:
 It is quite simple to develop and maintain. In addition to this, it is easy to
understand and interpret as well, technically speaking.
 Everything that is visually represented is easier to understand and maintain, and
the same goes for Enhanced ER models. It has been an efficient tool for
database designers.
 Moreover, Enhanced ER Model serves as a communication tool and helps
display the relationship between entities.
 You can always convert the Enhanced ER model into a table. Thus, it can easily
be integrated into a relational model.

Limitations of Enhanced ER Models in DBMS


The limitations of Enhanced ER Models are as follows:
 The Pareto Chart cannot be applied to all issues.
 Faults in data scoring are possible. There may also be instances of errors in the
application.

4 Diagrammatic Techniques Utilized in Enhanced ER Models


The concepts and techniques that are used in the design of Enhanced ER Models are
as follows:
 Superclass and Subclass
 Specialization and Generalization
 Category or Union
 Aggregation

A. Sub Class and Super Class


Sub class and Super class relationship leads the concept of Inheritance.

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 49
1. Super Class
 Super class is an entity type that has a relationship with one or more subtypes.
 An entity cannot exist in database merely by being member of any super class.
For example: Shape super class is having sub groups as Square, Circle, Triangle.

2. Sub Class
 Sub class is a group of entities with unique attributes.
 Sub class inherits properties and attributes from its super class.
For example: Square, Circle, Triangle are the sub class of Shape super class.

Attribute Inheritance
When a subclass inherits from one or more superclasses, it inherits all their
attributes. In addition to the inherited attributes, a subclass can also define its own
specific attributes. A subclass also inherits participation in the relationship sets in which
its superclass (higher-level entity) participates.

Attribute Inheritance
The attributes of a higher level entity set are inherited through a lower level entity set
made by specialization-generalization hierarchy. Namely, all the attributes of the higher
level entity set are as well the attributes of the lower level entity set.
B. Specialization and Generalization
1. Generalization
 Generalization is the process of generalizing the entities which contain the properties of
all the generalized entities.
 It is a bottom approach, in which two lower level entities combine to form a higher level
entity.
 Generalization is the reverse process of Specialization.
 It defines a general entity type from a set of specialized entity type.
 It minimizes the difference between the entities by identifying the common features.

For example:

-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 50
In the above example, Tiger, Lion, Elephant can all be generalized as Animals.

2. Specialization

 Specialization is a process that defines a group entities which is divided into sub
groups based on their characteristic.
 It is a top down approach, in which one higher entity can be broken down into two lower
level entity.
 It maximizes the difference between the members of an entity by identifying the unique
characteristic or attributes of each member.
 It defines one or more sub class for the super class and also forms the
superclass/subclass relationship.
For example

In the above example, Employee can be specialized as Developer or Tester, based on


what role they play in an Organization.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 51
C. Category or Union
 Category represents a single super class or sub class relationship with more than one
super class.
 It can be a total or partial participation.
For example Car booking, Car owner can be a person, a bank (holds a possession on
a Car) or a company. Category (sub class) → Owner is a subset of the union of the
three super classes → Company, Bank, and Person. A Category member must exist in
at least one of its super classes.

D. Aggregation
 Aggregation is a process that represents a relationship between a whole object and its
component parts.
 It abstracts a relationship between objects and viewing the relationship as an object.
 It is a process when two entities are treated as a single entity.

In the above example, the relation between College and Course is acting as an Entity in
Relation with Student.
-------------------------------------------------------------------------------------------------------------------------------
Database Management System (Unit-II) Prof. Ratna Biswas Page- 52

You might also like