0% found this document useful (0 votes)
9 views87 pages

Module-1 Lecture Notes

The document outlines a course on Database Management Systems led by Prof. Bhupendra Panchal, detailing expected outcomes, modules, and syllabus. Key topics include the advantages of DBMS over traditional file systems, database design using ER models, SQL query construction, and transaction management. It also covers data abstraction levels, database languages (DDL, DML, DCL, TCL), and the functions of a Database Administrator.

Uploaded by

Aarav gt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views87 pages

Module-1 Lecture Notes

The document outlines a course on Database Management Systems led by Prof. Bhupendra Panchal, detailing expected outcomes, modules, and syllabus. Key topics include the advantages of DBMS over traditional file systems, database design using ER models, SQL query construction, and transaction management. It also covers data abstraction levels, database languages (DDL, DML, DCL, TCL), and the functions of a Database Administrator.

Uploaded by

Aarav gt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 87

CSE3001

Database Management Systems

Prof. Bhupendra Panchal


Assistant Professor
Expected Outcomes:

• Advantages of using a DBMS rather than a file system.

• Designing an Entity-Relationship model for a real life application.

• Mapping a database schema from ER model.

• Evaluating relational schemas for design qualities

• Optimize a query.

• Basic concepts on transaction processing, concurrency control and recovery.

• Fundamental view on unstructured data and its management.

• Storage of databases and techniques to access them using various algorithms

Prepared and compiled by 2


Bhupendra Panchal, Asst. Professor, CSE
Expected Outcomes:

• Explain the role of a database management system in an organization.

• Describe the structure and operation of the relational data model.

• Construct database queries using Structured Query Language (SQL).

• Design and implement a database project depending on the business


requirements, considering various design issues.

• Implement the concept of a database transaction and related database


facilities, including concurrency control, backup and recovery.

Prepared and compiled by 3


Bhupendra Panchal, Asst. Professor, CSE
Modules Syllabus
Module- Introduction to Database system: purpose of database system, view of data,
1 Independence, relational databases, -Database Language-Database System
architecture- levels, Mappings, Database, users and DBA Data Models: Importance,
Basic building blocks, Degrees of data abstraction. Database design and ER Model:
Overview, ER-Model, Constraints, ER Diagrams, ERD Issues, weak entity sets.
Module- Relational Models: Structure of relational databases, Domains, Relations, Relational
2 algebra – fundamental operators and syntax, selection, Projection, relational
algebra queries, tuple relational calculus, set operations, renaming, Joins, Division,
syntax. Operators, grouping and ungrouping, relational comparison. Codd’s rules,
Relational Schemas, Introduction to UML Relational database model: Logical view
of data, keys, integrity rules. Normalization: 1NF, 2NF, 3NF, BCNF, Multi valued
dependencies and Fourth Normal Form.
Module- Relational Database design: features, atomic domain. SQL: data definition,
3 aggregate function, Null Values, nested sub queries, Joined relations. Triggers. Data
Manipulation Language (DML) and Transaction Control Language (TCL) , Basic
SELECT statements , Table Joins, Restricting and Sorting Data - Order By / Group By.
Retrieving Data Using the SQL SELECT Statement, Single-Row Functions, Conversion
Functions and Conditional Expressions, Reporting Aggregated Data Using the Group
Functions, Displaying Data from Multiple Tables. Joins, Set Operators, DML
Statements, Data Definition Language - Data Dictionary Views - Creating Sequences,
Synonyms, and Indexes, Creating Views - Introduction to views, data independence,
security, updates on views, Prepared and compiled by
comparison between tables and views. 4
Bhupendra Panchal, Asst. Professor, CSE
Modules Syllabus
Module- PL/SQL: Declaring PL/SQL Variables, Writing Executable Statements, Using SQL
4 Statements Within a PL/SQL Block, Control Structures, Composite Data Types, Using
Explicit Cursors, Handling Exceptions, Introducing Stored Procedures and Functions.
Data Storage: Overview of Physical Storage Media - Magnetic disk Flash storage -
RAID-File and Record Organization-Indexing and Hashing, Ordered Indices - B+ Tree
Index File-Static Hashing -Dynamic Hashing Query Processing: Overview-measures
of Query Cost. Query Optimization Techniques- Cost based Optimization-Heuristic
Optimization
Module- Transaction Management: Transaction concepts-properties of transactions-
5 Transaction Atomicity and Durability-Transaction Isolation- Implementation of
Isolation Levels-serializability of transactions, testing for serializability. Concurrency
Control: Lock based protocols--Deadlock handling-Multiple Granularity-Time stamp
based protocols -System recovery, Two- Phase Commit protocol, Recovery system:
Failure classification --Recovery and atomicity Recovery Algorithms.

Prepared and compiled by 5


Bhupendra Panchal, Asst. Professor, CSE
Introduction to Database:

• What is Data?
– Collection of raw facts.
– Facts that can be recorded and have implicit meaning, known as data.
– For ex: Students records- rno, name, address…

• Database
– Collection of interrelated data.
– Can be stored in the form of tables.
– Data can be stored, updated, deleted either manually or computerized.
Rno Name Address
101 Ajay Bhopal
102 Sahil Ujjain
Prepared and compiled by 6
Bhupendra Panchal, Asst. Professor, CSE
Introduction to Database Cont….:

• Database Management System

– DBMS is collection of interrelated data items and set of programs to easily


store, update and retrieve those data.

– Interrelated Data + Set of programs Instructions

– Primary goal of DBMS is to perform the operations for data without any
anomalies.

Prepared and compiled by 7


Bhupendra Panchal, Asst. Professor, CSE
Database Approach vs Traditional File System
Approach

• Disadvantages of File Processing Systems


– Data Redundancy
– Difficulties in accessing the data
– Data Isolation
– Atomicity (All or None)
– Concurrency Control Anomalies
– Security
– Integrity Constrains
• Domain Constrains
• Key Constrains
• Referential Integrity

Prepared and compiled by 8


Bhupendra Panchal, Asst. Professor, CSE
DBMS Architecture:

• Three Tier Architecture of DBMS:

• User interface
Presentation Tier • View level
• Application server
& Programs
• Logics Application Tier • Query Processing
• Abstraction Language
• Relation of Data
Database Tier • Constrains

Prepared and compiled by 9


Bhupendra Panchal, Asst. Professor, CSE
DBMS Architecture

Prepared and compiled by 10


Bhupendra Panchal, Asst. Professor, CSE
Three Level Database Schema Architecture:

Prepared and compiled by 11


Bhupendra Panchal, Asst. Professor, CSE
Three Level Schema Architecture:
1. Internal Level
• The internal level schema describes the physical storage and data structure of the database.
• It is also known as a physical schema and it uses physical data model.
• It is used to define that how the data will be stored in a block.

2. Conceptual Level
• The conceptual schema describes the design of a database at the conceptual level.
• Conceptual level is also known as logical level.
• The conceptual level describes what data are to be stored in the database and also describes
what relationship exists among those data.
• In this level, internal details such as an implementation of the data structure are hidden.
• Programmers and database administrators work at this level.

3. External Level
• The external level describes the different views of the database.
• An external schema is also known as view schema.
• Each view schema describes the database part that a particular user group is interested and
hides the remaining database from that user group.
• The view schema describes the end user interaction with database systems.
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
Levels of Data Abstraction or View of Data:

• Three levels of Data Abstraction

External View Level Snapshots, Views of Data

What Data is stored & What is


Conceptual Level relationship among Data?

Internal/Physical
How the Data is actually stored?
Level
Prepared and compiled by 13
Bhupendra Panchal, Asst. Professor, CSE
Data Independence:

– A Database System that is able to separate three different levels of


abstraction is likely to be flexible and adaptable.
– This flexibility and adaptability is called DATA INDEPENDENCE.
– Means if we change in low level then higher level should not be
affected.

– Two types of Data Independence:


• Physical Data Independence:
– Separation of Conceptual & View from Internal View
– Without specifying the physical structure of Database

• Logical Data Independence


– Separation of external view from conceptual view
– Changes in concepts without affecting external view

Prepared and compiled by 14


Bhupendra Panchal, Asst. Professor, CSE
Database Schemas & Instances:

Database Schemas:
• It is the description of Database (Overall design of Database).
• Specified during database design.
• Not expected to change frequently.

Student (Roll_No Varchar(10), Name Char(30), Address varchar(30),


Phone_No Number(10), DOB date……..)

Department (Dept_Id Varchar(10), Dept_Name Char(10), Course_Name


Char(20)…….)

Prepared and compiled by 15


Bhupendra Panchal, Asst. Professor, CSE
Database Schemas & Instances Cont.…:

Database Instances:
• Collection of information stored in the database at particular
state of time.
• Snapshot of Database.

• Find those students who lives in Bhopal-


Roll No Name Contact No Address
101 Ajay 123 BPL
125 Kartik 456 BPL
140 Rahul 789 BPL

Prepared and compiled by 16


Bhupendra Panchal, Asst. Professor, CSE
Database Languages:
1. DDL (Data Definition Language):
– It is used to define database structure or pattern.
– It is used to create schemas, tables, indexes, constraints, etc. in
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 Commands 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.

Prepared and compiled by 17


Bhupendra Panchal, Asst. Professor, CSE
Data Definition Language:

SQL> create table student_detail(roll_no number(10), name char(30));


Table created.

SQL> alter table student_detail add(contact_no number(10), address varchar(20));


Table altered.

SQL> alter table student_detail modify(roll_no varchar(20) primary key);


Table altered.

SQL> alter table student_detail drop(contact_no);


Table altered.

SQL> rename student_detail to student;


Table renamed.

Prepared and compiled by 18


Bhupendra Panchal, Asst. Professor, CSE
Data Definition Language:
SQL> desc student;

Name Null? Type


---------------------------- -------- ----------------------------
ROLL_NO NOT NULL VARCHAR2(20)
NAME CHAR(30)
ADDRESS VARCHAR2(20)

SQL> truncate table student;


Table truncated.

SQL> drop table student;


Table dropped.

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Database Languages Cont.…:

2. DML (Data Manipulation Language):


– It is used for accessing and manipulating data in a
database.
– It handles user requests.

Here are some Commands that come under DML:


Select: It is used to retrieve data from a database.
Insert: It is used to insert data into a table.
Update: It is used to update existing data within a table.
Delete: It is used to delete all records from a table.

Prepared and compiled by 20


Bhupendra Panchal, Asst. Professor, CSE
Data Manipulation Language:

SQL> insert into student values ('CS101', 'Ajay', 'Bhopal');

SQL> insert into student values ('CS102', 'Aman', 'Ujjain');

SQL> insert into student values ('CS103', 'Amit', '');

SQL> insert into student (roll_no) values ('CS104');

SQL> insert into student (name) values ('Anuj');


insert into student (name) values ('Anuj')
*
ERROR at line 1:
ORA-01400: cannot insert NULL into ("SYSTEM"."STUDENT"."ROLL_NO")

SQL> insert into student (roll_no, name) values ('CS105','Anuj');


Prepared and compiled by 21
Bhupendra Panchal, Asst. Professor, CSE
Data Manipulation Language:
SQL> select *from student;

ROLL_NO NAME ADDRESS


-------------------- ------------------------------ --------------------
CS101 Ajay Bhopal
CS102 Aman Ujjain
CS103 Amit
CS104
CS105 Anuj

SQL> select roll_no, name from student;

ROLL_NO NAME
-------------------- ------------------------------
CS101 Ajay
CS102 Aman
CS103 Amit
CS104
CS105 Anuj Prepared and compiled by 22
Bhupendra Panchal, Asst. Professor, CSE
Data Manipulation Language:
SQL> select * from student where address= 'Bhopal';

ROLL_NO NAME ADDRESS


-------------------- ------------------------------ --------------------
CS101 Ajay Bhopal

SQL> select address from student where roll_no= 'CS104';


ADDRESS
--------------------

SQL> select roll_no as roll_number from student;

ROLL_NUMBER
--------------------
CS101
CS102
CS103
CS104
CS105 Prepared and compiled by 23
Bhupendra Panchal, Asst. Professor, CSE
Data Manipulation Language:

SQL> update student set address='Bhopal' where roll_no='CS103';

SQL> update student set name='Anay', address='Ujjain' where roll_no='CS104';

SQL> update student set address='Indore' where name='Anuj';

SQL> select * from student;

ROLL_NO NAME ADDRESS


-------------------- ------------------------------ --------------------
CS101 Ajay Bhopal
CS102 Aman Ujjain
CS103 Amit Bhopal
CS104 Anay Ujjain
CS105 Anuj Indore
Prepared and compiled by 24
Bhupendra Panchal, Asst. Professor, CSE
Data Manipulation Language:

SQL> delete from student where roll_no='CS104';

1 row deleted.

SQL> delete from student where address='Bhopal';

2 rows deleted.

SQL> select * from student;

ROLL_NO NAME ADDRESS


-------------------- ------------------------------ --------------------
CS102 Aman Ujjain
CS105 Anuj Indore

Prepared and compiled by 25


Bhupendra Panchal, Asst. Professor, CSE
Database Languages Cont.…:

3. DCL (Data Control Language):


– It is used to retrieve the stored or saved data.
Here are some Commands 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.

4. TCL (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 Commands that come under DCL:
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.
Prepared and compiled by 26
Bhupendra Panchal, Asst. Professor, CSE
Functions of DBA:

1. Designing Conceptual & Physical Schema

2. Security & Authorization

3. Data Availability & Recovery from failures

4. Storage Structure and Access Method Definitions

5. Integrity Constrains Specifications

Prepared and compiled by 27


Bhupendra Panchal, Asst. Professor, CSE
Data Models:

• Collection of concept that can be used to describe the structure of


DBMS like datatypes, relationships and constrains.
• Specifies the dynamic aspects and behavior of database applications.
• Relatively simple representations, usually graphical of complex real-
world data structures.
• Facilitate interaction among the designer, applications programmer and
the end user.

28
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
The Evolution of Data Models:

– High Level or Object Based Data Model


• Entity Relationship Model
• Object Oriented Data Model

– Representation or Record Based Data Model


• Relational Model
• Network Model
• Hierarchical Model

– Low Level or Physical Data Model


• Unifying Model
• Frame Memory Model

31
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
The Entity Relationship Model
– Widely accepted and adapted graphical tool for data modeling.
– ER Model is a high-level conceptual data model diagram.
– ER model helps you to analyze data requirements to produce a
well-designed database.
– Graphical representation of entities and their relationships in a
database structure.
– In other words, ER diagrams help to explain the logical structure of
databases.

– Components of ER Model:
• Entity
• Relationship
• Attributes
32
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
The Entity Relationship Model Example-

Prepared and compiled by 33


Bhupendra Panchal, Asst. Professor, CSE
The Object Oriented Model
– Modeled both data and their relationships in a single structure
known as an object.
– Object-oriented data model (OODM) is the basis for the object-
oriented database management system (OODBMS).
– OODM is said to be a semantic data model.
– Object becomes basic building block for autonomous structures.

Components of OODM: Object and Class


– Object is an abstraction of a real-world entity.
– Attributes describe the properties of an object.
– Objects that share similar characteristics are grouped in classes.
– Inheritance is the ability of an object within the class hierarchy to
inherit the attributes and methods of classes above it.
34
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
The Object Oriented Model Example-

Prepared and compiled by 35


Bhupendra Panchal, Asst. Professor, CSE
The Relational Model

• Developed by Codd (IBM) in 1970.


• Conceptually simple.
• Extension for Relational Database Management System (RDBMS).
• Most important advantage of the RDBMS is its ability to hide the
complexities of the relational model from the user.

A Relational Model comprises of-

Relational diagram-
• Representation of relational database’s entities, attributes within those
entities, and relationships between those entities.

Prepared and compiled by 36


Bhupendra Panchal, Asst. Professor, CSE
The Relational Model Cont.….

Relational Table (relations)


• Stores a collection of related entities
• Matrix consisting of a series of row/column intersections
• Relational table is purely logical structure
• How data are physically stored in the database is of no concern to the
user or the designer.
• This property became the source of a real database revolution.

Structured Query Language (SQL)


• Allows users to specify what must be done without specifying how it
must be done.
• SQL-based relational database application involves- User interface, set
of tables stored in the database and SQL engine.

Prepared and compiled by 37


Bhupendra Panchal, Asst. Professor, CSE
The Relational Model Example-

Prepared and compiled by 38


Bhupendra Panchal, Asst. Professor, CSE
The Hierarchical Model

• Developed in the 1960s to manage large amounts of data for complex


manufacturing projects.
• Basic logical structure is represented by an upside-down “tree”
• The hierarchical structure contains levels or segments.
• Depicts a set of one-to-many (1:M) relationships between a parent and
its children segments.

Prepared and compiled by 39


Bhupendra Panchal, Asst. Professor, CSE
The Hierarchical Model Example-

Prepared and compiled by 40


Bhupendra Panchal, Asst. Professor, CSE
The Hierarchical Model Cont.….

Advantages
• Many of the hierarchical data model’s features formed the foundation
for current data models.
• Its database application advantages are replicated in current database
environments.

Disadvantages
• Complex to implement
• Difficult to manage
• Implementation limitations

Prepared and compiled by 41


Bhupendra Panchal, Asst. Professor, CSE
The Network Model

• Developed to represent complex data relationships more effectively.


• Improve database performance with the help of links/connections.
• Collection of records in M:M relationships.

Prepared and compiled by 42


Bhupendra Panchal, Asst. Professor, CSE
ER (Entity Relationship) Models :

– ER Model is a high-level conceptual data model diagram.

– ER modeling helps you to analyze data requirements to produce a


well-designed database.

– The Entity-Relation model represents real-world entities and the


relationship between them.

– In other words, ER diagrams help to explain the logical structure of


databases.

– Components of ER Model:
• Entity
• Relationship
43
• Attributes
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
Components in ER Model:

44

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Symbols Used in ER:

Prepared and compiled by 45


Bhupendra Panchal, Asst. Professor, CSE
Entity & Entity Types:

– An Entity may be an object with a physical existence – a


person, car, house or employee.
– It may be an object with a conceptual existence – a company,
a job, or a university course.
– An Entity is an object of Entity Type and set of all entities is
called as entity set.
– An entity is represented as rectangle in an ER diagram.
– For example: In the following ER diagram we have two
entities Student and College-

Prepared and compiled by 46


Bhupendra Panchal, Asst. Professor, CSE
Types of Entities:

– Strong Entity: An entity that contains a unique key is called


strong entity.
– Weak Entity Sets: The entity set which does not have sufficient
attributes to form a primary key is called as Weak entity set.
– Weak entity is represented by a double rectangle.

Prepared and compiled by 47


Bhupendra Panchal, Asst. Professor, CSE
Attributes & Types:

– An attribute describes the property of an entity.


– An attribute is represented as Oval in an ER diagram.

– There are four types of attributes:


1. Key attribute
2. Simple & Composite attribute
3. Single valued & Multivalued attribute
4. Stored & Derived attribute

Prepared and compiled by 48


Bhupendra Panchal, Asst. Professor, CSE
1. Key Attribute:

– A key attribute can uniquely identify an entity from an entity


set.
– Key attribute is represented by oval same as other attributes
however the text of key attribute is underlined.

Prepared and compiled by 49


Bhupendra Panchal, Asst. Professor, CSE
2. Simple & Composite Attributes:

– An attribute that is a combination of other attributes is


known as composite attribute.

Prepared and compiled by 50


Bhupendra Panchal, Asst. Professor, CSE
3. Single Valued & Multivalued Attributes:

– An attribute that can hold multiple values is known as


multivalued attribute.
– It is represented with double ovals in an ER Diagram.
– For example – A person can have more than one phone
numbers so the phone number attribute is multivalued.

DOB
Phone_No
Student

Prepared and compiled by 51


Bhupendra Panchal, Asst. Professor, CSE
4. Stored & Derived Attributes:

– A derived attribute is one whose value is dynamic and


derived from another attribute.
– It is represented by dashed oval in an ER Diagram.

DOB

Student

Prepared and compiled by 52


Bhupendra Panchal, Asst. Professor, CSE
Types of Attributes:

Prepared and compiled by 53


Bhupendra Panchal, Asst. Professor, CSE
Relationship in ER Model:

• Association among the entities is called relationship.


• A relationship is represented by diamond shape in ER diagram,
it shows the relationship among entities.

• There are four types of relationships:


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

Prepared and compiled by 54


Bhupendra Panchal, Asst. Professor, CSE
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.

Prepared and compiled by 55


Bhupendra Panchal, Asst. Professor, CSE
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
relationship.

• For example – a customer can place many orders but a order


cannot be placed by many customers.

Prepared and compiled by 56


Bhupendra Panchal, Asst. Professor, CSE
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.

Prepared and compiled by 57


Bhupendra Panchal, Asst. Professor, CSE
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 relationship.

• For example, a student can be assigned to many projects and a


project can be assigned to many students.

Prepared and compiled by 58


Bhupendra Panchal, Asst. Professor, CSE
Participation Constraints:
• Total Participation − Each entity in the entity set occurs at least one
relationship in that relationship set. Total participation is represented
by double lines.
Customer Borrows Loan

Here each loan entity is associated with at least one associated customer.

Prepared and compiled by 59


Bhupendra Panchal, Asst. Professor, CSE
Participation Constraints:
• Partial Participation − Each entity in the entity set may not occur in
at least one relationship in that relationship set.

Employee Manage Department


s

Not every employee manages Every department is managed


a department. by at least one employee
(called Manager).
So here is partial
participation of employee in So here is total participation
‘manages’ relationship of department in manages
relationship

Prepared and compiled by 60


Bhupendra Panchal, Asst. Professor, CSE
Recursive Relationship:

• If the same entity participates more than once in a relationship it


is known as a recursive relationship.
• In the below example an employee can be a manager and can be
worker, so there is a recursive relationship.

Worker
Work
Employee For
Manager

Prepared and compiled by 61


Bhupendra Panchal, Asst. Professor, CSE
Steps to create an ER Diagram:

In a university, a Student enrolls in Courses. A student must be


assigned to at least one or more Courses. Each course is taught by a
single Professor. To maintain instruction quality, a Professor can
deliver only one course.

Step 1) Entity Identification


• Student
• Course
• Professor

Prepared and compiled by 62


Bhupendra Panchal, Asst. Professor, CSE
Steps to create an ER Diagram:

Step 2) Relationship Identification

We have the following two relationships


• The student is assigned a course
• Professor delivers a course

Prepared and compiled by 63


Bhupendra Panchal, Asst. Professor, CSE
Steps to create an ER Diagram:

Step 3) Cardinality Identification

For them problem statement we know that,


• Many students can be assigned to multiple courses
• A Professor can deliver only one course

Prepared and compiled by 64


Bhupendra Panchal, Asst. Professor, CSE
Steps to create an ER Diagram:

Step 4) Identify Attributes


• Initially, it's important to identify the attributes without mapping
them to a particular entity.
• Ensure an attribute is to be paired with exactly one entity.
• If you think an attribute should belong to more than one entity,
use a modifier to make it unique.

Prepared and compiled by 65


Bhupendra Panchal, Asst. Professor, CSE
Student Class Management ER Diagram:

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
Extended Features in ER Diagram:

Aggregation:

• Relationship among the relationship.


• It is used to represent a relationship between a whole object and
its component part.
• It allows us to indicate that a relationship set participates in
another relationship set.
• It is an abstraction for building composite objects from their
component objects.
• It is represented by dashed line in an ER diagram.

Prepared and compiled by 68


Bhupendra Panchal, Asst. Professor, CSE
Aggregation in ER Diagram:

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE 69
Aggregation in ER Diagram:

Prepared and compiled by 70


Bhupendra Panchal, Asst. Professor, CSE
Generalization in ER Diagram:

Generalization
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE 71
Specialization in ER Diagram:

Specialization
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE 72
Specialization & Generalization in ER Diagram:

Prepared and compiled by 73


Bhupendra Panchal, Asst. Professor, CSE
Specialization & Generalization in ER Diagram:

Generalization
Specialization

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE 74
Conversion of ER Model into Relational Model

1. ER with Key Attribute:

Employee
Eid Name Salary
1201 Aman 56,000
1202 Prateek 49,000
1203 Bhavya 52,000

Prepared and compiled by 75


Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

2. Entity set with Composite Attribute:

Employee
Eid Name Basic HRA TA DA
1201 Aman 32000 3000 1500 4500
1202 Prateek 29000 3000 1500 4500
1203 Bhavya 30000 3000 1500 4500

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

3. ER with Multivalued Attribute:


Employee
Eid Name Salary City
1201 Aman 56,000 Indore, Bhopal
1202 Prateek 49,000 Indore
1203 Bhavya 52,000 Bhopal

Employee Employee
Eid Name Salary Eid City
1201 Aman 56,000 1201 Indore
1202 Prateek 49,000 1201 Bhopal
1203 Bhavya 52,000 1202 Indore
1203 Bhopal
Prepared and compiled by
Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model
4. Translating Relationship set into Relations:

Employee Works_in Department


Eid Name Salary Eid Did Since Did Dname
1201 Aman 56,000 1201 D02 01-02-2018 D01 HR
1202 Prateek 49,000 1202 D01 18-05-2020 D02 Admin
1203 Bhavya 52,000 1202 D02 18-05-2020 D03 Finance
1204 Ravish 53,000 1203 D03 01-07-2020
1204 D02 16-01-2019
1204 D03
Prepared 16-01-2019
and compiled by
Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

5. Relationship with key constraints: (One to Many)

Each department is required to have at most one employee as manager

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Manages

Employee Eid Did


Department
Eid Name Salary 1201 D02
Did Dname
1201 Aman 56,000 1202 D01
D01 HR
1202 Prateek 49,000 1202 D02
D02 Admin
1203 Bhavya 52,000 1203 D03
D03 Finance
1204 Ravish 53,000 1204 D02
1204 D03

Department
Did Dname Eid
D01 HR 1202
D02 Admin 1202
D03 Finance 1203
Prepared and compiled by 80
Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

6.1 One to Many:

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

6.2 Many to One:

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

6.3 Many to Many:

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

6.4 One to One:

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

Find the minimum no. of tables that are possible for converting
into ER Model

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Conversion of ER Model into Relational Model

Find the minimum no. of tables that are possible for converting
into ER Model

Prepared and compiled by


Bhupendra Panchal, Asst. Professor, CSE
Thank You

87

You might also like