You are on page 1of 89

UNIT – I INTRODUCTION

 Database and Database Users:


 Characteristics of database approach
 Advantages of DBMS Approach
 Database Applications
 Database system concepts and architecture:
 Data models, Schemas, Instance
 Three schema architecture and data independence
 DBMS languages, DBMS interfaces
 database system Environment
 ER model
 EER data model
INTRODUCTION

What is Data?
 Data is a collection of Facts (or) Information such as numbers, characters, words etc..
(or)
 Data can be Qualitative (or) Quantitative
DATA

Qualitative Quantitative
Ex: “My name is hari”

Discrete [Whole number] Continuous [Within range]


Ex: 5 ,6, 7 Ex: 3.25, 5.68
INTRODUCTION

What is file management system?


 A file management system is a type of software that manages data files in a computer system.
 It has limited capabilities and is designed to manage individual or group files, such as special
office documents and records.
 It may display report details, like owner, creation date, state of completion and similar features
useful in an office environment.
Advantages of file management system:
1. Simpler to use
2. Less expensive
3. Popular FMS’s are packaged along with the operating systems. ( Note pad, Word pad, Microsoft
office etc..)
4. Fits the needs of many small businesses and home users.

Limitations:
1. Separated and Isolated Data - Makes coordinating, representing is data difficult.
2. Data Duplication - Wastes space and can lead to data integrity (inconsistency) problems.
3. Application Program Dependencies - Changes to a single file can require changes to numerous
application programs
INTRODUCTION

Disadvantages of file management systems:


1. Data redundancy and inconsistency
- Files are created by different programmers, different formats and written in several
programming languages. Moreover, same piece of information may be duplicated in
several places. This redundancy leads to high storage and data inconsistency.
2. Difficulty in accessing data
- Conventional file processing environments do not allow needed data to be retrieved
in a convenient and efficient manner.
3. Data isolation
- Data is scattered in various files, and files may be in different formats, it is difficult
to write new file to retrieve the appropriate data.
4. Integrity problems
- The data value stored in the database must satisfy certain types of consistency
constraints.
Ex: The balance of the bank account may never fall below a prescribed amount.
INTRODUCTION

5. Atomicity problems
- A computer system (or) any other devices subject to failure. [ Once failure has
occurred and has been detected, the data are restored to the consistent state existed
prior to the failure.
6. Concurrent access anomalies
- Multiple user may update the data simultaneously.
7. Security problem
- Not every user of the database system should be able to access all the data. It is
difficult to enforce such security constrains.
INTRODUCTION

What is DBMS?
DATABASE MANAGEMANT SYSTEM
 A database is refers to a collection of related data and the way of it is organized, access
to this data is usually provided by a database management system.
 DBMS is a collection of program ( or) software application that interact with user and
other application software.
INTRODUCTION

Some of the very well known DBMS are :


1. Microsoft Access

2. Oracle
3. FoxPro
4. SQLite
5. Firebird
6. Microsoft SQL Server
7. Postgre SQL
8. IBM DB2
9. SAP Sybase
10. R:Base

11. MYSQL

12. Microsoft Azure SQL Database (Cloud base) etc..


INTRODUCTION

Types of Database?
 DBMS is a computer software application used to manage a database.
There are Six main types of (DB) and these are based upon their management of database
structures:
1. Hierarchical DB
 A hierarchical database model is a data model in which the data is organized into a tree-like
structure.
 The data is stored as records which are connected to one another through links.
A record is a collection of fields, with each field containing only one value.
 This structure is simple but inflexible because the relationship is confined to a one-to-many
relationship
 Currently hierarchical databases are still widely used especially in applications that require
very high performance and availability such as banking and telecommunications
Another example of the use of hierarchical databases is Windows Registry in the Microsoft
Windows operating systems.
Structure Example:
INTRODUCTION

2. Network DB
 The network model is a data model conceived as a flexible way of representing
their relationships.
 Looks like several trees which share branches.
 Many-to-Many relationship
Structure Example:
INTRODUCTION

3. Relational DB
 A relational database management system (RDBMS) is a database management
system(DBMS) that is based on the relational model as invented by E. F. Codd, of
IBM's San Jose Research Laboratory.
 Many popular databases currently in use are based on the relational data base model.
 RDBMSs are a common choice for the storage of information in new databases used
for financial records, manufacturing and logistical information, personnel data, and
other applications since the 1980s.
 the most popular database management systems are Oracle, MySQL, Microsoft SQL
Server, PostgreSQL and IBM DB2.

Relational databases support:


 integers
 floating point
 character strings
 date-time
 currency
INTRODUCTION

Comparison between Hierarchical, Network and Relational database model


INTRODUCTION

Comparison between Hierarchical, Network and Relational database model


INTRODUCTION

Comparison between Hierarchical, Network and Relational database model


INTRODUCTION

4. Object DB
 An object database (also object-oriented database management system) is a database
management system in which information is represented in the form of objects as used in object
oriented programming .
 handle many new data types, including graphics, photographs, audio, and video, object-oriented
databases represent a significant advance over their other database.

Note:
Hierarchical and network databases are all designed to handle structured data;
that is,
 Data that fits nicely into fields, rows, and columns.
 They are useful for handling small snippets of information such as names, addresses, zip
codes, product numbers, and any kind of statistic or number you can think of.
On the other hand,
 An object-oriented database can be used to store data from a variety of media sources,
such as photographs and text, and produce work, as output, in a multimedia format.

Object databases support:


 Images / Video / Audio / Animations / Mixed Media
INTRODUCTION

5. Mobile DB
 A mobiledatabase is either a stationary database that can be connected to by a
mobile computing over a mobile network.
This could be a list of contacts, price information, distance travelled, or any other
information.
Example:
1. SQLite

6. Cloud DB
 A cloud database is a database that typically runs on a cloud computing platform.

There are two primary methods to run a database on the cloud:


1. Virtual machine Image (Microsoft Azure)
2. Database as a service (DBaaS) (Amazon Web Services)
INTRODUCTION

Define meta-data ? Metadata is literally "data about data."


Defining a database involves specifying the data type, structure and constraints of the data to be
stored in the database.
META-DATA

Structural metadata Descriptive metadata


Structural metadata:
Structural metadata is data about the containers of data.
Descriptive metadata
Descriptive metadata uses individual instances of application data or the data content.

Meta-data is defined as the data providing information about one or more aspects of the
data, such as:
 Creation of the data / Purpose of the data / Time and date of creation / Creator or author of the
data
 Location on a computer network where the data was created / Standards used
INTRODUCTION

There are several functions that a DBMS performs to ensure data integrity and
consistency of data in the database.
The Ten functions in the DBMS are:
1. Data dictionary management
Data Dictionary is where the DBMS stores definitions of the data elements and their
relationships (metadata). The DBMS uses this function to look up the required data
component structures and relationships.
2. Data storage management
Data storage management is used for the storage of data and any related data.
3. Data transformation and presentation
By using the data transformation and presentation function the DBMS can determine
the difference between logical and physical data formats.
Ex:
 Logical data is data about database. (It stores information about how data is
managed inside DB)
 Physical data the actual data is stored in bit format on the disk.
INTRODUCTION

4. Security management
This is one of the most important functions in the DBMS. Security management sets
rules that determine specific users that are allowed to access the database. (Users are
given a username and password)
5. Multiuser access control
Data integrity and data consistency are the basis of this function. it enables multiple
users to access the database simultaneously without affecting the integrity of the
database.
6. Backup and Recovery management
Backup and recovery is brought to mind whenever there is potential outside threats to
a database.
7. Data integrity management
The DBMS enforces these rules to reduce things such as data redundancy, which is
when data is stored in more than one place unnecessarily, and maximizing data
consistency, making sure database is returning correct/same answer each time for
same question asked.
INTRODUCTION

8. Database access languages and application programming interfaces


SQL (structured query language) is the most common query language supported by
the majority of DBMS vendors.
9. Database communication interfaces
This refers to how a DBMS can accept different end user requests through different
network environments. A DBMS can provide access to the database using the Internet
through Web Browsers (Mozilla Firefox, Internet Explorer, Netscape).
10. Transaction management
This refers to how a DBMS must supply a method that will guarantee that all the
updates in a given transaction are made or not made.
All transactions must follow what is called the ACID properties.
ACID = Atomicity, Consistency, Isolation, Durability.
INTRODUCTION

Example:
UNIVERSITY database for maintaining information concerning students,
courses, and grades in a university environment.

The database is organized as five files, each of which stores data records of
the same type:
1. The STUDENT file stores data on each student.
2. The COURSE file stores data on each course.
3. The SECTION file stores data on each section of a course.
4. The GRADE_REPORT file stores the grades that students receive in the
various sections they have completed.
5. The PREREQUISITE file stores the prerequisites of each course.
INTRODUCTION
Notice that records
in the various files
may be related.
INTRODUCTION

Example:
RAILWAY reservation database
CHARACTERISTICS OF DATABASE APPROACH

The main characteristics of the database approach versus the file-processing


approach are the following:

1. Self-describing nature of a database system


- The database system contains not only the database itself but also a complete
definition or description of the database structure and constraints. (meta-data)

2. Insulation between programs and data, and data abstraction


- The structure of data files is embedded in the application programs.
- So any changes to the structure of a file may require changing all programs that
access that file. in DBMS do not require such changes in most cases.
- The structure of data files is stored in the DBMS catalog separately from the access
programs. this property is known as program-data independence.
CHARACTERISTICS OF DATABASE APPROACH

In some types of database systems, such as object-oriented and object-relational


systems users can define operations on data as part of the database definitions.

 An operation (also called a function or method) is specified in two parts.


- The interface (or signature) of an operation includes the operation name and the data
types of its arguments (or parameters).
- The implementation (or method) of the operation is specified separately and can be
changed without affecting the interface.
- User application programs can operate on the data by invoking these operations
through their names and arguments, regardless of how the operations are implemented.
This may be termed program-operation independence.

The characteristic that allows program-data independence and program-


operation independence is called data abstraction.
(Data abstraction is simply a way of turning a complex problem into a
manageable one)
CHARACTERISTICS OF DATABASE APPROACH

An example of a
database catalog
for
the database.
CHARACTERISTICS OF DATABASE APPROACH

3. Support of multiple views of the data


 A database typically has many users, each of whom may require a different
perspective
or view of the database.

4. Sharing of data and multiuser transaction processing


A multiuser DBMS, as its name implies, must allow multiple users to access the
database at the same time.
This is essential if data for multiple applications is to be integrated and maintained in
a single database.
The DBMS must include concurrency control software to ensure that several users
trying to update the same data in a controlled manner so that the result of the updates
is correct.
ADVANTAGES OF DBMS APPROACH

Advantages of using a DBMS and the capabilities that a good DBMS should possess.

These capabilities are in addition to the four main characteristics (Refer above):

1. Controlling Redundancy ( Storing the same data multiple times leads to several
problems)
2. Restricting Unauthorized Access
3. Providing Persistent Storage for Program Objects ( Database can be used to provide
persistent storage for program objects and data structure)
Note: In traditional data base system suffer from “ Impedance mismatch
problem”.
1. Providing Storage Structures and Search Techniques for Efficient Query Processing
2. Providing Backup and Recovery
3. Providing Multiple User Interfaces
4. Representing Complex Relationships among Data
5. Enforcing Integrity Constraints (Business rules)
A BRIEF HISTORY OF DATABASE APPLICATIONS

Brief historical overview of the applications that use DBMSs and how these
applications provided the impetus for new types of database systems:

1. Early Database Applications Using Hierarchical and Network Systems

2. Providing Data Abstraction and Application Flexibility with Relational Databases

3. Object-Oriented Applications and the Need for More Complex Databases

4. Interchanging Data on the Web for E-Commerce Using XML

5. Extending Database Capabilities for New Applications like Banking, Airlines and railway
reservations, Universities, Telecommunication, Finance, Manufacturing and Sales, Human
Resources, E-Commerce, Scientific, Storage and Retrieval, Data Mining, Spatial, Weather
forecast etc..

6. Database versus information retrieval


DATA MODEL

Data abstraction:
Data abstraction generally refers to the suppression of details of data organization and storage, the
highlighting of the essential features for an improved understanding of data.

Data model:
A data model organizes data elements and standardized how the data elements relate to one
another. (It describes the structure of a database and also provide behavior of a database)
Note:
Structure means data types, constraints, relationships

Categories of data model:


1. Conceptual data model
2. Logical data model
3. Physical data model
DATA MODEL

1. Conceptual data model


A conceptual data model identifies the highest level relationships between the different entities.

Features:
 Conceptual data model includes Entities and the relationship among them.
 No attributes is specified.
 No primary key is specified
DATA MODEL

2. Logical data model


A logical data model describes the data in as much detail as possible, without regards to how
they will be physically implemented in the database.
DATA MODEL

Features:
 Logical data model includes all entities and the relationship among them.
 The primary key for each entity is specified.
 All attributes for each entity are specified.
 Foreign key ( key identifies the relation ship between different entities) are specified.
 Normalization occurs at this level.
DATA MODEL

2. Physical data model


- A physical data model represents how the model will be built in the database.
- A physical model shows all table structures including column name, column data type, column
constrains, primary key, foreign key, and relation ship between tables.
DATA MODEL

Features:
 Specification all tables and columns. ( convert entities into tables and attributes into columns )
 Foreign key are used to identify relationship between entities.
 De-normalization may occur based on user requirements.
 Physical considerations may cause the physical data model to be quite different from logical data
model.
 Physical data model will be different for different RDBMS. ( Data types for a column may be
different between oracle, DB2, mysql etc..)
DATABASE SCHEMA

 A database schema is the skeleton structure (or) description of the database that represents the
logical view of the entire database.
 It defines how the data is organized and how the relations among them are associated.
 It formulates all the constraints that are to be applied on the data.
DATABASE INSTANCE

The actual content of the database, the data, changes often over the years.
A database state at a specific time defined through the currently existing content and
relationship and their attributes is called a database instance. (The data in the
database at a particular moment of time is called an instance or a database state)

The following illustration shows that a database scheme could be looked at like a
template or building plan for one or several database instances.
DATABASE SCHEMA

A database schema can be divided broadly into two categories −


 Logical Database Schema −
The logical constraints that need to be applied on the data stored.
It defines tables, views, and integrity constraints.
 Physical Database Schema −
The actual storage of data and its form of storage.
It defines how the data will be stored in a secondary storage.
THE THREE-SCHEMA ARCHITECTURE

In this architecture, the overall database description can be defined at three levels,
namely internal, conceptual, and external levels called as three-level DBMS
architecture (or) Three schema architecture.
This architecture is proposed by ANSI/SPARC (American National Standards
Institute/Standards Planning and Requirements Committee) and hence, is also
known as ANSI/SPARC architecture These three levels are used to describe the
schema of the database at various levels.
To separate the user applications from the physical database In this architecture, schemas can be
defined at the following three levels:
THE THREE-SCHEMA ARCHITECTURE

The external level or view level:-


It is the highest level of abstraction that deals with the user’s view of the database
and thus, is also known as view level.
In general, most of the users and application programs do not require the entire data
stored in the database.
The external level describes a part of the database for a particular group of users.
It permits users to access data in a way that is customized according to their needs,
so that the same data can be seen by different users in different ways.
The conceptual level:-
This level of abstraction deals with the logical structure of the entire database and
thus, is also known as logical level.
It describes what data is stored in the database, the relationships among the data
and complete view of the user’s requirements without any concern for the physical
implementation.
The conceptual level has a conceptual schema, it describes the entities, data types, relationships,
user operations, and constraints.
The internal level:-
It is the lowest level of data abstraction that deals with the physical representation
of the database on the computer and thus, is also known as physical level.
DATA INDEPENDENCE

The main advantage of three-schema architecture is that it provides data independence.

Data independence is the ability to change the schema at one level of the database system without
having to change the schema at the other levels.
Data independence is of two types, namely, logical data independence and physical data
independence.

Logical data independence:


It is the ability to change the conceptual schema without affecting the external schemas or
application programs.
The conceptual schema may be changed due to change in constraints or addition of new data item
or removal of existing data item, etc.

Physical data independence:


It is the ability to change the internal schema without affecting the conceptual or external schema.
An internal schema may be changed due to several reasons such as for creating additional access
structure, changing the storage structure, etc.
DBMS LANGUAGES AND INTERFACES

 DBMS Languages
<Refer Book>
 DBMS Interfaces
<Refer Book>
DATA BASE SYSTEM ENVIRONMENT - COMPONENT MODULES OF A DBMS
COMPONENT MODULES OF A DBMS

Database system utilities : Help DBA to manage database system

Common utilities are:


1. Loading
- Loading utilities is used to load existing data files (source to target).
2. Backup
- A backup utility creates a backup copy of the database.
3. Database storage reorganization
- Reorganize a set of database files into a different file organization to improve performance.
4. Performance monitoring
- Monitors database usage and provides statistics to the DBA to improve the performance.
DATA MODELING USING ENTITY RELATIONSHIP MODEL

 Entity –Relationship (ER) modeling is an important step in information system design and
software engineering.

 The ER model describe the basic data structuring concepts and constraints of the ER model and
discuss their use in the design conceptual schemas for database application.

 The diagrammatic notation associated with the ER model is known as ER diagram, main
components of ER models are entities and their relationships.
DATA MODELING USING ENTITY RELATIONSHIP MODEL

Simplified description of the database design process


DATA MODELING USING ENTITY RELATIONSHIP MODEL

 Step 1: Requirement collection and analysis


 The requirements should be specified in as detailed and complete a form as possible.

 Functional requirement consist of transactions and both retrievals and updates.

(In s/w design it is common to use data flow diagram, sequence diagram, scenarios and other
techniques specified by functional requirements)

 Step 2: Create conceptual schema for the database


 The conceptual schema is a concise description of the data requirements of the users and
includes detailed descriptions of the entity types, relationships, and constraints.

 Step 3: Database design is the actual implementation of the database


Conceptual schema is transformed from the high-level data model into the implementation
data model.
This step is called logical design or data model mapping; its result is a database schema in the
implementation data model of the DBMS.

 Step 4: Physical design


The internal storage structures, file organizations, indexes, access paths, and
physical design parameters for the database files are specified.
DATA MODELING USING ENTITY RELATIONSHIP MODEL

Company Database
DATA MODELING USING ENTITY RELATIONSHIP MODEL

ER Model Describes data as Entities, Attributes and Relationships

Entity: An entity can be a real-world object.


For example : In a Company database
 Employee, Department, Project, Dependent can be considered as entities.
 All these entities have some attributes or properties that give them their identity.

Entity types , Entity sets, Domain:


 An entity type defines the collection of entities that have the same attributes.

 An entity set is a set of entities of the same type that share the same properties at
any point in time.
 Domain (Value set) – the set of permitted values for each attribute.

Entity type is like fruit is a class ,we haven't seen any "fruit“ yet though we have seen instance of
fruit like apple ,banana etc..

For example:
fruit=entity type=EMPLOYEE
apple=entity=e1 or e2 or e3
enity set= bucket of apple, banana ,mango etc={e1,e2......}
DATA MODELING USING ENTITY RELATIONSHIP MODEL

Keys:
Key is an uniquely identifies an entity among entity set.
For example,
1- Super Key 2- Candidate Key 3- Primary Key
4- Foreign Key 5- Alternate Key 6- Composite Key

Week Entity types: Entities based on their characteristics are classified as follows.

1- Strong Entity
An entity set that has a primary key is termed as strong entity set.
2- Weak Entity
An entity set that does not have sufficient attributes to form a primary key is termed as a
weak entity set. (partial key is used to identify other attributes of a weak entity set)
DATA MODELING USING ENTITY RELATIONSHIP MODEL

Attributes:
Entities are represented by means of their properties, called attributes.
All attributes have values. For example, a Employee entity may have name, Bdate, address, and
salary as attributes.
Several types of attributes are:
1. Simple
2. composite
3. Single valued
4. Multi valued
5. Stored and derived

Several types of attributes are:


1- Simple
Simple attributes are atomic values, which cannot be divided further.
For example, a Department number is an atomic value of 10 digits.
2- Composite
Composite attributes can be divided into smaller subparts, which represent more
basic attributes with independent meanings..
For example, a Employee name may have Fname, Miname and Lname.
DATA MODELING USING ENTITY RELATIONSHIP MODEL

3- Single valued
Most attributes have a single value for a particular entity; such attributes are called single-valued.
For example, Age is a single-valued attribute of a person.
4 - Multi valued
Multi-value attributes may contain more than one values. For example, a Employee can have
more than one phone number, email_address, etc.
5- Stored and derived
In some cases, two (or more) attribute values are related
for example, the Age and Birth_date attributes of a person.
For a particular person entity, the value of Age can be determined from the current (today’s) date
and the value of that person’s Birth_date.
The Age attribute is hence called a derived attribute and is said to be derivable from the Birth_date
attribute, which is called a stored attribute.

NULL Values
In some cases, a particular entity may not have an applicable value for an attribute.

Complex attributes
for example, a person can have more than one residence and each residence can have a single
address and multiple phones.
DATA MODELING USING ENTITY RELATIONSHIP MODEL

Relationships :
There are several implicit relationships among the various entity types.
An attribute of one entity type refers to another entity type, some relationship exists.
For example
 The attribute Manager of DEPARTMENT refers to an employee who manages the
department.
 The attribute Controlling_department of PROJECT refers to the department that
controls the project.

Relationship Types, Sets, and Instances:

 A relationship type R among n entity types (E1, E2, ..., En) defines a set of
associations—or a relationship set.
 The relationship set (A set of relationships of similar type is called a relationship set)
R is a set of relationship instances ri,
 where each ri associates n individual entities (e1, e2, ..., en),
 each entity ej in ri is a member of entity set Ej,
DATA MODELING USING ENTITY RELATIONSHIP MODEL

Relationships : The relationship set WORKS_FOR associates one EMPLOYEE entity and one
DEPARTMENT entity.
DATA MODELING USING ENTITY RELATIONSHIP MODEL

Relationships :

 A relationship type WORKS_FOR between the two entity types EMPLOYEE and
DEPARTMENT.
 Employees e1, e3, and e6 work for department d1; employees e2 and e4 work for department d2;
and employees e5 and e7 work for department d3.

Relationship Degree, Role Names, and Recursive Relationships


The number of participating entities in a relationship defines the degree of the
relationship.
 Binary = degree 2
 Ternary = degree 3
 n-ary = degree
The degree of a relationship type is the number of participating entity types.
Hence, the WORKS_FOR relationship is of degree two.
DATA MODELING USING ENTITY RELATIONSHIP MODEL

Role Names, and Recursive Relationships


 The role name signifies the role that a participating entity from the entity type plays in each
relationship instance, and helps to explain what the relationship means.
For example,
WORKS_FOR relationship type, EMPLOYEE plays the role of employee or worker and
DEPARTMENT plays the role of department or employer.

Constraints on Binary Relationship Types


 Relationship types usually have certain constraints that limit the possible combinations of entities
that may participate in the corresponding relationship set.
For example,
The company has a rule that each employee must work for exactly one department, then we would
like to describe this constraint in the schema.
two main types of binary relationship constraints:
 cardinality ratio ( The possible cardinality ratios for binary relationship types are 1:1, 1:N, N:1,
and M:N)
 Participation (This constraint specifies the minimum number of relationship instances
that each entity can participate)
NOTATION FOR ER DIAGRAMS
The diagrammatic notation associated with the ER model is known as ER diagram.
main components of ER models are entities and their relationships.

Database Design Techniques


 ER Modeling (Top down Approach)
 Normalization (Bottom Up approach)

Entity: An entity can be a real-world object.


In ER modeling, notation for entity is given below.
NOTATION FOR ER DIAGRAMS
Week Entity types: Entities based on their characteristics are classified as follows.

1- Strong Entity
An entity set that has a primary key is termed as strong entity set.
2- Weak Entity
An entity set that does not have sufficient attributes to form a primary key is termed as a
weak entity set. (partial key is used to identify other attributes of a weak entity set)
In ER modeling, notation for weak entity is given below.
NOTATION FOR ER DIAGRAMS
Attributes:
Entities are represented by means of their properties, called attributes.
In ER modeling, notation for attribute is given below.

Key attribute:
The attribute which is unique for every entity instance is called key attribute.
In ER modeling, notation for key attribute is given below.
NOTATION FOR ER DIAGRAMS
Multi valued attributes:
Multi-value attributes may contain more than one values. For example, a Employee can have
more than one phone number, email_address, etc.
In ER modeling, notation for multi-valued attribute is given below.
NOTATION FOR ER DIAGRAMS
Derived Attribute:
An attribute which can be calculated or derived based on other attributes is a derived attribute.

Example for derived attribute :


Age of employee which can be calculated from date of birth and current date.

In ER modeling, notation for derived attribute is given below.


NOTATION FOR ER DIAGRAMS

Relationships : Associations between entities are called relationships


The relationship set WORKS_FOR associates one EMPLOYEE entity and one DEPARTMENT
entity.
NOTATION FOR ER DIAGRAMS
In ER modeling, notation for relationship is given below.
NOTATION FOR ER DIAGRAMS
However in ER Modeling, To connect a weak Entity with others, you should use a
weak relationship notation as given below
NOTATION FOR ER DIAGRAMS
Degree of a Relationship
 Degree of a relationship is the number of entity types involved.
 The n-ary relationship is the general form for degree n. Special cases are unary,
binary, and ternary ,where the degree is 1, 2, and 3, respectively.
 Example for unary relationship : An employee ia a manager of another employee

 Example for binary relationship : An employee works-for department.


 Example for ternary relationship : customer purchase item from a shop keeper

Cardinality of a Relationship

 Relationship cardinalities specify how many of each entity type is allowed.


 Relationships can have four possible connectivity's as given below.
One to one (1:1) relationship
One to many (1:N) relationship
Many to one (M:1) relationship
Many to many (M:N) relationship
Note: The minimum and maximum values of this connectivity is called the
cardinality of the relationship
NOTATION FOR ER DIAGRAMS
Example for Cardinality – One-to-One (1:1)
 Employee is assigned with a parking space.

 One employee is assigned with


only one parking space and one
parking space is assigned
to only one employee.
Hence it is a 1:1 relationship
and cardinality is One-To-One (1:1)

 In ER modeling, this can be mentioned using notations as given below


NOTATION FOR ER DIAGRAMS
Example for Cardinality – One-to-Many (1:N)
 Organization has employees

 One organization can have


many employees ,
but one employee works
in only one organization.
Hence it is a 1:N relationship
and cardinality is One-To-Many (1:N)

 In ER modeling, this can be mentioned using notations as given below


NOTATION FOR ER DIAGRAMS
Example for Cardinality – Many-to-One (M :1)
 It is the reverse of the One to Many relationship. employee works in organization

 One employee works in only one


organization But one organization
can have many employees.
Hence it is a M:1 relationship and
cardinality is Many-to-One (M :1)

 In ER modeling, this can be mentioned using notations as given below


NOTATION FOR ER DIAGRAMS
Cardinality – Many-to-Many (M:N)
 Students enrolls for courses

 One student can enroll for


many courses and one course
can be enrolled by many students.
Hence it is a M:N relationship and
cardinality is Many-to-Many (M:N)

 In ER modeling, this can be mentioned using notations as given below


ADVANTAGES AND DISADVANTAGES OF ER MODEL

Advantages :
 ER Modeling is simple and easily understandable. It is represented in business users language and
it can be understood by non-technical specialist.
 Intuitive and helps in Physical Database creation.
 Can be generalized and specialized based on needs.
 Can help in database design.
 Gives a higher level description of the system.

Disadvantages:
 Physical design derived from E-R Model may have some amount of ambiguities or inconsistency.
 Sometime diagrams may lead to misinterpretations
ENTITY RELATIONSHIP (ER) MODEL
Here we are going to design an Entity Relationship (ER) model for a college database
1. A college contains many departments

2. Each department can offer any number of courses

3. Many instructors can work in a department

4. An instructor can work only in one department

5. For each department there is a Head

6. An instructor can be head of only one department

7. Each instructor can take any number of courses

8. A course can be taken by only one instructor

9. A student can enroll for any number of courses

10. Each course can have any number of students


ENTITY RELATIONSHIP (ER) MODEL
Step 1 : Identify the Entities

1. Department
2. Course
3. Instructor
4. Student

Step 2 : Identify the relationships

1. One department offers many courses. But one particular course can be offered by only one
department. hence the cardinality between department and course is One to Many (1:N)
2. One department has multiple instructors . But instructor belongs to only one department. Hence
the cardinality between department and instructor is One to Many (1:N)
3. One department has only one head and one head can be the head of only one department. Hence
the cardinality is one to one. (1:1)
4. One course can be enrolled by many students and one student can enroll for many courses.
Hence the cardinality between course and student is Many to Many (M:N)
5. One course is taught by only one instructor. But one instructor teaches many courses. Hence the
cardinality between course and instructor is Many to One (N :1)
ENTITY RELATIONSHIP (ER) MODEL
Step 3: Identify the key attributes

1. "Departmen_Name" can identify a department uniquely. Hence Department_Name is the key


attribute for the Entity "Department".
2. Course_ID is the key attribute for "Course" Entity.
3. Student_ID is the key attribute for "Student" Entity.
4. Instructor_ID is the key attribute for "Instructor" Entity.

Step 4: Identify other relevant attributes

1. For the department entity, other attributes are location


2. For course entity, other attributes are course_name,duration
3. For instructor entity, other attributes are first_name, last_name, phone
4. For student entity, first_name, last_name, phone
ENTITY RELATIONSHIP (ER) DIAGRAMS
Step 4: Draw complete ER diagram
NOTATION FOR ER DIAGRAMS
ENTITY RELATIONSHIP (ER) DIAGRAMS

Company Database
ENTITY RELATIONSHIP (ER) DIAGRAMS
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL

What is the difference between ERD (Entity relationship diagram) and EERD (enhanced entity
relationship diagram) in database design?

ER Model(Entity relationship diagram) is a popular high-level (conceptual) data model. It is


an approach to designing Semantic Conceptual schema of a Database.
ER model allows us to describe the data involved in a real-world environment in terms of objects
and their relationships, which are widely used in design of database.

ER model provides preliminary concepts or idea about the data representation which is later
modified to achieve final detailed design.

EER Model is for applications like –GIS, CAD/CAM, Telecommunication which are more
complex requirements than normal database applications.
To meet the requirements additional modeling concepts were incorporated into Conceptual data
modeling such as ER modeling.
The result is EER, stands for Extended ER modeling or Enhanced ER modeling.
The additional EER concepts are used to model applications more completely and more
accurately.
EER includes some object-oriented concepts, such as inheritance.
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
EER model includes all modeling concepts of the ER model
In addition, EER includes:
 Subclasses and super classes
 Specialization and generalization
 Attribute and relationship inheritance
 Category or union type

Why Extend the E-R Model:


 E-R is suitable for traditional business applications and not semantically rich enough for
advanced applications.

Applications where E-R is inadequate:


 Geographical information systems
 Search engines / Data mining
 Multimedia
 CAD/CAM
 Software development
 Engineering design...and others
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
Subclasses and super classes :
Entity type is used to represent both a type of entity and the entity set or collection of entity.
 An entity type may have additional meaningful sub groupings of its entities
 Example: EMPLOYEE may be further grouped into:
 SECRETARY, ENGINEER, TECHNICIAN, …

 Based on the EMPLOYEE’s Job

 MANAGER

 EMPLOYEEs who are managers

 SALARIED_EMPLOYEE, HOURLY_EMPLOYEE

 Based on the EMPLOYEE’s method of pay

 To represent these additional sub groupings, called subclasses or subtypes, Each of these sub
groupings is a subset of EMPLOYEE entities.
 EMPLOYEE is the super class for each of these subclasses
 These are called super class/subclass relationships:
 EMPLOYEE/SECRETARY
 EMPLOYEE/TECHNICIAN
 EMPLOYEE/MANAGER ...
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
 EER Diagram
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
Specialization and generalization :

 Specialization is the process of defining a set of subclasses of an entity type; this entity type is
called the superclass of the specialization.

 The set of subclasses that forms a specialization is defined on the basis of some distinguishing
characteristic of the entities in the superclass.

For Example:
Set of sub classes {SECRETARY, ENGINEER, TECHNICIAN} is a specialization of the
superclass EMPLOYEE .

 The subclasses that define a specialization are attached by lines to a circle that represents the
specialization (Subset symbol).

 Attributes of a subclass are called specific or local attributes.

 It is a top-down approach in which one higher level entity can be broken down into two lower
level entity.
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
Specialization and generalization :
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
 Specialization and generalization :

Generalization is a bottom-up approach in which two lower level entities combine to form a
higher level entity.

For Example:
- Consider the entity types CAR and TRUCK have several common attributes, they can be
generalized into the entity type VEHICLE.

- Both CAR and TRUCK are now subclasses of the generalized superclass VEHICLE.

 We can view {CAR, TRUCK} as a specialization of VEHICLE, rather than viewing VEHICLE as
a generalization of CAR and TRUCK.
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
Specialization and generalization :
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
Constraints:
Two basic constraints can apply to a specialization/generalization:
1- Disjointness Constraint
- Specifies that the subclasses of the specialization must be disjoint:
- The entity can be a member of at most one of the subclasses of the specialization.
- Specified by d in EER diagram.
- If not disjoint, specialization is overlapping:
-The entity can be a member of more than one subclass of the specialization.
- Specified by o in EER diagram.

2- Completeness Constraint
- Total specifies that every entity in the super class must be a member of some subclass in the
specialization/generalization.
- Shown in EER diagrams by a double line.

- Partial allows an entity not to belong to any of the subclasses.


- Shown in EER diagrams by a single line.
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
Constraints:
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
Hence, we have four types of specialization/generalization:
1 - Disjoint, total
2 - Disjoint, partial
3 - Overlapping, total
4 - Overlapping, partial
< REFER BOOK >
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
A subclass may itself have further sub classes specified on it
- forms a hierarchy or a lattice
Hierarchy has a constraint that every subclass has only one super class (called single
inheritance); this is basically a tree structure
In a lattice, a subclass can be subclass of more than one super class (called multiple inheritance)
THE ENHANCED ENTITY-RELATIONSHIP (EER) MODEL
Category (or) Union type:

You might also like