Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

UNIT-1

INTRODUCTION TO DBMS AND ENTITY RELATIONAL MODEL


Introduction: Basic Concepts, Data Base System Applications, File Systems VS DBMS.
View Of Data , Data Abstraction, Instances And Schemas, Data Models, Database
Language, Database System Architecture.

The Entity Relationship Model: Database Design And ER Diagrams, Entities, Attributes, And
Entity Sets, Relationships And Relationships Sets, Additional Features Of The ER Model,
Conceptual Design With The ER Model , Conceptual Design For Large Enterprises.

INTRODUCTION TO DATA BASES:

Database Management System: DBMS is a collection of programs that manages database


structure and control access to data stored in the database.

Or

DBMS = Database + Management System. Database is a collection of data and Management


System is a set of programs to store and retrieve those data.

DBMS is a software which is used to manage database.

• MYSQL
• SQL SERVER
• ORACLE

What is DBMS?
Database Management System (DBMS) is a software for storing and retrieving
users’ data while considering appropriate security measures. It consists of a group
of programs which manipulate the database.

DBMS allows users to create their own databases as per their requirement. The term
“DBMS” includes the user of the database and other application programs. It
provides an interface between the data and the software application.

Here, are the important landmarks from the history:

• 1960 – Charles Bachman designed first DBMS system


• 1970 – Codd introduced IBM’S Information Management System (IMS)
• 1976- Peter Chen coined and defined the Entity-relationship model also
know as the ER model
• 1980 – Relational Model becomes a widely accepted database component
• 1985- Object-oriented DBMS develops.
• 1990s- Incorporation of object-orientation in relational DBMS.
• 1991- Microsoft ships MS access, a personal DBMS and that displaces
all other personal DBMS products.

1
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

• 1995: First Internet database applications


• 1997: XML applied to database processing. Many vendors begin to
integrate XML into DBMS products.

Characteristics of DBMS
Here are the characteristics and properties of Database Management System:
• Provides security and removes redundancy
• Self-describing nature of a database system
• Insulation between programs and data abstraction
• Support of multiple views of the data
• Sharing of data and multiuser transaction processing
• Database Management Software allows entities and relations among them
to formtables.
• It follows the ACID concept (Atomicity, Consistency, Isolation, and Durability).
• DBMS supports multi-user environment that allows users to access and
manipulate data in parallel.
• Advantages of DBMS
• DBMS offers a variety of techniques to store & retrieve data
• DBMS serves as an efficient handler to balance the needs of multiple
applications using the same data
• Uniform administration procedures for data
• 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.
• A DBMS schedules concurrent access to the data in such a manner that
only one user can access the same data at a time
• Reduced Application Development Time

DBMS Concepts

DBMS solutions come equipped with a unique set of components, each responsible for
performing different tasks. Here are the most basic DBMS components:

• Software-A DBMS is a software-based system that provides a management


interface, which helps users control databases and data sources.
• Data-DBMS provides controls for managing operational data, such as
records and metadata, as well as index files, data dictionaries, and
administrative information.
• Procedures-documents that standardize database management, used as
guidelines by employees and users, and as automation policies.
• Database languages-DBMS use various languages to perform tasks such as
controlling user access and specifying database schema. DBMS languages
include Data Manipulation Language (DML), Data Definition Language
(DDL), Data Control Language (DCL), and Database Access Language
(DAL).
• Query processor-serves as a communication intermediary between users
and the DBMS data engine. The query processor enables users to query
requests, for example, by entering instructions in Structured Query
Language (SQL).
• Runtime database manager-enables DBMS to centralize management of

2
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

runtime data. A runtime database manager validates user authorizations,


processes approved queries, determines which strategy provides optimal
query results, ensures data integrity, and handles any task that requires
handling query and runtime data.
• Database manager-handles database jobs and enables administrators to
perform database operations and maintenance tasks, including data backup
and restore, cloning, deleting, updating the database, and executing patches.
• Database engine-performs the main data storage and retrieval tasks. A
database engine can be built into the DBMS software or as a remote
resource accessed via an API.
• Report generator-enables users to extract DBMS files and display the
information in structured formats, according to predefined specifications.
Report generation processes help users perform analyses and derive
actionable insights.
Data: The Collection of raw facts which does not give complete meaning is called as
data and processed data is called Information.

❖ Database System Applications: The Databases are widely used in many areas and
many applications. Here are some of the Database Applications.


❖ Enterprise Information:
 Sales: For customer, product, and purchase information.
 Accounting: For payments, receipts, account balances, assets and other accounting
information.
 resources Human: For information about employees, salaries, payroll taxes and
benefits, and for generation of paychecks.
 Manufacturing: For management of supply chain and for tracking production of
items in factories, inventories of items in warehouses/stores, and orders for items.
 Online retailers: For sales data noted above plus online order tracking, generation
of recommendation lists, and maintenance of online product evaluation.
 Banking and Finance:
Banking: For customer information, accounts, and loans, and banking transactions.

Credit card transactions: For purchases on credit cards and generation of monthly
statements.

3
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

 Finance: For storing information about holdings, sales, and purchases of financial
instruments such as stocks and bonds.
 Universities: For student information, course registrations, and grades.
 Airlines: For reservations and schedule information. Airlines were among the first to
use databases in a geographically distributed manner—terminals situated around the
world accessed the central database system through phone lines and other data
networks.
 Telecommunication: For keeping records of calls made, generating monthly bills,
maintaining balances on prepaid calling cards, and storing information about the
communication networks.
 Railway Reservation Systems: For reservations and schedule information.
 Library Management System − Now-a-days it’s become easy in the Library to
track each book and maintain it because of the database. This happens because there
are thousands of books in the library. It is very difficult to keep a record of all books
in a copy or register. Now DBMS used to maintain all the information related to book
issue dates, name of the book, author and availability of the book.
 Social Media Sites : By filling the required details we are able to access social
media platforms. Many users sign up daily on social websites such as Facebook,
and Instagram. All the information related to the users are stored and maintained with
the help of DBMS.

File System vs. DBMS

There are following differences between DBMS and File system:

File System DBMS

File system is a collection of data. In this DBMS is a collection of data. In DBMS, the
system, the user has to write the procedures user is not required to write the procedures.
for managing the database
.
File system provides the detail of the data DBMS gives an abstract view of data that
representation and storage of data hides the details.
.
File system doesn't have a crash mechanism, DBMS provides a crash recovery
i.e., if the system crashes while entering mechanism, i.e., DBMS protects the user
some data, then the content of the file will from the system failure.
lost.

It is very difficult to protect a file under the DBMS provides a good protection
file system. mechanism.

File system can't efficiently store and retrieve DBMS contains a wide variety of
the data sophisticated techniques to store and retrieve
the data.
In the File system, concurrent access has DBMS takes care of Concurrent access of
many problems like redirecting the file while data using some form of locking.
other deleting some information or updating
some information.

Files are unstructured data Dbms is structured data

4
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

Data redundancy is there in file system No data redundancy in Dbms

Memory utilisation poor in file system Memory utilisation well in dbms

Inconsistency in file system No data inconsistency in dbms

VIEW OF DATA:

A database system is a collection of interrelated files and a set of programs that allow
users to access and modify these files. A major purpose of database system is to provide users
with an “Abstract View” of the data. That is, the system hides certain details of how data
stored and maintained.

Or

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

4. Key Takeaways

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

5
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

i. Physical level (internal level)


ii. Logical level (conceptual level)
iii. 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.

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

2.Instances and Schemas

What is an instance?

The data stored in database at a particular moment of time is called instance of database.
Database schema defines the variable declarations in tables that belong to a particular
database; the value of these variables at a moment of time is called the instance of that
database.

What is Schema:
Schema is a structural view of a database. Moreover, a schema diagram refers to
representing a database as a diagram. It represents the relationship between the
tables. However, it does not show the data present in the tables.

6
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

For example: In the following diagram, we have a schema that shows the relationship
between three tables: Course, Student and Section. The diagram only shows the design of
the database, it doesn’t show the data present in those tables. Schema is only a structural
view(design) of a database

❖ 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:

Relational Model:
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.

7
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

SID SNAME GENDER AGE BRANCH

501 RAMU Male 22 CSE

502 Ramana Male 23 AI


503 Rama Female 24 ECE
504 seetha female 25 EEE

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

3.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_iddescribes 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'.

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

ER MODEL BENEFITS

 Provide a clear picture of the scope of information requirement


 Provides an easily understandable pictorial map for database design
 It offers an effective Framework for integrating multiple applications.
8
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

DATABASE LANGUAGES
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:

9
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

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.

DATABASE SYSTEMS ARCHITECTURE

Database systems can be centralized or client-server, where one server machine


executes work on behalf of multiple client machines. A database system is partitioned into
modules that deal with each of the responsibilities of the overall system. The functional
components of a database system can be broadly divided into the storage manager and the
query processor components as shown in the following figure, the structure of database
system architecture.

The architecture of a database system is greatly influenced by the underlying computer


system on which the database is running:

i. Centralized.
ii. Client-server.
iii. Parallel (multi-processor).
iv. Distributed

10
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

The storage manager is important because databases typically require a large amount
of storage space. Some Big organizations Database ranges from giga bytes to tera bytes. So
the main memory of computers cannot store this much information, the information is stored
on disks. Data are moved between disk storage and main memory as needed.
The query processor also very important because it helps the database systems simplify and
facilitate access to data. So quick processing of updates and queries is important. It is the job
of the database system to translate updates and queries written in a nonprocedural language,
at the logical level, into an efficient sequence of operations at the physical level.

Database Users & Database Administrators:

A primary goal of a database system is to retrieve information from and store new
information in the database. People who work with a database can be categorized as database
users or database administrators.

11
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

Database Users:
There are four different types of database-system users, differentiated by the way they expect
to interact with the system.
Naive users:
These users are also called as Unsophisticated Users. They don’t have any type of knowledge
with the system. These users interact with the system by invoking one of the application
programs that have been written previously.
 For example, a bank teller who needs to transfer $50 from account A to account B
invokes a program called transfer. This program asks the teller for the amount of
money to be transferred, the account from which the money is to be transferred, and
the account to which the money is to be transferred.

Application programmers:
These users are computer professionals who write application programs. Application
programmers can choose from many tools to develop user interfaces. Rapid application
development (RAD) tools are tools that enable an application programmer to construct forms
and reports without writing a program.

Sophisticated users:
These users are interacting with the system without writing programs. Instead, they
form their requests in a database query language. They submit each such query to a query
processor, whose function is to break down DML statements into instructions that the storage
manager understands. Analysts who submit queries to explore data in the database fall in this
category.

Specialized users:
These users are sophisticated users who write specialized database applications that
do not fit into the traditional data-processing framework. Among these applications are
computer-aided design systems, knowledge base and expert systems, systems that store data
with complex data types (for example, graphics data and audio data), and environment Unit
modeling systems.

Database Administrator:

Coordinates all the activities of the database system. The database administrator has a good
understanding of the enterprise’s information resources and needs.
• Database administrator's duties include:
 Schema definition: The DBA creates the original database schema by executing a
set of data definition statements in the DDL.
 Storage structure and access method definition.
 Schema and physical organization modification: The DBA carries out changes to
the schema and physical organization to reflect the changing needs of the
organization, or to alter the physical organization to improve performance.
 Granting user authority to access the database: By granting different types of
authorization, the database administrator can regulate which parts of the database
various users can access.
 Specifying integrity constraints.
 Monitoring performance and responding to changes in requirements.

 Query Processor:
The query processor will accept query from user and solves it by accessing the database.

Parts of Query processor:


• DDL interpreter
12
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

This will interprets DDL statements and fetch the definitions in the data dictionary.
• DML compiler

a. This will translates DML statements in a query language into low level instructions that the
query evaluation engine understands.
b. A query can usually be translated into any of a number of alternative evaluation plans for
same query result DML compiler will select best plan for query optimization.
• Query evaluation engine
This engine will execute low-level instructions generated by the DML compiler on DBMS.

 The storage manager components include:


o Authorization and integrity manager: Checks for integrity constraints and authority of
users to access data.
o Transaction manager: Ensures that the database remains in a consistent state although
there are system failures.
o File manager: Manages the allocation of space on disk storage and the data structures used
to represent information stored on disk.
o Buffer manager: It is responsible for retrieving data from disk storage into main memory.
It enables the database to handle data sizes that are much larger than the size of main
memory.
o Data structures implemented by storage manager.
o Data files: Stored in the database itself.
oData dictionary: Stores metadata about the structure of the database. o Indices: Provide
fast access to data items. Three-tier architecture: The client machine acts as merely a front end
and does not contain any direct database calls. Instead, the client end communicates with an
application server, usually through a forms interface. The application server in turn communicates
with a database system to access data. The business logic of the application, which says what actions
to carry out under what conditions, is embedded in the application server, instead of being distributed
across multiple clients. Three-tier applications are more appropriate for large applications, and for
applications that run on the World Wide Web.

13
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

THE ENTITY RELATIONSHIP MODEL

What is database design and ER diagram

OVERVIEW OF DATABASE DESIGN


The database design process can be divided into six steps. The ER Model is most relevant to
the first three steps. Next three steps are beyond the ER Model

1. Requirements Analysis: The very first step in designing a database application is to


understand what data is to be stored in the database, what applications must be built on top of
it, and what operations are most frequent and subject to performance requirements. The
database designers collect information of the organization and analyzer, the information to
identify the user’s requirements. The database designers must find out what the users want
from the database.

2. Conceptual Database Design: Once the information is gathered in the requirements


analysis step a conceptual database design is developed and is used to develop a high level
description of the data to be stored in the database, along with the constraints that are known
to hold over this data. This step is often carried out using the ER model, or a similar high-
level data model.

3. Logical Database Design: In this step convert the conceptual database design into a
database schema (Logical Database Design) in the data model of the chosen DBMS. In terms
of relational DBMSs, and therefore, the task in the logical design step is to convert an ER
schema into a relational database schema. The result is a conceptual schema, sometimes
called the logical schema, in the relational data model.

BEYOND THE ER DESIGN: The first three steps are more relevant to the ER Model. Once
the logical scheme is defined designer consider the physical level implementation and finally
provide certain security measures. The remaining three steps of database design are briefly
described below:

14
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

4. Schema Refinement: The fourth step in database design is to analyze the collection of
relations in our relational database schema to identify potential problems, and to refine it. In
contrast to the requirements analysis and conceptual design steps, which are essentially
subjective, schema refinement can be guided by some elegant and powerful theory.

5. Physical Database Design: In this step, must consider typical expected workloads that our
database must support and further refine the database design to ensure that it meets desired
performance criteria. This step may simply involve building indexes on some tables and
clustering some tables, or it may involve a substantial redesign of parts of the database
schema obtained from the earlier design steps.

6. Security Design: The last step of database design is to include security features. This is
required to avoid unauthorized access to database practice after all the six steps. We required
Tuning step in which all the steps are interleaved and repeated until the design is satisfactory.

History of ER models

ER diagrams are visual tools that are helpful to represent the ER model.
Peter Chen proposed ER Diagram in 1971 to create a uniform convention that can
be used for relational databases and networks. He aimed to use an ER model as a
conceptual modelling approach.
❖ E-R diagrams are used to model real-world objects like a person, a car, a company
etc. and the relation between these real-world objects.

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.

Here are the geometric shapes and their meaning in an E-R Diagram

• Rectangle: Represents Entity sets.


• Ellipses: Attributes
• Diamonds: Relationship Set
• Lines: They link attributes to Entity Sets and Entity sets to Relationship Set
• Double Ellipses: Multivalued Attributes
• Dashed Ellipses: Derived Attributes
• Double Rectangles: Weak Entity Sets
Double Lines: Total participation of an entity in a relationship set

15
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

ENTITIES, ATTRIBUTES, AND ENTITY SETS:

ENTITY:
An entity is a thing which is distinguishable from other objects. Entities are represented by
using rectangular boxes. .
A real-world thing either living or non-living that is easily recognizable and
nonrecognizable. 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

For example each person in a university is an entity.

There are 2 types:strong entity and weak entity


STRONG ENTITY: An entity whose existence does not depend on existence of another
entity is called strong entity. An entity set that has a primary key is termed as a strong entity
set. Strong entity can be represented in rectangular box

Here student is a strong entity, as it has a primary key attribute ID which is uniquely defined

16
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

WEAK ENTITY: An entity whose existence depends on the existence of another entity is
called Weak entity. An entity set may not have sufficient attributes to form a primary key
such an entity set is termed as a weak entity set. Weak entity is represented by double
rectangular box.

Note – Weak entity always has total participation but Strong entity may not have total
participation.

For example – a bank account cannot be uniquely identified without knowing the bank to
which the account belongs, so bank account is a weak entity.

BANK-ACCOUNT BANK

Weak Entities : A weak entity is a type of entity which doesn't have its key attribute. It can
be identified uniquely by considering the primary key of another entity. For that, weak entity
sets need to have participation.

Strong Entity Set Weak Entity Set


Strong entity set always has a primary key. It does not have enough attributes to build a
primary key.
It is represented by a rectangle symbol. It is represented by a double rectangle
symbol.
It contains a Primary key represented by the It contains a Partial Key which is represented
underline symbol. by a dashed underline symbol.
The member of a strong entity set is called as The member of a weak entity set called as a
dominant entity set. subordinate entity set.
Primary Key is one of its attributes which In a weak entity set, it is a combination of
helps to identify its member. primary key and partial key of the strong
entity set.

17
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

In the ER diagram the relationship between The relationship between one strong and a
two strong entity set shown by using a weak entity set shown by using the double
diamond symbol. diamond symbol.
The connecting line of the strong entity set The line connecting the weak entity set for
with the relationship is single. identifying relationship is double.

ATTRIBUTES:

Attributes are the properties of entities that are represented using ellipse-shaped figures.
Every elliptical figure represents one attribute and is directly connected to its entity (which is
represented as a rectangle). OR

Attribute: The property of the Entity is called an Attribute. The entity is described using a
set of Attributes. It is represented with oval.

Example: Employee Number, Name, Salary etc.,

There are 8 types of attributes. They are:

1. Simple attribute.

2. Composite attribute.

3. Single valued attribute.

4. Multi valued attribute.

5. Null attribute.

6. Key attribute.

7. Derived attribute.

8. Descriptive attribute.

Simple Attributes

Simple attributes in an ER model diagram are independent attributes that can't be


classified further and also, can't be subdivided into any other component. These
attributes are also known as atomic attributes.

class age
Roll-no

Student

As we can see in the above example, Student is an entity represented by a rectangle, and it consists
of attributes: Roll_no, class, and Age. Also, there is a point to be noted that we can't further

18
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

subdivide the Roll_no attribute and even the other two attributes into sub-attributes. Hence, they are
known as simple attributes of the Student entity.

Composite Attributes

Composite attributes have opposite functionality to that of simple attributes as we can further
subdivide composite attributes into different components or sub-parts that form simple attributes. In
simple terms, composite attributes are composed of one or more simple attributes.

The attributes that can be divided into subparts are known as composite attributes.

For example, an attribute name could be structured as a composite attribute consisting of


first_ name, middle_ initial and last_ name

SINGLE VALUED ATTRIBUTE: The attribute have a single value for a particular entity
is known as single valued attribute. Eg: For instance, the student ID attribute for a specific
student entity refers to only one student ID. Such attributes are said to be single valued.

MULTI VALUED ATTRIBUTE: The attribute that have many values for a particular entity
is known as multi valued attribute. Eg: If we add to the instructor entity set an attribute
dependent name listing all the dependents. This attribute will be multi valued, since any
particular instructor may have zero, one or more dependents. To denote that an attribute is
multi valued, it represented by double oval shape

NULL ATTRIBUTE: A null attribute is an attribute that uses a null value when an entity
doesn’t have a value for an attribute. Null attribute is represented by empty oval shape

19
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

KEY ATTRIBUTE: A key is a minimal set of attributes whose values uniquely identify an
entity in the set. Eg: The entity set instructor includes the attributes ID, name, dept_name and
salary with ID forming the primary key. It can be represented by underlining the key
attribute.

For example, one may have no middle name. Null can also designate that an attribute value is
unknown. An unknown value may be either missing or not known.

DERIVED ATTRIBUTE: The values for this type of attribute can be derived from the
values of another related attribute. Derived attribute represented by dotted oval shape.

Here instructor is an entity where age indicates the instructor’s age. If it also has the attribute
date of birth we can calculate age from date of birth and current date.

DESCRIPTIVE ATTRIBUTE: A relationship can also have descriptive attributes.


Descriptive attributes are used to record the information about the relationship rather than
about any one of the participating entities.
Eg: Let us consider a relationship advisor with entity sets instructor and student and associate
the attribute date with that relationship to specify the date when an instructor became advisor
of a student.

Domain: The attribute with set of values is called Domain. For each attribute associated with
an entity set, must identify a domain of possible values. For example, if the company rates
employees on a scale of 1 to 10 and stores ratings in a field called rating, the associated
domain consists of integers 1 through 10.

20
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

Key: A key is a minimal set of attributes whose values uniquely identify an entity in the set.
There could be more than one candidate key, and then select any of them as the Primary Key.
So for each entity set choose a key. The key attribute is represented with under line. Each
attribute in the primary key is underlined.

❖ Entity Set
An entity set in DBMS is a set that collectively represents a group of entities of a
similar type.
For example, an entity set of cars, an entity set of bank accounts, etc. In
DBMS, the whole table in the tabular representation of data is an entity set, while
each row inside this table is an entity. Below is the tabular representation, i.e., entity
set of bank accounts.

In entity-relationship diagrams, entity sets are represented by a rectangle, and the


attributes of an entity set are represented by an ellipse.

Below is the representation of the bank entity accounts set in an entity-relationship diagram.

21
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

Weak Entity Set


Weak entity set in DBMS is an entity set that does not have a primary key, i.e.,
there exists no attribute that can uniquely represent each entity in the entity set.
For example, an entity set of cars having attributes such as a car's color, a car's
name is a weak entity since two cars can have the same color as well as the same name.
So, none of the attributes can be considered as the primary key and hence the entity set is a
weak entity set.

In entity-relationship diagrams, weak entity sets are represented by a double rectangle.

Strong Entity Set


Strong entity set in DBMS is the entity set in which there exists a primary
key, i.e., there exists an attribute that can uniquely represent each element in the
entity.
For example, an entity set of cars having attributes such as a car's
registration number, car's color, car's name is a strong entity since no two cars can
have the same registration number. So, the attributes registration number can be
considered as the primary key, and hence the entity set is a strong entity set. In
entity-relationship diagrams, strong entities are represented by a rectangle.

 RELATIONSHIPS AND RELATIONSHIP SETS

Relationship: A Relationship is an association among two or more entities. Relationship can


be represented with a Diamond.
Example: The Employee and Department are the two entities the Works in is the relationship
between the Employee and Department. Each employee will work in the department.
Relationship Set: The collection of similar relationships is a relationship set. A relationship
set can be thought of as a set of n-tuples: {(e1,…, en) | e1 ϵ E1,……en ϵ En}
.Each n-tuple denotes a relationship involving n entities e1 through en, where entity e is in
entity set Ei.

22
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

The above Figure shows the relationship set Works_In, in which each relationship indicates a
department in which an employee works.

Descriptive Attributes: Descriptive attributes are used to record information about the
relationship. From above figure, since attribute is descriptive attribute which stores the
information about relationship.
Instance: An instance of a relationship set is a set of relationships. Below figure show that
each Employees entity is denoted by its ssn, and each Departments entity is denoted by it’s
did. The since value is shown beside each relationship.

Degree:
The number of entities associated with a relationship set is known by degree of entities.
1. Unary: Where the association is within a single entity.
2. Binary: A relationship that associates two entities is knows as binary relationship.
3. Ternary: When three entities are participating in the relation then that is a Ternary.
4. N – Ary. When more than three entities are participating in the relation then that is a N –
ary relation.
Consider another example of ER diagram, suppose that each department has offices in several
locations and to record the location at which each employee works. This relationship is
ternary because it must record an association between an employee, a department, and a
location as shown in bellow:

23
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

Fig:A Ternary Relationship Set

Cardinality: The number of times an entity of an entity set participates in a relationship


set is known as cardinality. Cardinality can be of different types:
❖ RELATIONSHIPS

Any association between two entity types is called a relationship. Entities take part in the
relationship. It is represented by a diamond shape. There are four types of relationships:

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

1. One to One Relationship


When a single instance of an entity is associated with a single instance of another
entity then it is called one to one relationship. For example, a person has only one
passport and a passport is given to one person.

2. One to Many Relationship


When a single instance of an entity is associated with more than one instances of
another entity then it is called one to many relationships. For example – a customer
can place many orders but a order cannot be placed by many customers.

3. Many to One Relationship


When more than one instances of an entity is associated with a single instance of
another entity then it is called many to one relationship. For example – many
students can study in a single college but a student cannot study in many colleges at
the same time.

24
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

4. Many to Many Relationship


When more than one instances of an entity is associated with more than one
instances of another entity then it is called many to many relationships. For
example, a can be assigned to many projects and a project can be assigned to many
students.

ADDITIONAL FEATURES OF THE ER MODEL:

Features of ER model: The basic E-R concepts can model most database features, some
aspects of a database may be more aptly expressed by certain extensions to the basic E-R
model. The extended E-R features are specialization, generalization, higher- and lower-
level entity sets, attribute inheritance, and aggregation.

The basic E-R concepts can model most database features, some aspects of a database
may be more aptly expressed by certain extensions to the basic E-R model.

1. Generalization
2. Specialization
3. Aggregation

Generalization –
Generalization is the process of extracting common properties from a set of
entities and create a generalized entity from it. It is a bottom-up approach.
For Example, STUDENT and FACULTY can be generalized to a higher-level
entity called PERSON as shown in Figure 1. In this case, common attributes like P_NAME,
P_ADD become part of higher entity (PERSON) and specialized attributes like S_FEE
become part of specialized entity (STUDENT).

25
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

Specialization –
In specialization, an entity is divided into sub-entities based on their characteristics.
It is a top-down approach where higher level entity is specialized into two or more lower
level entities.
For Example, EMPLOYEE entity in an employee management system can be
specialized into DEVELOPER, TESTER etc. In this case, common attributes
likeE_NAME, E_SAL etc. become part of higher entity (EMPLOYEE) and specialized
attributes like TES_TYPE become part of specialized entity (TESTER).

Aggregation –
Aggregation is an abstraction through which we can represent relationships as higher level
entity sets.

For Example, Employee working for a project may require some machinery. So, REQUIRE
relationship is needed between relationship WORKS_FOR and entity MACHINERY.
Using aggregation, WORKS_FOR relationship with its entities EMPLOYEE and
PROJECT is aggregated into single entity and relationship REQUIRE is created between
aggregated entity and MACHINERY.

26
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

What is conceptual design with 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.

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.

CONCEPTUAL DATABASE DESIGN WITH ER MODEL:

Developing an ER diagram presents several choices, including the following:


 Should a concept be modeled as an entity or an attribute?
 Should a concept be modeled as an entity or a relationship?
 What are the relationship sets and their participating entity sets? Should we use binary
or ternary relationships?
 Should we use aggregation?

Entity versus Attribute:


While identifying the attributes of an entity set, it is sometimes not clear whether a property
should be modeled as an attribute or as an entity set. For example, consider adding address
information to the Employees entity set. One option is to use an attribute address. This option
is appropriate if it needs to record only one address per employee, and it suffices to think of
an address as a string. An alternative is to create an entity set called Addresses and to record
associations between employees and addresses using a relationship has Address.
This more complex alternative is necessary in two situations:
 Have to record more than one address for an employee.
 To capture the structure of an address in our ER diagram. For example, might break
down an address into city, state, country, and Zip code, in addition to a string for
street information. By representing an address as an entity with these attributes, can
support queries such as “Find all employees with an address in AP, INDIA.

Consider another example to model a concept as an entity set rather than an attribute as
shown in below:

27
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

It records the interval during which an employee works for a department. Now suppose that it
is possible for an employee to work in a given department over more than one period. This
possibility is ruled out by the ER diagram's semantics. The problem is to record several
values for the descriptive attributes for each instance of the Works_In2 relationship. May
address this problem by introducing an entity set called, say, Duration, with attributes from
and to, as shown in below the Figure

Entity versus Relationship:


Consider the relationship set called Manages in the below Figure. Suppose that each
department manager is given a discretionary budget (dbudget), as shown in below the Figure,
in which the relationship set renamed to Manages2

Key Constraint of Manages

28
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

Entity versus Relationship

There is at most one employee managing a department, but a given employee could manage
several departments; we store the starting date and discretionary budget for each manager-
department pair. This approach is natural if we assume that a manager receives a separate
discretionary budget for each department that he or she manages. But what if the
discretionary budget is a sum that covers all departments managed by that employee? In this
case each Manages2 relationship that involves a given employee will have the same value in
the dbudget field. In general such redundancy could be significant and could cause a variety
of problems.

Binary versus Ternary Relationships:


Consider the ER diagram shown in below Figure. It models a situation in which an employee
can own several policies, each policy can be owned by several employees, and each
dependent can

be covered by several policies.

Fig: Policies as an Entity Set

The following additional requirements also there:


 A policy cannot be owned jointly by two or more employees.
 Every policy must be owned by some employee.
 Dependent is a weak entity set, and each dependent entity is uniquely identified by
taking pname in conjunction with the policyid of a policy.

The first requirement suggests that, it impose a key constraint on Policies with respect to
Covers, but this constraint has the effect that a policy can cover only one dependent. The

29
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

second requirement suggests that, it impose a total participation constraint on Policies. This
solution is acceptable if each policy covers at least one dependent.
The third requirement forces to introduce an identifying relationship that is binary as show in
below:

As a good example of a ternary relationship, consider entity sets Parts, Suppliers, and
Departments, and a relationship set Contracts that involves all of them. A contract specifies
that a supplier will supply a part to a department. This relationship cannot be adequately
captured by a collection of binary

relationships without the use of aggregation. With binary relationships, can denote that a
supplier `can supply' certain parts, that a department `needs' some parts, or that a department
`deals with' a certain supplier.

Aggregation versus Ternary Relationships:


The choice between using aggregation or a ternary relationship is mainly determined by the
existence of a relationship that relates a relationship set to an entity set. The choice may also
be guided by certain integrity constraints that we want to express. For example, consider the
ER diagram shown in Figure “Aggregation”. According to this diagram, a project can be
sponsored by any number of departments, a department can sponsor one or more projects,
and each sponsorship is monitored by one or more employees.

CONCEPTUAL DESIGN FOR LARGE ENTERPRISES

30
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor
DATABASE MANAGEMENT SYSTEMS SUB CODE:20A1302

We have thus far concentrated on the constructs available in the ER model for describ-
ing various application concepts and relationships. The process of conceptual design consists
of more than just describing small fragments of the application in terms of ER diagrams. For
a large enterprise, the design may require the efforts of more than one designer and span data
and application code used by a number of user groups. Using a high-level, semantic data
model such as ER diagrams for conceptual design in such an environment offers the additional
advantage that the high-level design can be diagrammatically represented and is easily
understood by the many people who must provide input to the design process. An important
aspect of the design process is the methodology used to structure the development of the
overall design and to ensure that the design takes into account all user requirements and is
consistent. The usual approach is that the requirements of various user groups are considered,
any conflicting requirements are somehow resolved, and a single set of global requirements is
generated at the end of the requirements analysis phase. Generating a single set of global
requirements is a difficult task, but it allows the conceptual design phase to proceed with the
development of a logical schema that spans all the data and applications throughout the
enterprise

The Entity-Relationship Model: An alternative approach is to develop separate conceptual


schemas for different user groups and to then integrate these conceptual schemas. To integrate
multiple conceptual schemas, we must establish correspondences between entities,
relationships, and attributes, and we must resolve numerous kinds of conflicts (e.g., naming
conflicts, domain mismatches, and differences in measurement units).This task is difficult in
its own right. In some situations schema integration cannot be avoided—for example, when
one organization merges with another, existing databases may have to be integrated. Schema
integration is also increasing in importance as users demand access to heterogeneous data
sources, often maintained by different organizations.

31
DEPT OF CSE ,ASCET Mrs.B.Sravni, Assistant Professor

You might also like