0% found this document useful (0 votes)
7 views38 pages

DBMS Notes by Sanju

Uploaded by

sharama445
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)
7 views38 pages

DBMS Notes by Sanju

Uploaded by

sharama445
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/ 38

DBMS notes By Sanju

30 December 2021 17:45

Source links
File System vs DBMS: Key Differences (guru99.com)

What is DBMS?
Database Management System (DBMS) is a software for storing and retrieving
user’s data while considering appropriate security measures. It consists of a group
of programs that manipulate the database. The DBMS accepts the request for
data from an application and instructs the DBMS engine to provide the specific
data. In large systems, a DBMS helps users and other third­party software to store
and retrieve data.

What is a File system?


A file system is a technique of arranging the files in a storage medium
like a hard disk, pen drive, DVD, etc. It helps you to organizes the data
and allows easy retrieval of files when they are required. It mostly
consists of different types of files like mp3, mp4, txt, doc, etc. that are
grouped into directories.
A file system enables you to handle the way of reading and writing data
to the storage medium. It is directly installed into the computer with
the Operating systems such as Windows and

KEY DIFFERENCES:
• A file system is a software that manages and organizes the files in a storage
medium, whereas DBMS is a software application that is used for accessing,
creating, and managing databases.
• The file system doesn’t have a crash recovery mechanism on the other hand,
DBMS provides a crash recovery mechanism.
• Data inconsistency is higher in the file system. On the contrary Data
inconsistency is low in a database management system.
• File system does not provide support for complicated transactions, while in the
DBMS system, it is easy to implement complicated transactions using SQL.
• File system does not offer concurrency, whereas DBMS provides a concurrency
facility.
Features of a File system
Here are important elements of the file system:
• It helps you to store data in a group of files.
• Files data are dependent on each other.
• C/C++ and COBOL languages were used to design the files.
• Shared File System Support
• Fast File System Recovery.

Features of DBMS
Here, are essential features of DBMS:
• A user-accessible catalogue of data
• Transaction support
• Concurrency control with Recovery services
• Authorization services
• The value of data is the same at all places.
• Offers support for data communication
• Independent utility services
• Allows multiple users to share a file at the same time

Difference between filesystem vs. DBMS

Here, are the difference between File System and DBMS


File System DBMS
A file system is a software that manages DBMS or Database Management System
and organizes the files in a storage is a software application. It is used for
medium. It controls how data is stored accessing, creating, and managing
and retrieved. databases.
The file system provides the details of DBMS gives an abstract view of data
data representation and storage of data. that hides the details
Storing and retrieving of data can’t be DBMS is efficient to use as there are a
done efficiently in a file system. wide variety of methods to store and
retrieve data.
It does not offer data recovery processes. There is a backup recovery for data in
DBMS.
The file system doesn’t have a crash DBMS provides a crash recovery
recovery mechanism. mechanism
Protecting a file system is very difficult. DBMS offers good protection
mechanism.
In a file management system, the The redundancy of data is low in the
redundancy of data is greater. DBMS system.
Data inconsistency is higher in the file Data inconsistency is low in a database
system. management system.
The file system offers lesser security. Database Management System offers
high security.
File System allows you to stores the data Database Management System stores
as isolated data files and entities. data as well as defined constraints and
interrelation.
Not provide support for complicated Easy to implement complicated
transactions. transactions.
The centralization process is hard in File Centralization is easy to achieve in the
Management System. DBMS system.
It doesn’t offer backup and recovery of DBMS system provides backup and
data if it is lost. recovery of data even if it is lost.
There is no efficient query processing in You can easily query data in a database
the file system. using the SQL language.
These system doesn’t offer concurrency. DBMS system provides a concurrency
facility.

Advantages of File system


Here are pros/benefits of file system:
• Enforcement of development and maintenance standards.
• Helps you to reduce redundancy
• Avoid inconsistency across file maintenance to get the integrity of data
independence.
• Firm theoretical foundation (for the relational model).
• It is more efficient and cost less than a DBMS in certain situations.
• The design of file processing is simpler than designing Database.

Advantages of DBMS system


Here, are pros/benefits of DBMS system:
• DBMS offers a variety of techniques to store & retrieve data
• Uniform administration procedures for data
• Application programmers never exposed to details of data representation and
Storage.
• A DBMS uses various powerful functions to store and retrieve data efficiently.
• Offers Data Integrity and Security
• The DBMS implies integrity constraints to get a high level of protection against
prohibited access to data.
• Reduced Application Development Time
• Consume lesser space
• Reduction of redundancy.
• Data independence.

Application of File system


Here, are an important application of the file system:
• Language-specific run-time libraries
• API programs using it to make requests of the file system
• It is used for data transfer and positioning.
• Helps you to update the metadata
• Managing directories.

Application of the DBMS system


Here, are important applications of the DBMS system:
• Admission System Examination System Library System
• Payroll & Personnel Management System
• Accounting System Hotel Reservation System Airline Reservation System
• It is used in the Banking system for Customer information, account activités,
Payments, déposits, loans, etc.
• Use for Airlines for reservations and schedules
• DBMS system also used by universities to keep call records, monthly bills,
maintaining balances, etc.
• Finance for storing information about stock, sales, and purchases of financial
instruments like stocks and bonds.

Disadvantages of File system


Here, are cons/drawback of the file system:
• Each application has its data file so, the same data may have to be recorded
and stored many times.
• Data dependence in the file processing system are data-dependent, but, the
problem is incompatible with file format.
• Limited data sharing.
• The problem with security.
• Time-consuming.
• It allows you to maintain the record of the big firm having a large number of
items.
• Required lots of labour work to do.

Disadvantages of the DBMS system


Here, are some cons/drawbacks of the DBMS system:
• Cost of Hardware and Software of a DBMS is quite high, which increases the
budget of your organization.
• Most database management systems are often complex systems, so the
training for users to use the DBMS is required.
• The use of the same program at a time by many users sometimes lead to the
loss of some data.
• DBMS can’t perform sophisticated calculations
• Data-sets begins to grow large as it provides a more predictable query
response time.
• It required a processor with the high speed of data processing.
• The database can fail because or power failure or the whole system stops.
• The cost of DBMS is depended on the environment, function, or recurrent
annual maintenance cost.

The Key Responsibilities of a Database


Administrator

A database administrator's (DBA) primary job is to ensure that data is available,


protected from loss and corruption, and easily accessible as needed. Below are some of
the chief responsibilities that make up the day-to-day work of a DBA. DSP deliver an
outsourced DBA service in the UK, providing Oracle Support and SQL Server Support;
whilst mindset and toolset may be different, whether a database resides on-premise or
in a Public / Private Cloud, the role of the DBA is not that different.

1. Software installation and Maintenance


A DBA often collaborates on the initial installation and configuration of a new Oracle,
SQL Server etc database. The system administrator sets up hardware and deploys the
operating system for the database server, then the DBA installs the database software
and configures it for use. As updates and patches are required, the DBA handles this on-
going maintenance.
And if a new server is needed, the DBA handles the transfer of data from the existing
system to the new platform.

2. Data Extraction, Transformation, and Loading


Known as ETL, data extraction, transformation, and loading refers to efficiently
importing large volumes of data that have been extracted from multiple systems into a
data warehouse environment.
This external data is cleaned up and transformed to fit the desired format so that it can
be imported into a central repository.

3. Specialised Data Handling


Today’s databases can be massive and may contain unstructured data types such as
images, documents, or sound and video files. Managing a very large database (VLDB)
may require higher-level skills and additional monitoring and tuning to maintain
efficiency.

4. Database Backup and Recovery


DBAs create backup and recovery plans and procedures based on industry best
practices, then make sure that the necessary steps are followed. Backups cost time and
money, so the DBA may have to persuade management to take necessary precautions
to preserve data.
System admins or other personnel may actually create the backups, but it is the DBA’s
responsibility to make sure that everything is done on schedule.
In the case of a server failure or other form of data loss, the DBA will use existing
backups to restore lost information to the system. Different types of failures may
require different recovery strategies, and the DBA must be prepared for any eventuality.
With technology change, it is becoming ever more typical for a DBA to backup
databases to the cloud, Oracle Cloud for Oracle Databases and MS Azure for SQL
Server.

5. Security
A DBA needs to know potential weaknesses of the database software and the
company’s overall system and work to minimise risks. No system is one hundred per
cent immune to attacks, but implementing best practices can minimise risks.
In the case of a security breach or irregularity, the DBA can consult audit logs to see
who has done what to the data. Audit trails are also important when working with
regulated data.

6. Authentication
Setting up employee access is an important aspect of database security. DBAs control
who has access and what type of access they are allowed. For instance, a user may
have permission to see only certain pieces of information, or they may be denied the
ability to make changes to the system.
7. Capacity Planning
The DBA needs to know how large the database currently is and how fast it is growing
in order to make predictions about future needs. Storage refers to how much room the
database takes up in server and backup space. Capacity refers to usage level.
If the company is growing quickly and adding many new users, the DBA will have to
create the capacity to handle the extra workload.

8. Performance Monitoring
Monitoring databases for performance issues is part of the on-going system
maintenance a DBA performs. If some part of the system is slowing down processing,
the DBA may need to make configuration changes to the software or add additional
hardware capacity. Many types of monitoring tools are available, and part of the DBA’s
job is to understand what they need to track to improve the system. 3rd party
organisations can be ideal for outsourcing this aspect, but make sure they offer modern
DBA support.

9. Database Tuning
Performance monitoring shows where the database should be tweaked to operate as
efficiently as possible. The physical configuration, the way the database is indexed, and
how queries are handled can all have a dramatic effect on database performance.
With effective monitoring, it is possible to proactively tune a system based on
application and usage instead of waiting until a problem develops.

10. Troubleshooting
DBAs are on call for troubleshooting in case of any problems. Whether they need to
quickly restore lost data or correct an issue to minimise damage, a DBA needs to
quickly understand and respond to problems when they occur.

If you would like to know more about what the Oracle Support & SQL Server
Support DBAs do here at DSP-Explorer, then please get in touch with us.

DBMS Architecture
• The DBMS design depends upon its architecture. The basic
client/server architecture is used to deal with a large
number of PCs, web servers, database servers and other
components that are connected with networks.
• The client/server architecture consists of many PCs and a
workstation which are connected via the network.
• DBMS architecture depends upon how users are connected
to the database to get their request done.
Types of DBMS Architecture

Database architecture can be seen as a single tier or multi­tier.


But logically, database architecture is of two types like: 2-tier
architecture and 3-tier architecture.
1­Tier Architecture
• In this architecture, the database is directly available to the
user. It means the user can directly sit on the DBMS and
uses it.
• Any changes done here will directly be done on the
database itself. It doesn't provide a handy tool for end
users.
• The 1­Tier architecture is used for development of the local
application, where programmers can directly communicate
with the database for the quick response.

2­Tier Architecture
• The 2­Tier architecture is same as basic client­server. In the
two­tier architecture, applications on the client end can
directly communicate with the database at the server side.
For this interaction, API's like: ODBC, JDBC are used.
• The user interfaces and application programs are run on the
client­side.
• The server side is responsible to provide the functionalities
like: query processing and transaction management.
• To communicate with the DBMS, client­side application
establishes a connection with the server side.

Fig: 2-tier Architecture


3­Tier Architecture
• The 3­Tier architecture contains another layer between the
client and server. In this architecture, client can't directly
communicate with the server.
• The application on the client­end interacts with an
application server which further communicates with the
database system.
• End user has no idea about the existence of the database
beyond the application server. The database also has no
idea about any other user beyond the application.
• The 3­Tier architecture is used in case of large web
application.

Data Independence
A database system normally contains a lot of data in
addition to users’ data. For example, it stores data about
data, known as metadata, to locate and retrieve data
easily. It is rather difficult to modify or update a set of
metadata once it is stored in the database. But as a DBMS
expands, it needs to change over time to satisfy the
requirements of the users. If the entire data is dependent,
it would become a tedious and highly complex job.
Metadata itself follows a layered architecture, so that when
we change data at one layer, it does not affect the data at
another level. This data is independent but mapped to
each other.

Logical Data Independence


Logical data is data about database, that is, it stores
information about how data is managed inside. For
example, a table (relation) stored in the database and all
its constraints, applied on that relation.
Logical data independence is a kind of mechanism, which
liberalizes itself from actual data stored on the disk. If we
do some changes on table format, it should not change
the data residing on the disk.

Physical Data Independence


All the schemas are logical, and the actual data is stored
in bit format on the disk. Physical data independence is
the power to change the physical data without impacting
the schema or logical data.
For example, in case we want to change or upgrade the
storage system itself − suppose we want to replace hard-
disks with SSD − it should not have any impact on the
logical data or schemas

From
<https://www.tutorialspoint.com/dbms/dbms_quick_guide.ht
m>

Data Models
Data Model is the modeling of the data description, data semantics,
and consistency constraints of the data. It provides the conceptual tools
for describing the design of a database at each level of data abstraction.
Therefore, there are following four data models used for understanding
the structure of the database:

1) Relational Data Model: This type of model designs the data in the
form of rows and columns within a table. Thus, a relational model uses
tables for representing data and in­between relationships. Tables are
also called relations. This model was initially described by Edgar F.
Codd, in 1969. The relational data model is the widely used model
which is primarily used by commercial data processing applications.

2) Entity-Relationship Data Model: An ER model is the logical


representation of data as objects and relationships among them. These
objects are known as entities, and relationship is an association among
these entities. This model was designed by Peter Chen and published in
1976 papers. It was widely used in database designing. A set of
attributes describe the entities. For example, student_name,
student_id describes the 'student' entity. A set of the same type of
entities is known as an 'Entity set', and the set of the same type of
relationships is known as 'relationship set'.

3) Object-based Data Model: An extension of the ER model with


notions of functions, encapsulation, and object identity, as well. This
model supports a rich type system that includes structured and
collection types. Thus, in 1980s, various database systems following the
object­oriented approach were developed. Here, the objects are
nothing but the data carrying its properties.

4) Semistructured Data Model: This type of data model is different


from the other three data models (explained above). The
semistructured data model allows the data specifications at places
where the individual data items of the same type may have different
attributes sets. The Extensible Markup Language, also known as XML, is
widely used for representing the semistructured data. Although XML
was initially designed for including the markup information to the text
document, it gains importance because of its application in the
exchange of data.

Data model Schema and Instance


• The data which is stored in the database at a particular moment of
time is called an instance of the database.
• The overall design of a database is called schema.
• A database schema is the skeleton structure of the database. It
represents the logical view of the entire database.
• A schema contains schema objects like table, foreign key, primary
key, views, columns, data types, stored procedure, etc.
• A database schema can be represented by using the visual diagram.
That diagram shows the database objects and relationship with
each other.
• A database schema is designed by the database designers to help
programmers whose software will interact with the database. The
process of database creation is called data modeling.
A schema diagram can display only some aspects of a schema like the
name of record type, data type, and constraints. Other aspects can't be
specified through the schema diagram. For example, the given figure
neither show the data type of each data item nor the relationship
among various files.
In the database, actual data changes quite frequently. For example, in
the given figure, the database changes whenever we add a new grade
or add a student. The data at a particular
moment of time is called the instance of the database.
Database Language
• A DBMS has appropriate languages and interfaces to
express database queries and updates.
• Database languages can be used to read, store and
update the data in the database.
Types of Database Language

1. Data Definition Language


• DDL stands for Data Definition Language. It is used to
define database structure or pattern.
• It is used to create schema, tables, indexes,
constraints, etc. in the database.
• Using the DDL statements, you can create the
skeleton of the database.
• Data definition language is used to store the
information of metadata like the number of tables
and schemas, their names, indexes, columns in each
table, constraints, etc.
Here are some tasks that come under DDL:
• Create: It is used to create objects in the database.
• Alter: It is used to alter the structure of the database.
• Drop: It is used to delete objects from the database.
• Truncate: It is used to remove all records from a
table.
• Rename: It is used to rename an object.
• Comment: It is used to comment on the data
dictionary.
These commands are used to update the database
schema that's why they come under Data definition
language.

2. Data Manipulation Language


DML stands for Data Manipulation Language. It is used
for accessing and manipulating data in a database. It
handles user requests.
Here are some tasks that come under DML:

• Select: It is used to retrieve data from a database.


• Insert: It is used to insert data into a table.
• Update: It is used to update existing data within a table.
• Delete: It is used to delete all records from a table.
• Merge: It performs UPSERT operation, i.e., insert or
update operations.
• Call: It is used to call a structured query language or a
Java subprogram.
• Explain Plan: It has the parameter of explaining data.
• Lock Table: It controls concurrency.

3. Data Control Language


• DCL stands for Data Control Language. It is used to
retrieve the stored or saved data.
• The DCL execution is transactional. It also has rollback
parameters.
(But in Oracle database, the execution of data control
language does not have the feature of rolling back.)
Here are some tasks that come under DCL:
• Grant: It is used to give user access privileges to a
database.
• Revoke: It is used to take back permissions from the
user.
There are the following operations which have the
authorization of Revoke:
CONNECT, INSERT, USAGE, EXECUTE, DELETE, UPDATE
and SELECT.

4. Transaction Control Language


TCL is used to run the changes made by the DML
statement. TCL can be grouped into a logical transaction.
Here are some tasks that come under TCL:
• Commit: It is used to save the transaction on the
database.
• Rollback: It is used to restore the database to original
since the last Commit.

ACID Properties in DBMS


DBMS is the management of data that should remain integrated when
any changes are done in it. It is because if the integrity of the data is
affected, whole data will get disturbed and corrupted. Therefore, to
maintain the integrity of the data, there are four properties described in
the database management system, which are known as
the ACID properties. The ACID properties are meant for the transaction
that goes through a different group of tasks, and there we come to see
the role of the ACID properties.
In this section, we will learn and understand about the ACID properties.
We will learn what these properties stand for and what does each
property is used for. We will also understand the ACID properties with
the help of some examples.

ACID Properties
The expansion of the term ACID defines for:

1) Atomicity: The term atomicity defines that the data remains atomic.
It means if any operation is performed on the data, either it should be
performed or executed completely or should not be executed at all. It
further means that the operation should not break in between or
execute partially. In the case of executing operations on the transaction,
the operation should be completely executed and not partially.
In the above diagram, it can be seen that after crediting $10, the
amount is still $100 in account B. So, it is not an atomic transaction.
The below image shows that both debit and credit operations are done
successfully. Thus the transaction is atomic.

Thus, when the amount loses atomicity, then in the bank systems, this
becomes a huge issue, and so the atomicity is the main focus in the
bank systems.
2) Consistency: The word consistency means that the value should
remain preserved always. In DBMS, the integrity of the data should be
maintained, which means if a change in the database is made, it should
remain preserved always. In the case of transactions, the integrity of
the data is very essential so that the database remains consistent
before and after the transaction. The data should always be correct.
Example:

4) Isolation: The term 'isolation' means separation. In DBMS, Isolation is


the property of a database where no data should affect the other one
and may occur concurrently. In short, the operation on one database
should begin when the operation on the first database gets complete. It
means if two operations are being performed on two different
databases, they may not affect the value of one another. In the case of
transactions, when two or more transactions occur simultaneously, the
consistency should remain maintained. Any changes that occur in any
particular transaction will not be seen by other transactions until the
change is not committed in the memory.

Example: If two operations are concurrently running on two different


accounts, then the value of both accounts should not get affected. The
value should remain persistent. As you can see in the below diagram,
account A is making T1 and T2 transactions to account B and C, but both
are executing independently without affecting each other. It is known
as Isolation.

4) Durability: Durability ensures the permanency of something. In


DBMS, the term durability ensures that the data after the successful
execution of the operation becomes permanent in the database. The
durability of the data should be so perfect that even if the system fails
or leads to a crash, the database still survives. However, if gets lost, it
becomes the responsibility of the recovery manager for ensuring the
durability of the database. For committing the values, the COMMIT
command must be used every time we make changes.
Therefore, the ACID property of DBMS plays a vital role in maintaining
the consistency and availability of data in the database.
Thus, it was a precise introduction of ACID properties in DBMS. We have
discussed these properties in the transaction section also.

ER model
• 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.
• It develops a conceptual design for the database. It also
develops a very simple and easy to design view of data.
• In ER modeling, the database structure is portrayed as a
diagram called an 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
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
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.

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.

Notation of ER diagram
Database can be represented using the notations. In ER diagram, many notations are used to
express the cardinality. These notations are as follows:
ER Model ­ Basic Concepts
The ER model defines the conceptual view of a database. It works around real-world
entities and the associations among them. At view level, the ER model is considered a
good option for designing databases.
Entity
An entity can be a real-world object, either animate or inanimate, that can be easily
identifiable. For example, in a school database, students, teachers, classes, and
courses offered can be considered as entities. All these entities have some attributes or
properties that give them their identity.
An entity set is a collection of similar types of entities. An entity set may contain entities
with attribute sharing similar values. For example, a Students set may contain all the
students of a school; likewise a Teachers set may contain all the teachers of a school
from all faculties. Entity sets need not be disjoint.
Attributes
Entities are represented by means of their properties, called attributes. All attributes
have values. For example, a student entity may have name, class, and age as
attributes.
There exists a domain or range of values that can be assigned to attributes. For
example, a student's name cannot be a numeric value. It has to be alphabetic. A
student's age cannot be negative, etc.
Types of Attributes
• Simple attribute − Simple attributes are atomic values, which cannot be divided
further. For example, a student's phone number is an atomic value of 10 digits.
• Composite attribute − Composite attributes are made of more than one simple
attribute. For example, a student's complete name may have first_name and
last_name.
• Derived attribute − Derived attributes are the attributes that do not exist in the
physical database, but their values are derived from other attributes present in the
database. For example, average_salary in a department should not be saved
directly in the database, instead it can be derived. For another example, age can
be derived from data_of_birth.
• Single-value attribute − Single-value attributes contain single value. For example −
Social_Security_Number.
• Multi-value attribute − Multi-value attributes may contain more than one values. For
example, a person can have more than one phone number, email_address, etc.
These attribute types can come together in a way like −
• simple single-valued attributes
• simple multi-valued attributes
• composite single-valued attributes
• composite multi-valued attributes
Entity-Set and Keys
Key is an attribute or collection of attributes that uniquely identifies an entity among
entity set.
For example, the roll_number of a student makes him/her identifiable among students.
• Super Key − A set of attributes (one or more) that collectively identifies an entity in
an entity set.
• Candidate Key − A minimal super key is called a candidate key. An entity set may
have more than one candidate key.
• Primary Key − A primary key is one of the candidate keys chosen by the database
designer to uniquely identify the entity set.
Relationship
The association among entities is called a relationship. For example, an
employee works_at a department, a student enrolls in a course. Here, Works_at and
Enrolls are called relationships.
Relationship Set
A set of relationships of similar type is called a relationship set. Like entities, a
relationship too can have attributes. These attributes are called descriptive attributes.
Degree of Relationship
The number of participating entities in a relationship defines the degree of the
relationship.
• Binary = degree 2
• Ternary = degree 3
• n-ary = degree
Mapping Cardinalities
Cardinality defines the number of entities in one entity set, which can be associated with
the number of entities of other set via relationship set.
• One-to-one − One entity from entity set A can be associated with at most one
entity of entity set B and vice versa.
• One-to-many − One entity from entity set A can be associated with more than one
entities of entity set B however an entity from entity set B, can be associated with
at most one entity.

• Many-to-one − More than one entities from entity set A can be associated with at
most one entity of entity set B, however an entity from entity set B can be
associated with more than one entity from entity set A.

• Many-to-many − One entity from A can be associated with more than one entity
from B and vice versa.
ER Diagram Representation
Let us now learn how the ER Model is represented by means of an ER diagram. Any
object, for example, entities, attributes of an entity, relationship sets, and attributes of
relationship sets, can be represented with the help of an ER diagram.
Entity
Entities are represented by means of rectangles. Rectangles are named with the entity
set they represent.

Attributes
Attributes are the properties of entities. Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is directly connected to its entity (rectangle).

If the attributes are composite, they are further divided in a tree like structure. Every
node is then connected to its attribute. That is, composite attributes are represented by
ellipses that are connected with an ellipse.
Multivalued attributes are depicted by double ellipse.

Derived attributes are depicted by dashed ellipse.


Relationship
Relationships are represented by diamond-shaped box. Name of the relationship is
written inside the diamond-box. All the entities (rectangles) participating in a
relationship, are connected to it by a line.
Binary Relationship and Cardinality
A relationship where two entities are participating is called a binary relationship.
Cardinality is the number of instance of an entity from a relation that can be associated
with the relation.
• One-to-one − When only one instance of an entity is associated with the
relationship, it is marked as '1:1'. The following image reflects that only one
instance of each entity should be associated with the relationship. It depicts one-to-
one relationship.

• One-to-many − When more than one instance of an entity is associated with a


relationship, it is marked as '1:N'. The following image reflects that only one
instance of entity on the left and more than one instance of an entity on the right
can be associated with the relationship. It depicts one-to-

• Many-to-one − When more than one instance of entity is associated with the
relationship, it is marked as 'N:1'. The following image reflects that more than one
instance of an entity on the left and only one instance of an entity on the right can
be associated with the relationship. It depicts many-to-one relationship.

• Many-to-many − The following image reflects that more than one instance of an
entity on the left and more than one instance of an entity on the right can be
associated with the relationship. It depicts many-to-many relationship.
Participation Constraints
• Total Participation − Each entity is involved in the relationship. Total participation is
represented by double lines.
• Partial participation − Not all entities are involved in the relationship. Partial
participation is represented by single lines.

Generalization Aggregation
Let us now learn how the ER Model is represented by means of an ER diagram. Any
object, for example, entities, attributes of an entity, relationship sets, and attributes of
relationship sets, can be represented with the help of an ER diagram.
Entity
Entities are represented by means of rectangles. Rectangles are named with the entity
set they represent.

Attributes
Attributes are the properties of entities. Attributes are represented by means of ellipses.
Every ellipse represents one attribute and is directly connected to its entity (rectangle).

If the attributes are composite, they are further divided in a tree like structure. Every
node is then connected to its attribute. That is, composite attributes are represented by
ellipses that are connected with an ellipse.
Multivalued attributes are depicted by double ellipse.

Derived attributes are depicted by dashed ellipse.


Relationship
Relationships are represented by diamond-shaped box. Name of the relationship is
written inside the diamond-box. All the entities (rectangles) participating in a
relationship, are connected to it by a line.
Binary Relationship and Cardinality
A relationship where two entities are participating is called a binary relationship.
Cardinality is the number of instance of an entity from a relation that can be associated
with the relation.
• One-to-one − When only one instance of an entity is associated with the
relationship, it is marked as '1:1'. The following image reflects that only one
instance of each entity should be associated with the relationship. It depicts one-to-
one relationship.

• One-to-many − When more than one instance of an entity is associated with a


relationship, it is marked as '1:N'. The following image reflects that only one
instance of entity on the left and more than one instance of an entity on the right
can be associated with the relationship. It depicts one-to-

• Many-to-one − When more than one instance of entity is associated with the
relationship, it is marked as 'N:1'. The following image reflects that more than one
instance of an entity on the left and only one instance of an entity on the right can
be associated with the relationship. It depicts many-to-one relationship.

• Many-to-many − The following image reflects that more than one instance of an
entity on the left and more than one instance of an entity on the right can be
associated with the relationship. It depicts many-to-many relationship.
Participation Constraints
• Total Participation − Each entity is involved in the relationship. Total participation is
represented by double lines.
• Partial participation − Not all entities are involved in the relationship. Partial
participation is represented by single lines.

Generalization Aggregation
The ER Model has the power of expressing database entities in a conceptual
hierarchical manner. As the hierarchy goes up, it generalizes the view of entities, and as
we go deep in the hierarchy, it gives us the detail of every entity included.
Going up in this structure is called generalization, where entities are clubbed together to
represent a more generalized view. For example, a particular student named Mira can
be generalized along with all the students. The entity shall be a student, and further, the
student is a person. The reverse is called specialization where a person is a student,
and that student is Mira.
Generalization
As mentioned above, the process of generalizing entities, where the generalized entities
contain the properties of all the generalized entities, is called generalization. In
generalization, a number of entities are brought together into one generalized entity
based on their similar characteristics. For example, pigeon, house sparrow, crow and
dove can all be generalized as Birds.

Specialization
Specialization is the opposite of generalization. In specialization, a group of entities is
divided into sub-groups based on their characteristics. Take a group ‘Person’ for
example. A person has name, date of birth, gender, etc. These properties are common
in all persons, human beings. But in a company, persons can be identified as employee,
employer, customer, or vendor, based on what role they play in the company.
Similarly, in a school database, persons can be specialized as teacher, student, or a
staff, based on what role they play in school as entities.
Inheritance
We use all the above features of ER-Model in order to create classes of objects in
object-oriented programming. The details of entities are generally hidden from the user;
this process known as abstraction.
Inheritance is an important feature of Generalization and Specialization. It allows lower-
level entities to inherit the attributes of higher-level entities.

For example, the attributes of a Person class such as name, age, and gender can be
inherited by lower-level entities such as Student or Teacher.

From <https://www.tutorialspoint.com/dbms/dbms_quick_guide.htm>

You might also like