Course - DBMS: Course Instructor Dr.K. Subrahmanyam Department of CSE, KLEF
Course - DBMS: Course Instructor Dr.K. Subrahmanyam Department of CSE, KLEF
Course - DBMS: Course Instructor Dr.K. Subrahmanyam Department of CSE, KLEF
Course Instructor
Dr.K. SUBRAHMANYAM
Department of CSE, KLEF
1
Friday, August 28, 2020 CSE, KL UNIVERSITY
Announcement
1. First project presentation is scheduled on 28-1-2016, 2:00pm at PG
lab, 6th floor, PG Block. Each group should present their project
requirements and ER diagram during presentation. All students of the
class should be present during whole presentation. Students not
showing up for presentation without prior information will get negative
class attendance.
2. Yet 40% of the students have not registered their DBMS project topic
and group members. Last and final call for registration is on or before
21-1-2016. In case if the student does not register before 21-1-
2016, he or she should carry out the project individually and
randomly the topic will assigned by the faculty instructor.
3. Group members who have already registered their project topics should
discuss with faculty instructor on or before 23-1-2016 to identify
requirements of the topic. Because you should start preparing
requirements and ER- diagram for your project topic.
Note: It hinders your learning and creativity when others code/
design is copied. You should be ethical in preparing your own ER
diagrams, design plans and writing program code during your DBMS
Project design and development.
Course
CourseNam
Code
USN e
Name
Opting
Student Courses
has
Handles
Offers
has
Faculty
Department
ID Name
Name
Attribute
Entity
Relationship
Requirements Were
- Department has students and faculty
- Department will offer a set of courses during each semester
- Each student in the department during course registration will be
opting for courses offered by the department
- Faculty will be handling courses
Friday, August 28, 2020 CSE, KL UNIVERSITY 7
Design plan or ER diagram before actual development of the
application
Constraints
- Each semester student
should register for minimum
of 20 credits and maximum
of 30 credits
- Each faculty can handle
a maximum two courses
During each semester
Requirements Were
- Department has students and faculty
- Department will offer a set of courses during each semester
- Each student in the department during course registration will be
opting for courses offered by the department
- Faculty will be handling courses
Friday, August 28, 2020 CSE, KL UNIVERSITY 8
What is Entity, Entity Types, Entity sets ?
Entity Set
Student DOB
Attribute
…..
Composite Attribute
Multivalued Attribute
Derived Attribute
USN
ER Diagram Notation for Entity: Rectangle
B CSE 21K
A EC 30K
B EC 27K
C CSE 22K
B CSE 21K
A EC 30K
B EC 27K
C CSE 22K
A EC 30K
B EC 27K
C CSE 22K
A EC 30K
Note:
B EC 27K Before determining the Key
C CSE 22K attribute, look at the values
present but it will
not be consistent
Friday, August 28, 2020 CSE, KL UNIVERSITY 23
Activity To DO
Attribute Represent Employee entity
using ER diagram notation
….. Which has following attributes
- Employee ID (Key)
Composite Attribute - Name
- Address(House No., Street
name, Area name, Place)
- Mobile Number (Can have
Multivalued Attribute
more than one )
- DOB
- Age
Derived Attribute
Entity
Unit 2:
- Relationship Types, Relationship sets, Roles and
Structural Constraints
- Weak Entity Types
Enrolls_for
Student Course
Dr. Guruprasad
CSE
Dr. Umadevi
Dr. Indiramma
ISE
Dr. Ashok
Faculty
Department
Entity Works_for
Entity
relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 27
Relationship Type
A Relationship Type defines a relationship set among entities of certain
entity types.
Example, an Faculty works_for a department, a student enrolls_for in a
course. Here, works_for and enrolls are called relationships.
Avinash
DBMS
Balaji
Chandan
Java
Dinesh
Student
Course
Entity enrolls_for
Entity
relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 28
Relationship Set
An Relationship Set is a collection of relationships all belonging to one
relationship type.
Here relationship set,
has 4 relationships
Avinash
DBMS
Balaji
Chandan
Java
Dinesh
Student
Course
Entity enrolls_for
Entity
relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 29
Relationship
The association among entities is called a
relationship. or A Relationship is one
instance in a Relationship Set.
Avinash
DBMS
Balaji
Chandan
Java
Dinesh
Student
Course
Entity enrolls_for
Entity
relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 30
Relationship Degree
Dr. Guruprasad
CSE
Dr. Umadevi
Dr. Indiramma
ISE
Dr. Ashok
Faculty
Department
Entity Works_for
Entity
relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 31
Relationship Degree
Ternary Relationship: Degree three, three
entities are participating
Micro Systems
Pvt. Ltd
Keyboard
Project
Part supplies
Entity
Entity relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 32
Relationship Degree
Ternary Relationship: Degree three, three
entities are participating
Micro Systems
Pvt. Ltd
Keyboard
Project
Part supplies
Entity
Entity relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 33
Recursive Relationship
In some cases the same entity type participates in
more than once in a relationship type in different
roles.
Faculty
Entity supervision
relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 34
Recursive Relationship
In some cases the same entity type participates in
more than once in a relationship type in different
roles.
Subordinate
Dr. Guruprasad
Supervisor
Dr. Umadevi
Dr. Indiramma
Supervisor
Principal
Faculty
Entity supervision
relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 35
Relationship Constraints or Structural Constraints
Two Types
1.Cardinality Ratios
a. One to one (1:1)
b. One to Many (1:M)
c. Many to Many (N:M)
2.Participation Constraints
a. Total
b. Partial
Dr. Guruprasad
CSE
Faculty Department
Heads
Entity Entity
relationship
Friday, August 28, 2020 CSE, KL UNIVERSITY 38
Cardinality Ratios
Cardinality is a constraint on a relationship specifying
the number of entity instances that a specific entity may
be related to via the relationship.
One to One:
One instance of one entity type can participate in one
instance of other entity type.
1 Heads 1
Faculty Department
1 R M
Entity A Entity B
Departme 1 Has M
Student
nt
N R M
Entity A Entity B
Partial Name
Key -----
Faculty
Dependents_of Dependent
Owner Weak
Entity Identifying Entity
Relationship
Dr. Guruprasad
Ram
Ravi
Dr. Gowrishankar
Ram
Owner
Entity Dependents_of Dependent (Children)
relationship Entity
Friday, August 28, 2020 CSE, KL UNIVERSITY 50
ER Diagram Symbols
Attribute
…..
Composite Attribute
Multivalued Attribute
Derived Attribute
Relationship
Identifying Relationship
Unit 2:
ER diagram design for a given requirements
Requirement Analysis
- What is going to be stored ?
- How is it going to be used ?
- What are we going to do with the data ?
- Who should access the data ?
Conceptual Design
- A high-level description of the database.
- Sufficiently precise that technical people can understand it.
- But, not so precise that non-technical can not participate.
…..
Composite Attribute
Multivalued Attribute
Derived Attribute
Relationship
Identifying Relationship
M 1
M
N
N N
1 M
M M 1
N
N
M
Unit 2:
- Converting ER Diagrams to Tables
or Database design using ER-to-Relational Mapping
Student
Student Table
USN Name DOB
Primary
1BM14CS001 Aditya 1-1-1997
Key
1BM14CS002 Bharath 31-12-1996
Mobile
Student
Mobile
Student
Which of the following representation of the table for Multivalued
Attribute is best ?
USN Name DOB Mobile 1 Mobile 2
1BM14CS001 Aditya 1-1-1997 8766655433
If you have a multi-valued attribute, take the attribute and turn it into a
new entity or table of its own. Then make a 1:N relationship between
the new entity and the existing one. In simple words,
1.Create a table for the attribute.
2.Add the primary (id) column of the parent entity as a foreign key
within the new table
Friday, August 28, 2020 CSE, KL UNIVERSITY 78
Converting ER diagram to Tables
Street Area
Composite Attribute Name Name
Address Place
USN DOB
Name
Student Mobile
Address Place
USN DOB
Name
Student Mobile
Student Table
USN Name DOB Street Area Place
1BM14CS001 Aditya 1-1-1997 RK Road Nagar Mandya
USN Mobile
Mobile Table 1BM14CS001 8766655433
1BM14CS002 9762255433
1BM14CS002 7066722433
Friday, August 28, 2020 CSE, KL UNIVERSITY 80
Converting ER diagram to Tables
Street Area
Derived Attribute Name Name
Address Place
USN DOB
Name
Student Table
USN Name DOB Street Area Place
1BM14CS001 Aditya 1-1-1997 RK Road Nagar Mandya
USN Mobile
Mobile Table 1BM14CS001 8766655433
1BM14CS002 9762255433
1BM14CS002 7066722433
Friday, August 28, 2020 CSE, KL UNIVERSITY 81
Converting ER diagram to Tables
Relationship: One-to-One
D-ID
F-ID 1
1
F-Name
D-Name
F-Name
D-Name
Approach 3: Cross-reference or relationship relation approach
USN
D-ID
Departme 1 Has M
Student
nt
D-Name
S-Name
Relationship: Many-to-Many
USN C-ID
Enrolls_for
Student Course
S-Name C-Name
Friday, August 28, 2020 CSE, KL UNIVERSITY 90
Converting ER diagram to Tables
Relationship: Many-to-Many
USN C-ID
Enrolls_for
Student Course
S-Name C-Name
F-ID F-Name
Faculty
Dependents_of Dependent
Owner
Identifying Weak
Entity
Relationship Entity
F-ID F-Name
Faculty
Dependents_of Dependent
Owner
Identifying Weak
Entity
Relationship Entity
1 M
M M 1
N
N
M
Song Table
Song-ID Author Title Album-ID
Performing Table
Muscian-ID Song-ID
Plays Table
Muscian-ID Instr-ID
Instrument Table
Instr-ID Name M-Key
Song Table
Song-ID Author Title Album-ID
Performing Table
Muscian-ID Song-ID
Plays Table
Muscian-ID Instr-ID
Instrument Table
Instr-ID Name M-Key
N R 1
Entity A Entity B