0% found this document useful (0 votes)
14 views

DBMS-1 unit notes

Data refers to raw facts and statistics, while information is processed data that provides meaning. A Database is a structured collection of related data, managed by a Database Management System (DBMS) that allows for easy access and manipulation. Various database models exist, including hierarchical, network, relational, object-oriented, NoSQL, and graph models, each with its own advantages and use cases.

Uploaded by

Chaitanya Sharma
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)
14 views

DBMS-1 unit notes

Data refers to raw facts and statistics, while information is processed data that provides meaning. A Database is a structured collection of related data, managed by a Database Management System (DBMS) that allows for easy access and manipulation. Various database models exist, including hierarchical, network, relational, object-oriented, NoSQL, and graph models, each with its own advantages and use cases.

Uploaded by

Chaitanya Sharma
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/ 45

What is Data?

Data is nothing but facts and statistics stored or free flowing over a
network, generally it's raw and unprocessed. For example: When
you visit any website, they might store you IP address, that is data,
in return they might add a cookie in your browser, marking you that
you visited the website, that is data, your name, it's data, your age,
it's data.

Data becomes information when it is processed, turning it into


something meaningful. Like, based on the cookie data saved on
user's browser, if a website can analyse that generally men of age
20-25 visit us more, that is information, derived from the data
collected.

What is a Database?
A Database is a collection of related data organised in a way that
data can be easily accessed, managed and updated. Database can
be software based or hardware based, with one sole purpose,
storing data.

During early computer days, data was collected and stored on tapes,
which were mostly write-only, which means once data is stored on it,
it can never be read again. They were slow and bulky, and soon
computer scientists realised that they needed a better solution to
this problem.

Larry Ellison, the co-founder of Oracle was amongst the first few,
who realised the need for a software based Database Management
System.

What is DBMS?

A DBMS is a software that allows creation, definition and


manipulation of database, allowing users to store, process and
analyse data easily. DBMS provides us with an interface or a tool, to
perform various operations like creating database, storing data in it,
updating data, creating tables in the database and a lot more.

DBMS also provides protection and security to the databases. It


also maintains data consistency in case of multiple users.

Here are some examples of popular DBMS used these days:

 MySql

 Oracle

 SQL Server

 IBM DB2

 PostgreSQL

 Amazon SimpleDB (cloud based) etc.

Characteristics of Database Management System

A database management system has following characteristics:

1. Data stored into Tables: Data is never directly stored into the
database. Data is stored into tables, created inside the
database. DBMS also allows to have relationships between
tables which makes the data more meaningful and connected.
You can easily understand what type of data is stored where
by looking at all the tables created in a database.

2. Reduced Redundancy: In the modern world hard drives are


very cheap, but earlier when hard drives were too expensive,
unnecessary repetition of data in database was a big problem.
But DBMS follows Normalisation which divides the data in
such a way that repetition is minimum.

3. Data Consistency: On Live data, i.e. data that is being


continuosly updated and added, maintaining the consistency
of data can become a challenge. But DBMS handles it all by
itself.

4. Support Multiple user and Concurrent Access: DBMS allows


multiple users to work on it(update, insert, delete data) at the
same time and still manages to maintain the data consistency.

5. Query Language: DBMS provides users with a simple Query


language, using which data can be easily fetched, inserted,
deleted and updated in a database.

6. Security: The DBMS also takes care of the security of data,


protecting the data from un-authorised access. In a typical
DBMS, we can create user accounts with different access
permissions, using which we can easily secure our data by
restricting user access.

7. DBMS supports transactions, which allows us to better handle


and manage data integrity in real world applications where
multi-threading is extensively used.

Advantages of DBMS

 Segregation of application program.

 Minimal data duplicacy or data redundancy.

 Easy retrieval of data using the Query Language.

 Reduced development time and maintainance need.

 With Cloud Datacenters, we now have Database Management


Systems capable of storing almost infinite data.

 Seamless integration into the application programming


languages which makes it very easier to add a database to
almost any application or website.

Disadvantages of DBMS
 It's Complexity

 Except MySQL, which is open source, licensed DBMSs are


generally costly.

 They are large in size.

Components of DBMS
The database management system can be divided into five major
components, they are:

1. Hardware

2. Software

3. Data

4. Procedures

5. Database Access Language


Let's have a simple diagram to see how they all fit together to form
a database management system.

DBMS Components: Hardware

When we say Hardware, we mean computer, hard disks, I/O


channels for data, and any other physical component involved
before any data is successfully stored into the memory.

When we run Oracle or MySQL on our personal computer, then our


computer's Hard Disk, our Keyboard using which we type in all the
commands, our computer's RAM, ROM all become a part of the
DBMS hardware.
DBMS Components: Software

This is the main component, as this is the program which controls


everything. The DBMS software is more like a wrapper around the
physical database, which provides us with an easy-to-use interface
to store, access and update data.

The DBMS software is capable of understanding the Database


Access Language and interpret it into actual database commands
to execute them on the DB.

DBMS Components: Data

Data is that resource, for which DBMS was designed. The motive
behind the creation of DBMS was to store and utilise data.

In a typical Database, the user saved Data is present and meta


data is stored.

Metadata is data about the data. This is information stored by the


DBMS to better understand the data stored in it.

For example: When I store my Name in a database, the DBMS will


store when the name was stored in the database, what is the size of
the name, is it stored as related data to some other data, or is it
independent, all this information is metadata.

DBMS Components: Procedures

Procedures refer to general instructions to use a database


management system. This includes procedures to setup and install
a DBMS, To login and logout of DBMS software, to manage
databases, to take backups, generating reports etc.

DBMS Components: Database Access Language

Database Access Language is a simple language designed to write


commands to access, insert, update and delete data stored in any
database.

A user can write commands in the Database Access Language and


submit it to the DBMS for execution, which is then translated and
executed by the DBMS.

User can create new databases, tables, insert data, fetch stored
data, update data and delete the data using the access language.

Users

 Database Administrators: Database Administrator or DBA is


the one who manages the complete database management
system. DBA takes care of the security of the DBMS, it's
availability, managing the license keys, managing user
accounts and access etc.

 Application Programmer or Software Developer: This user


group is involved in developing and desiging the parts of
DBMS.

 End User: These days all the modern applications, web or


mobile, store user data. How do you think they do it? Yes,
applications are programmed in such a way that they collect
user data and store the data on DBMS systems running on
their server. End users are the one who store, retrieve, update
and delete data.

DBMS Architecture
A Database Management system is not always directly available for
users and applications to access and store data in it. A Database
Management system can be centralised(all the data stored at one
location), decentralised(multiple copies of database at different
locations) or hierarchical, depending upon its architecture.

1-tier DBMS architecture also exist, this is when the database is


directly available to the user for using it to store data. Generally
such a setup is used for local application development, where
programmers communicate directly with the database for quick
response.

Database Architecture is logically of two types:

1. 2-tier DBMS architecture

2. 3-tier DBMS architecture

2-tier DBMS Architecture

2-tier DBMS architecture includes an Application layer between the


user and the DBMS, which is responsible to communicate the user's
request to the database management system and then send the
response from the DBMS to the user.

An application interface known as ODBC (Open Database


Connectivity) provides an API that allow client side program to call
the DBMS. Most DBMS vendors provide ODBC drivers for their
DBMS.

Such an architecture provides the DBMS extra security as it is not


exposed to the End User directly. Also, security can be improved by
adding security and authentication checks in the Application layer
too.

3-tier DBMS Architecture

3-tier DBMS architecture is the most commonly used architecture


for web applications.

It is an extension of the 2-tier architecture. In the 2-tier architecture,


we have an application layer which can be accessed
programatically to perform various operations on the DBMS. The
application generally understands the Database Access Language
and processes end users requests to the DBMS.

In 3-tier architecture, an additional Presentation or GUI Layer is


added, which provides a graphical user interface for the End user to
interact with the DBMS.

For the end user, the GUI layer is the Database System, and the end
user has no idea about the application layer and the DBMS system.
If you have used MySQL, then you must have seen PHP MyAdmin, it
is the best example of a 3-tier DBMS architecture.

Types of Database Model


A Database model defines the logical design and structure of a database. It defines
how data will be stored, accessed, and updated in a database management system.

 As per your application's requirement, you can use a database model to define
your database.
 The database model sets the rule, relationships, constraints, etc. to define
how data is stored in the database.
 It's like creating a blueprint of your Database.
 There are different types of Database models and each one has its own set of
features.
 You can define how you want to structure the application data using a
database model.

In this tutorial you will learn about the 7 database model that are popularly used.

Type of Database models


There are several different Database model types, some of them are old, while some
of them are new, to cater to the new age requirements. Here is a list of the 7 popular
Database models:

1. Hierarchical Model
2. Network Model
3. Entity-relationship Model
4. Relational Model
5. Object-oriented Model
6. NoSQL Model
7. Graph Model

Let's learn about the different types of database models along with their main
features and when should you use them.

1. Hierarchical Model
 The hierarchical database model organizes data into a tree-like structure, with
a single root, to which all the other data is linked.
 The hierarchy starts from the Root data, and expands like a tree,
adding child nodes to the parent nodes.
 In this model, a child node will only have a single parent node.
 This model efficiently describes many real-world relationships like the index
of a book, etc.
 IBM's Information Management System (IMS) is based on this model.
 Data is organized into a tree-like structure with a one-to-many
relationship between two different types of data, for example,
one department can have many courses, many teachers, and of course
many students (like shown in the diagram below).

Advantages/Disadvantages of the Hierarchical Model

Here are a few points to mark the advantages and disadvantages of the Hierarchical
database model:

1. Because it has one-to-many relationships between different types of data so it


is easier and fast to fetch the data.
2. But the Hierarchical model is less flexible.
3. And it doesn't support many-to-many relationships.

2. Network Model
 The Network Model is an extension of the Hierarchical model.
 In this model, data is organized more like a graph, and allowed to have more
than one parent node.
 In the network database model, data is more related as more relationships
are established in this database model.
 Also, as the data is more related, hence accessing the data is also
easier and fast.
 This database model uses many-to-many data relationships.
 Integrated Data Store (IDS) is based on this database model.
 This was the most widely used database model before Relational Model was
introduced.
 The implementation of the Network model is complex, and it's very difficult to
maintain it.
 The Network model is difficult to modify also.
 You may want to explore this if you are developing some social networking
applications, although the Graph Database model is new and is far better than
the Network Database model.

Advantages of the Network Model

1. It supports complex relationships


2. It allows more flexibility
3. Entity-relationship Model
 In this database model, relationships are created by dividing objects of
interest into entities and their characteristics into attributes.
 Different entities are related using relationships.
 ER Models are defined to represent the relationships in pictorial form to make
it easier for different stakeholders to understand.
 This model is good to design a database, which can then be turned into tables
in a relational model (explained below).
 Let's take an example, If we have to design a School Database, then
the Student will be an entity with attributes name, age, address, etc. As
an Address is generally complex, it can be
another entity with attributes street, pincode, city, etc, and there will be a
relationship between them.
 Relationships can also be of different types. You can learn about ER
Diagrams in detail if you want to learn about entities and relationships.

Advantages of the ER Model

1. It is easy to understand and design.


2. Using the ER model we can represent data structures easily.
3. As the ER model cannot be directly implemented into a database model, it is
just a step toward designing the relational database model.

4. Relational Model
 In this model, data is organized in two-dimensional tables and the relationship
is maintained by storing a common field.
 This model was introduced by E.F Codd in 1970, and since then it has been
the most widely used database model.
 The basic structure of data in the relational model is tables. All the
information related to a particular type is stored in rows of that table.
 Hence, tables are also known as relations in the relational model.
 You can design tables, normalize them to reduce data redundancy,
and use Structured Query language or SQL to access data from the tables.
 Some of the most popular databases are based on this database model. For
example, Oracle, MySQL, etc.

Advantages of the Relational Model

1. It's simple and easy to implement.


2. Poplar database software is available for this database model.
3. It supports SQL using which you can easily query the data.

5. Object-oriented Model
 In this model, data is stored in the form of objects.
 The behavior of the object-oriented database model is just like object-oriented
programming.
 A very popular example of an Object Database management system
or ODBMS is MongoDB which is also a NoSQL database.
 This database model is not mature enough as compared to the relational
database model.
Advantages of the Object-oriented Model

1. It can easily support complex data structures, with relationships.


2. It also supports features like Inheritance, Encapsulation, etc.

6. NoSQL Model
 The NoSQL database model supports an unstructured style of storing data.
 Data is stored as documents.
 The documents look more like JSON strings or Key-value based object
representations.
 It provides a flexible schema.
 It does provide features like indexing, relationships between data, etc.
 The support for data querying is limited in the NoSQL database model.
 This database model is well-suited for Big data applications, real-time
analytics, CMS (Content Management systems), etc.
Advantages of the NoSQL Model

1. This database model is scalable.


2. This database model functions with high performance.
3. The NoSQL database model can handle large volumes of data.

7. Graph Model
 The Graph database model is based on more real-world like relationships.
 Data is represented using Nodes or entities.
 The nodes are related using edges.
 The popular database Neo4j is based on the Graph database model.
 If your application has simple data requirements, then you should not use the
graph database model.
 In modern applications like social networks, recommendation systems, etc.
the graph database model is well-suited.
Advantages of the Graph Model

1. It handles complex relationships very well.


2. In the modern world where there is so much data and the data has to be
related in different ways, the graph database model is very useful.

View of Data in DBMS


View of data in DBMS narrate how the data is visualized at each level of
data abstraction? Data abstraction allow developers to keep complex data
structures away from the users. The developers achieve this by hiding the
complex data structures through levels of abstraction.

There is one more feature that should be kept in mind i.e. the data
independence. While changing the data schema at one level of the
database must not modify the data schema at the next level. In this section,
we will discuss the view of data in DBMS with data abstraction, data
independence, data schema in detail.

Content: View of Data in DBMS


1. Data Abstraction
2. Data Independence
3. Instance and Schema
Data Abstraction
Data abstraction is hiding the complex data structure in order to simplify
the user’s interface of the system. It is done because many of the users
interacting with the database system are not that much computer trained
to understand the complex data structures of the database system.

To achieve data abstraction, we will discuss a Three-Schema


architecture which abstracts the database at three levels discussed below:

Three-Schema Architecture:
The main objective of this architecture is to have an effective separation
between the user interface and the physical database. So, the user never
has to be concerned regarding the internal storage of the database and it
has a simplified interaction with the database system.

The three-schema architecture defines the view of data at three levels:

1. Physical level (internal level)


2. Logical level (conceptual level)
3. View level (external level)

1. Physical Level/ Internal Level

The physical or the internal level schema describes how the data is stored
in the hardware. It also describes how the data can be accessed. The
physical level shows the data abstraction at the lowest level and it
has complex data structures. Only the database administrator operates at
this level.

2. Logical Level/ Conceptual Level

It is a level above the physical level. Here, the data is stored in the form of
the entity set, entities, their data types, the relationship among the entity
sets, user operations performed to retrieve or modify the data and
certain constraints on the data. Well adding constraints to the view of data
adds the security. As users are restricted to access some particular parts
of the database.

It is the developer and database administrator who operates at the logical


or the conceptual level.

3. View Level/ User level/ External level


It is the highest level of data abstraction and exhibits only a part of the
whole database. It exhibits the data in which the user is interested. The
view level can describe many views of the same data. Here, the user
retrieves the information using different application from the database.

The figure below describes the three-schema architecture of the database:

In the figure above you can clearly distinguish between the three levels of
abstraction. To understand it more clearly let us take an example:

We have to create a database of a college. Now, what entity sets would be


involved? Student, Lecturer, Department, Course and so on…

Now, the entity sets Student, Lecturer, Department, Course will be stored in
the storage as the consecutive blocks of the memory location. This is
the physical or internal level and is hidden from the programmers but the
database administrator is it aware of it.
At the logical level, the programmers define the entity sets and relationship
among these entity sets using a programming language like SQL. So, the
programmers work at the logical level and even the database administrator
also operates at this level.

At the view level, the users have the set of applications which they use to
retrieve the data they are interested in.

Data Independence
Data independence defines the extent to which the data schema can be
changed at one level without modifying the data schema at the next level.
Data independence can be classified as shown below:

Logical Data Independence:


Logical data independence describes the degree up to which the logical or
conceptual schema can be changed without modifying the external
schema. Now, a question arises what is the need to change the data
schema at a logical or conceptual level?

Well, the changes to data schema at the logical level are made either
to enlarge or reduce the database by adding or deleting more entities,
entity sets, or changing the constraints on data.

Physical Data Independence:


Physical data independence defines the extent up to which the data
schema can be changed at the physical or internal level without modifying
the data schema at logical and view level.

Well, the physical schema is changed if we add additional storage to the


system or we reorganize some files to enhance the retrieval speed of the
records.

Instances and Schemas


What is an instance?
We can define an instance as the information stored in the database at a
particular point of time. Let us discuss it with the help of an example.
As we discussed above the database comprises of several entity sets and
the relationship between them. Now, the data in the database keeps on
changing with time. As we keep inserting or deleting the data to and from
the database.

Now, at a particular time if we retrieve any information from the database


then that corresponds to an instance.

What is schema?
Whenever we talk about the database the developers have to deal with the
definition of database and the data in the database.

The definition of a database comprises of the description of what data it


would contain what would be the relationship between the data. This
definition is the database schema.

Key Takeaways:
 View of data in DBMS describes the abstraction of data at three-level
i.e. physical level, logical level, view level.
 The physical level of abstraction defines how data is stored in the storage
and also reveals its access path.
 Abstraction at the logical level describes what data would be stored in the
database? what would be the relation between the data? and
the constraints applied to the data.
 The view level or external level of abstraction describes
the application which the users use to retrieve the information from the
database.
 Data independence explains the extent to which data at a certain level can
be modified without disturbing the data next higher levels.
 An instance is the retrieval of information from the database at a certain
point of time. An instance in a database keeps on changing with time.
 Schema is the overall design of the entire database. Schema of the
database is not changed frequently.

So that’s all about the view of data in the database which help us to
understand the database from users, developers and database
administrator aspects.

Difference between File System and DBMS



The file system is basically a way of arranging the files in a storage medium
like a hard disk. The file system organizes the files and helps in the retrieval of
files when they are required. File systems consist of different files which are
grouped into directories. The directories further contain other folders and files.
The file system performs basic operations like management, file naming,
giving access rules, etc.

Example: NTFS(New Technology File System), EXT(Extended File System).

File System

DBMS(Database Management System)


Database Management System is basically software that manages the
collection of related data. It is used for storing data and retrieving the data
effectively when it is needed. It also provides proper security measures for
protecting the data from unauthorized access. In Database Management
System the data can be fetched by SQL queries and relational algebra. It also
provides mechanisms for data recovery and data backup.

Example:
Oracle, MySQL, MS SQL server.
DBMS

Difference between File System and DBMS


Basics File System DBMS

The file system is a way of


DBMS is software for
arranging the files in a storage
managing the database.
Structure medium within a computer.

Data Redundant data can be In DBMS there is no


Redundancy present in a file system. redundant data.

It doesn’t provide Inbuilt It provides in house tools


Backup and mechanism for backup and for backup and recovery of
Recovery recovery of data if it is lost. data even if it is lost.

Query There is no efficient query Efficient query processing


processing processing in the file system. is there in DBMS.

There is more data


There is less data consistency
consistency because of the
in the file system.
Consistency process of normalization.

It is less complex as It has more complexity in


Complexity compared to DBMS. handling as compared to
Basics File System DBMS

the file system.

File systems provide less DBMS has more security


Security security in comparison to mechanisms as compared
Constraints DBMS. to file systems.

It has a comparatively
It is less expensive than
higher cost than a file
DBMS.
Cost system.

In DBMS data
independence exists,
mainly of two types:
There is no data
1) Logical Data
independence.
Independence.
Data 2)Physical Data
Independence Independence.

Only one user can access Multiple users can access


User Access data at a time. data at a time.

The user has to write


The users are not required to
procedures for managing
write procedures.
Meaning databases

Data is distributed in many


Due to centralized nature
files. So, it is not easy to share
data sharing is easy
Sharing data.

Data It give details of storage and It hides the internal details


Abstraction representation of data of Database

Integrity Integrity Constraints are Integrity constraints are


Constraints difficult to implement easy to implement

To access data in a file , user


No such attributes are
requires attributes such as file
required.
Attributes name, file location.

Example Cobol, C++ Oracle, SQL Server


The main difference between a file system and a DBMS (Database
Management System) is the way they organize and manage data.
1. File systems are used to manage files and directories, and provide basic
operations for creating, deleting, renaming, and accessing files. They
typically store data in a hierarchical structure, where files are organized in
directories and subdirectories. File systems are simple and efficient, but
they lack the ability to manage complex data relationships and ensure data
consistency.
2. On the other hand, DBMS is a software system designed to manage large
amounts of structured data, and provide advanced operations for storing,
retrieving, and manipulating data. DBMS provides a centralized and
organized way of storing data, which can be accessed and modified by
multiple users or applications. DBMS offers advanced features like data
validation, indexing, transactions, concurrency control, and backup and
recovery mechanisms. DBMS ensures data consistency, accuracy, and
integrity by enforcing data constraints, such as primary keys, foreign keys,
and data types.
In summary, file systems are suitable for managing small amounts of
unstructured data, while DBMS is designed for managing large amounts of
structured data, and offers more advanced features for ensuring data integrity,
security, and performance.

Data Independence
o Data independence can be explained using the three-schema architecture.
o Data independence refers characteristic of being able to modify the schema at one
level of the database system without altering the schema at the next higher level.

There are two types of data independence:

1. Logical Data Independence


o Logical data independence refers characteristic of being able to change the
conceptual schema without having to change the external schema.
o Logical data independence is used to separate the external level from the conceptual
view.
o If we do any changes in the conceptual view of the data, then the user view of the
data would not be affected.
o Logical data independence occurs at the user interface level.
2. Physical Data Independence
o Physical data independence can be defined as the capacity to change the internal
schema without having to change the conceptual schema.
o If we do any changes in the storage size of the database system server, then the
Conceptual structure of the database will not be affected.
o Physical data independence is used to separate conceptual levels from the internal
levels.
o Physical data independence occurs at the logical interface level.

Fig: Data Independence

Difference between DBMS and RDBMS


Although DBMS and RDBMS both are used to store information in physical database
but there are some remarkable differences between them.

The main differences between DBMS and RDBMS are given below:
No. DBMS RDBMS

1) DBMS applications store data as file. RDBMS applications store data in a tabular form.

2) In DBMS, data is generally stored in In RDBMS, the tables have an identifier called primary ke
either a hierarchical form or a and the data values are stored in the form of tables.
navigational form.

3) Normalization is not present in DBMS. Normalization is present in RDBMS.

4) DBMS does not apply any security with RDBMS defines the integrity constraint for the purpos
regards to data manipulation. of ACID (Atomocity, Consistency, Isolation and Durability
property.

5) DBMS uses file system to store data, in RDBMS, data values are stored in the form of tables, s
so there will be no relation between a relationship between these data values will be stored i
the tables. the form of a table as well.

6) DBMS has to provide some uniform RDBMS system supports a tabular structure of the dat
methods to access the stored and a relationship between them to access the store
information. information.

7) DBMS does not support distributed RDBMS supports distributed database.


database.

8) DBMS is meant to be for small RDBMS is designed to handle large amount of data.
organization and deal with small data. supports multiple users.
it supports single user.

9) Examples of DBMS are file Example of RDBMS are mysql, postgre, sq


systems, xml etc. server, oracle etc.

After observing the differences between DBMS and RDBMS, you can say that RDBMS
is an extension of DBMS. There are many software products in the market today who
are compatible for both DBMS and RDBMS. Means today a RDBMS application is
DBMS application and vice-versa.

Notation of ER diagram
Database can be represented using the notations. In ER diagram, many notations are
used to express the cardinality. These notations are as follows:
Fig: Notations of ER diagram

ER (Entity Relationship) Diagram in DBMS

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

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
Backward Skip 10sPlay VideoForward Skip 10s

An entity that depends on another entity called a weak entity. The weak entity doesn't
contain any key attribute of its own. The weak entity is represented by a double
rectangle.

2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to
represent an attribute.

For example, id, age, contact number, name, etc. can be attributes of a student.

a. Key Attribute

The key attribute is used to represent the main characteristics of an entity. It


represents a primary key. The key attribute is represented by an ellipse with the text
underlined.
b. Composite Attribute

An attribute that composed of many other attributes is known as a composite


attribute. The composite attribute is represented by an ellipse, and those ellipses are
connected with an ellipse.

c. Multivalued Attribute

An attribute can have more than one value. These attributes are known as a
multivalued attribute. The double oval is used to represent multivalued attribute.

For example, a student can have more than one phone number.
d. Derived Attribute

An attribute that can be derived from other attribute is known as a derived attribute.
It can be represented by a dashed ellipse.

For example, A person's age changes over time and can be derived from another
attribute like Date of birth.

3. Relationship
A relationship is used to describe the relation between entities. Diamond or rhombus
is used to represent the relationship.
Types of relationship are as follows:

a. One-to-One Relationship

ADVERTISEMENT

ADVERTISEMENT

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.

ADVERTISEMENT

ADVERTISEMENT

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.

ADVERTISEMENT

ADVERTISEMENT

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.

Notation of ER diagram
Database can be represented using the notations. In ER diagram, many notations are
used to express the cardinality. These notations are as follows:
Fig: Notations of ER diagram

Cardinality in DBMS (Mapping Constraints)


DBMS
DBMS stands for Database Management System, which is a tool, or a software used
to do various operations on a Database like the Creation of the Database, Deletion of
the Database, or Updating the current Database. To simplify processing and data
querying, the most popular types of Databases currently in use typically model their
data as rows and columns in a set of tables. The data may then be handled, updated,
regulated, and structured with ease. For writing and querying data, most Databases
employ Structured Query Language (SQL).

Cardinality
Cardinality means how the entities are arranged to each other or what is the
relationship structure between entities in a relationship set. In a Database
Management System, Cardinality represents a number that denotes how many times
an entity is participating with another entity in a relationship set. The Cardinality of
DBMS is a very important attribute in representing the structure of a Database. In a
table, the number of rows or tuples represents the Cardinality.

Cardinality Ratio
Cardinality ratio is also called Cardinality Mapping, which represents the mapping of
one entity set to another entity set in a relationship set. We generally take the
example of a binary relationship set where two entities are mapped to each other.

Cardinality is very important in the Database of various businesses. For example, if


we want to track the purchase history of each customer then we can use the one-to-
many cardinality to find the data of a specific customer. The Cardinality model can
be used in Databases by Database Managers for a variety of purposes, but
corporations often use it to evaluate customer or inventory data.

ADVERTISEMENT

ADVERTISEMENT

There are four types of Cardinality Mapping in Database Management Systems:

1. One to one
2. Many to one
3. One to many
4. Many to many

One to One
One to one cardinality is represented by a 1:1 symbol. In this, there is at most one
relationship from one entity to another entity. There are a lot of examples of one-to-
one cardinality in real life databases.

For example, one student can have only one student id, and one student id can
belong to only one student. So, the relationship mapping between student and
student id will be one to one cardinality mapping.

Another example is the relationship between the director of the school and the
school because one school can have a maximum of one director, and one director
can belong to only one school.
Note: it is not necessary that there would be a mapping for all entities in an entity set in
one-to-one cardinality. Some entities cannot participate in the mapping.

Many to One Cardinality:


In many to one cardinality mapping, from set 1, there can be multiple sets that can
make relationships with a single entity of set 2. Or we can also describe it as from
set 2, and one entity can make a relationship with more than one entity of set 1.

One to one Cardinality is the subset of Many to one Cardinality. It can be represented
by M:1.

For example, there are multiple patients in a hospital who are served by a single
doctor, so the relationship between patients and doctors can be represented by
Many to one Cardinality.

One to Many Cardinalities:


In One-to-many cardinality mapping, from set 1, there can be a maximum single set
that can make relationships with a single or more than one entity of set 2. Or we can
also describe it as from set 2, more than one entity can make a relationship with only
one entity of set 1.

One to one cardinality is the subset of One-to-many Cardinality. It can be represented


by 1: M.
For Example, in a hospital, there can be various compounders, so the relationship
between the hospital and compounders can be mapped through One-to-many
Cardinality.

Many to Many Cardinalities:


In many, many cardinalities mapping, there can be one or more than one entity that
can associate with one or more than one entity of set 2. In the same way from the
end of set 2, one or more than one entity can make a relation with one or more than
one entity of set 1.

It is represented by M: N or N: M.

One to one cardinality, One to many cardinalities, and Many to one cardinality is the
subset of the many to many cardinalities.

For Example, in a college, multiple students can work on a single project, and a
single student can also work on multiple projects. So, the relationship between the
project and the student can be represented by many to many cardinalities.

Appropriate Mapping Cardinality


Evidently, the real-world context in which the relation set is modeled determines the
Appropriate Mapping Cardinality for a specific relation set.

o We can combine relational tables with many involved tables if the Cardinality is one-
to-many or many-to-one.
o One entity can be combined with a relation table if it has a one-to-one relationship
and total participation, and two entities can be combined with their relation to form a
single table if both of them have total participation.
o We cannot mix any two tables if the Cardinality is many-to-many.

ER Diagram to Table Conversion


1. Strong Entity set with Simple attributes
The Strong Entity set becomes the table and the attributes of the Entity set becomes
the table attributes. The key attribute of the entity set becomes the primary key of
the table.
Let’s take an example: Here we have an entity set Employee with the attributes Name,
Age, Emp_Id and Salary. When we convert this ER diagram to table, the entity set
becomes table so we have a table named “Employee” as shown in the following
diagram. The attributes of the entity set becomes the attributes of the table.

2. Strong Entity Set With Composite Attributes


Now we will see how to convert Strong entity set with composite attributes ER to
table. The conversion is fairly simple in this case as well. The entity set will be the
table and the simple attributes of the composite attributes will become the attributes
of the table while the composite attribute itself will be ignored during conversion.

Let’s take an example. As you can see we have a composite attribute Name and this
composite attribute has two simple attributes First_N and Last_N. While converting
this ER to table we have not used the composite attribute itself in the table instead
we have used the simple attributes of this composite attribute as table’s attributes.
3. Strong Entity Set With Multi Valued Attributes
Entity set with multi-valued attributes will require two tables in the relational model.

We will understand this conversion with the help of a diagram. Let’s take the same
example that we have seen above, here we have added a new multi-valued
attribute Dept. An employee can work in multiple department so we have
this Dept attribute marked as multi-valued. Whenever we have a multi-valued attribute,
there needs to be more than one table to represent the ER diagram. As you can see
we have created two tables to represent this ER.
4. Relationship Set to Table conversion
While converting the relationship set to a table, the primary attributes of the two
entity sets becomes the table attributes and if the relationship set has any attribute
that also becomes the attribute of the table.

In the following example, we have two entity sets Employee and Department. These
entity sets are associated to each other using the Works relationship set. To convert
this relationship set Works to the table, we take the primary attributes of each entity
set, these are Emp_Id and Dept_Id and all the attributes of the relationship set and
form a table.
DBMS Specialization
Specialization is a process in which an entity is divided into sub-entities. You
can think of it as a reverse process of generalization, in generalization two
entities combine together to form a new higher level entity. Specialization is a
top-down process.

The idea behind Specialization is to find the subsets of entities that have few
distinguish attributes. For example – Consider an entity employee which can
be further classified as sub-entities Technician, Engineer & Accountant
because these sub entities have some distinguish attributes.

Specialization Example
In the above diagram, we can see that we have a higher level entity “Employee”
which we have divided in sub entities “Technician”, “Engineer” & “Accountant”.
All of these are just an employee of a company, however their role is
completely different and they have few different attributes. Just for the
example, I have shown that Technician handles service requests, Engineer
works on a project and Accountant handles the credit & debit details. All of
these three employee types have few attributes common such as name &
salary which we had left associated with the parent entity “Employee” as
shown in the above diagram.

BMS Aggregration
Aggregation is a process in which a single entity alone is not able to make
sense in a relationship so the relationship of two entities acts as one entity. I
know it sounds confusing but don’t worry the example we will take, will clear
all the doubts.

Aggregration Example
In real world, we know that a manager not only manages the employee
working under them but he has to manage the project as well. In such
scenario if entity “Manager” makes a “manages” relationship with either
“Employee” or “Project” entity alone then it will not make any sense because
he has to manage both. In these cases the relationship of two entities acts as
one entity. In our example, the relationship “Works-On” between “Employee” &
“Project” acts as one entity that has a relationship “Manages” with the entity
“Manager”.

Reduction of ER diagram to Table


The database can be represented using the notations, and these notations can be
reduced to a collection of tables.

In the database, every entity set or relationship set can be represented in tabular
form.

The ER diagram is given below:


There are some points for converting the ER diagram to the table:

o Entity type becomes a table.

In the given ER diagram, LECTURE, STUDENT, SUBJECT and COURSE forms


individual tables.

o All single-valued attribute becomes a column for the table.

In the STUDENT entity, STUDENT_NAME and STUDENT_ID form the column of


STUDENT table. Similarly, COURSE_NAME and COURSE_ID form the column of
COURSE table and so on.

o A key attribute of the entity type represented by the primary key.

In the given ER diagram, COURSE_ID, STUDENT_ID, SUBJECT_ID, and LECTURE_ID


are the key attribute of the entity.

o The multivalued attribute is represented by a separate table.

In the student table, a hobby is a multivalued attribute. So it is not possible to


represent multiple values in a single column of STUDENT table. Hence we create a
table STUD_HOBBY with column name STUDENT_ID and HOBBY. Using both the
column, we create a composite key.

o Composite attribute represented by components.

In the given ER diagram, student address is a composite attribute. It contains CITY,


PIN, DOOR#, STREET, and STATE. In the STUDENT table, these attributes can merge
as an individual column.

o Derived attributes are not considered in the table.

In the STUDENT table, Age is the derived attribute. It can be calculated at any point
of time by calculating the difference between current date and Date of Birth.

Using these rules, you can convert the ER diagram to tables and columns and assign
the mapping between the tables. Table structure for the given ER diagram is as
below:

Figure: Table structure

You might also like