SlideShare une entreprise Scribd logo
1  sur  46
DATABASE DESIGN: DATA MODELING
AND NORMALIZATION
Dr. R. Khanchana
Assistant Professor
Department of Computer Science
Sri Ramakrishna College of Arts and Science for Women
Data Modeling
Data Modeling:
• Data modeling - A tool used to represent various components and their
relationships.
• Popular modeling tool is Entity Relational Model(E-R Model)
• E-R Model provides
 An excellent communication tools
 A simple graphical representation of data.
• E-R Model uses E-R Diagram(ERD) for graphical representation of the
database components.
• An entity is represented by a rectangle it uses upper case letters and it should
be singular noun Eg. EMPLOYEE,DEPARTMENT etc
• Entity Representation in an E-R Diagram
EMPLOYEE
Representation of Relationship
• The line represents the relationship between the two entities it uses
lowercase letters and it should be active verb
• Passive verb can be used but active verb is preferable.
• Representation of relationship in an E-R diagram
1:1
• The types of relationships (1:1,1:M,M:N) between entities are called
connectivity or multiplicity.
M: N
1: Mmanages
employs
contains
Entity, Relationship, Connectivity
• The types of relationships (1:1,1:M,M:N) between entities are
called Connectivity or Multiplicity
• The connectivity is shown with vertical or angled lines next to
each entity
Cardinality
• The Relationship between two entities can be
given suing the lowercase and uppercase
limits
• Example - (n,m)
• n – lower limit
• m – upper limit
DEPARTMENTEMPLOYEE
FACULTYDIVISION
ITEMINVOICE
Supervises
Employees
Contains
(1, 1)
(1, 1)
(1, N)
(1, 1)
(1, N) (1, N)
Data Model Basic Building Blocks
Cardinality Types
• It has 2 types
– Mandatory
Relationship
– Optional
Relationship
• Oracle set rules for
the minimum and
maximum values for
cardinality. These
types of decision are
known as business
rules.
Minimum Cardinality
Cardinality Representation
Optional Relationship
• Optional relationships are shown with a small circle next to the
optional entity.
• The optional relational relationship can occur in 1:1,1:M or
M:N relationships and it can occur on one or both sides of the
relationship.
• In relational databases many-to-many (M:N) relationships are
allowed but they are not easy to implement.
Composite Entity & Relational Schema
• The decomposition from M:N to1:M involves
a third entity and it is known as Composition
entity or Associative entity
Weak Entity
• There are entities that cannot exist by
themselves.
Other Elements
• Some of the other elements considered in the database design are
 Simple Attributes:
Attributes that cannot be subdivided
Eg. city, gender
 Composite Attributes:
Attributes that can be subdivided
Eg. Full name(Last name, First name, Middle Initial)
 Single valued Attributes:
Attributes with a single value
Eg. Employee Id, Student Id
 Multivalued Attributes:
Attributes with multiple values
Eg. Course details
Quiz
• https://quizizz.com/admin/quiz/5f06a5c1b83
319001b5de46f
Dependency
• A dependency is a constraint that applies to or defines the relationship
between attributes.
• Primary key which uniquely identifies an entity
• The column that do not make up the primary key for the table such columns
are called the nonkey column
• The non key columns are functionally dependent on the primary key columns
• There are three types of dependency in tables
– Total or full dependency: A nonkey column dependent on
all primary key column
– Partial dependency : A nonkey column is dependent on part
of the primary key
– Transitive dependency :A nonkey column is dependent on
another nonkey column.
Dependency Types
Database Design
Normal forms
• Redundancy - Data Repetition
• Anomaly (Data Inconsistency)
• – if a change in piece of data, the change has
to made in many places
Anomalies
Deletion Anomaly
Insertion Anomaly
Update Anomaly
Deletion Anomaly
• Which results when the deletion of information about one
entity leads to the deletion of another entity.
• If someone decides to delete Botany department , he may
end up deleting all student’s data who had the department of
Botany.
Insertion Anomaly
When the information about an entity cannot be inserted
unless the information about another entity is known
and it is said to be Insertion Anomaly
Jerry is a new Student with department id 6. There is no Department with this Dept_ID 6. Hence , the
anomaly. The usual behaviour should be a new department id with 6 and only then Student could have
it.
Update Anomaly
• An update anomaly occurs when data is only
partially updated in a database.
• English department has now Dept_ID 8 , but unfortunately it
was not updated in Student table.
Quiz
• https://quizizz.com/admin/quiz/5f07f8f48538
03001bc75b8c/anamolies-and-depedency
Feedback
• https://docs.google.com/forms/d/1rk0rjFo78J
adkbHRT-SshgN0XavjgYvK5SnCOBqQ8V8/edit
Normalization
• Normalization is the process of organizing the
data in the database.
• Normalization is used to minimize the
redundancy from a relation or set of relations.
• Normalization divides the larger table into the
smaller table and links them using relationship.
• The normal form is used to reduce redundancy
from the database table.
Review
• Data Modeling
– Entity
– Attribute
– Connectivity
– Cardinality -Notation
• Dependency
• Database design
Types of Normal Forms
• Higher Normal Form - Lower the redundancy
i) First Normal Form(1NF)
ii) Second Normal Form(2NF)
iii) Third Normal Form(3NF)
First Normal Form (1NF)
The table said to be first normal form (or) labeled 1NF if the following conditions
exists:
• The primary key is defined
• Also includes composite key if a single column cannot be used as a primary key.
• First normal form disallows the multi-valued attribute/ composite attribute, and
their combinations.
Example: Relation EMPLOYEE is not in 1NF because of multi-valued attribute
EMP_PHONE
Second Normal Form (2NF)
• All 1NF requirements are fulfilled
•No partial dependency
•Suppose the table is in 1NF and does not have composite key and it is said to
be 2NF.
Example: A school can store the data of teachers and the subjects they teach. In a
school, a teacher can teach more than one subject.
Second Normal Form (2NF)
Third Normal Form (3NF)
• Table is said to be third normal form (or) 3NF
if the following requirements are satisfied.
– All 2NF requirements are fulfilled.
– No transitive dependency- non key column is
dependent on another non key column.
Third Normal Form (3NF)
• Super key in the table above:
– {EMP_ID}, {EMP_ID, EMP_NAME}, {EMP_ID, EMP_NAME, EMP_ZIP}....so on
• Candidate key: {EMP_ID}
• Non-prime attributes: all attributes except EMP_ID are non-prime.
– EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP dependent on
EMP_ID.
– The non-prime attributes (EMP_STATE, EMP_CITY) transitively dependent on
super key(EMP_ID). It violates the rule of third normal form.
– Hence need to move the EMP_CITY and EMP_STATE to the new
<EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.
Third Normal Form (3NF)
Other Normal forms
• BCNF - BoyceCodd Normal Form(BCNF)
• 4NF –Fourth Normal Form
• 5NF - Fifth Normal Form
• DKNF –Domain Key Normal Form
Dependency Diagram
• Total dependencies arrows are drawn above the boxes.
• Partial & transitive dependencies arrows are drawn below the boxes.
• i)Conversion from 1NF to 2NF
• ii)Conversion from 2NF to 3NF
Conversion from 1NF to 2NF
• The composite primary key is in the table remove partial dependency.
• 1st each primary key component on a separate line , they will become
primary key in two new tables.
• Composite key on the third line it will be the composite key on the third
table.
1NF to 2NF
Decomposition
Table in 2NF
Conversion from 2NF to 3NF
• Invoice table still has transitive dependency but no partial dependency.
• More columns of transitive dependency to a new table.
• Keep the primary key of new table as a foreign key at existing table.
2NF to 3NF
Decomposition
Table in 3NF
Denormaization
• Normalization process - splits tables into smaller
tables
• Smaller tables are joined together by common
columns to retrieve information from different
tables.
• Denomalization process – reverse process
• It reduces normal form and increases
data redundancy
• Duplicate data are stored more storage space is
required
Quiz
• https://quizizz.com/admin/quiz/5f071541f209
7b001e69591a
Feedback
• https://docs.google.com/forms/d/10qpFTAot
HMsCXuhBpCrNKnU3PIso8NtwjktMSc4sru8/e
dit
Assignment –Case Study
• Assume, a video library maintains a database of
movies rented out. Without any normalization, all
information is stored in one table as shown below.
Assignment Results
1NF
Assignment Results
2NF
Assignment Results
3NF

Contenu connexe

Tendances (20)

Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
ER MODEL
ER MODELER MODEL
ER MODEL
 
SQL Constraints
SQL ConstraintsSQL Constraints
SQL Constraints
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Types Of Keys in DBMS
Types Of Keys in DBMSTypes Of Keys in DBMS
Types Of Keys in DBMS
 
joins in database
 joins in database joins in database
joins in database
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Key and its different types
Key and its different typesKey and its different types
Key and its different types
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Joins And Its Types
Joins And Its TypesJoins And Its Types
Joins And Its Types
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
PL/SQL
PL/SQLPL/SQL
PL/SQL
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Chapter 6 relational data model and relational
Chapter  6  relational data model and relationalChapter  6  relational data model and relational
Chapter 6 relational data model and relational
 

Similaire à Data Modeling

Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design Jayant Dalvi
 
Normalization and three normal forms.pptx
Normalization and three normal forms.pptxNormalization and three normal forms.pptx
Normalization and three normal forms.pptxZoha681526
 
Normmmalizzarion.ppt
Normmmalizzarion.pptNormmmalizzarion.ppt
Normmmalizzarion.pptDeependra35
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFBiplap Bhattarai
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDr. GOPINATH D
 
normalization of database management ppt
normalization of database management pptnormalization of database management ppt
normalization of database management pptRabiaKabir
 
Chapter Four Logical Database Design (Normalization).pptx
Chapter Four Logical Database Design (Normalization).pptxChapter Four Logical Database Design (Normalization).pptx
Chapter Four Logical Database Design (Normalization).pptxhaymanot taddesse
 
Feb 2nd Makeup Class
Feb 2nd Makeup ClassFeb 2nd Makeup Class
Feb 2nd Makeup ClassGeorge Saban
 
data Normalization.pdf
data Normalization.pdfdata Normalization.pdf
data Normalization.pdfBijayNag1
 
1683368767418684.pdf
1683368767418684.pdf1683368767418684.pdf
1683368767418684.pdfJanoakre
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelKunal Anand
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSRubal Sagwal
 

Similaire à Data Modeling (20)

Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design
 
DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 
Normalization and three normal forms.pptx
Normalization and three normal forms.pptxNormalization and three normal forms.pptx
Normalization and three normal forms.pptx
 
Normalization
NormalizationNormalization
Normalization
 
Normmmalizzarion.ppt
Normmmalizzarion.pptNormmmalizzarion.ppt
Normmmalizzarion.ppt
 
Assignment#11
Assignment#11Assignment#11
Assignment#11
 
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NFNormalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
 
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEMDATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
 
normalization of database management ppt
normalization of database management pptnormalization of database management ppt
normalization of database management ppt
 
Chapter Four Logical Database Design (Normalization).pptx
Chapter Four Logical Database Design (Normalization).pptxChapter Four Logical Database Design (Normalization).pptx
Chapter Four Logical Database Design (Normalization).pptx
 
Normalisation
NormalisationNormalisation
Normalisation
 
Feb 2nd Makeup Class
Feb 2nd Makeup ClassFeb 2nd Makeup Class
Feb 2nd Makeup Class
 
data Normalization.pdf
data Normalization.pdfdata Normalization.pdf
data Normalization.pdf
 
UNIT II DBMS.pptx
UNIT II DBMS.pptxUNIT II DBMS.pptx
UNIT II DBMS.pptx
 
Research gadot
Research gadotResearch gadot
Research gadot
 
Year 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st TermYear 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st Term
 
1683368767418684.pdf
1683368767418684.pdf1683368767418684.pdf
1683368767418684.pdf
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
 
ER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMSER Modeling and Introduction to RDBMS
ER Modeling and Introduction to RDBMS
 
ERD.ppt
ERD.pptERD.ppt
ERD.ppt
 

Plus de DrkhanchanaR

Unit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptxUnit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptxDrkhanchanaR
 
Unit 5 composite datatypes
Unit 5  composite datatypesUnit 5  composite datatypes
Unit 5 composite datatypesDrkhanchanaR
 
Unit 5 internal sorting &amp; files
Unit 5  internal sorting &amp; filesUnit 5  internal sorting &amp; files
Unit 5 internal sorting &amp; filesDrkhanchanaR
 
Unit 4 external sorting
Unit 4   external sortingUnit 4   external sorting
Unit 4 external sortingDrkhanchanaR
 
Unit 3 graph chapter6
Unit 3  graph chapter6Unit 3  graph chapter6
Unit 3 graph chapter6DrkhanchanaR
 
Unit 3 Tree chapter 5
Unit 3  Tree chapter 5Unit 3  Tree chapter 5
Unit 3 Tree chapter 5DrkhanchanaR
 
Unit 2 linked list
Unit 2   linked listUnit 2   linked list
Unit 2 linked listDrkhanchanaR
 
Unit I-Data structures stack & Queue
Unit I-Data structures stack & QueueUnit I-Data structures stack & Queue
Unit I-Data structures stack & QueueDrkhanchanaR
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expressionDrkhanchanaR
 
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...DrkhanchanaR
 

Plus de DrkhanchanaR (10)

Unit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptxUnit I-Data Structures_Intoduction.pptx
Unit I-Data Structures_Intoduction.pptx
 
Unit 5 composite datatypes
Unit 5  composite datatypesUnit 5  composite datatypes
Unit 5 composite datatypes
 
Unit 5 internal sorting &amp; files
Unit 5  internal sorting &amp; filesUnit 5  internal sorting &amp; files
Unit 5 internal sorting &amp; files
 
Unit 4 external sorting
Unit 4   external sortingUnit 4   external sorting
Unit 4 external sorting
 
Unit 3 graph chapter6
Unit 3  graph chapter6Unit 3  graph chapter6
Unit 3 graph chapter6
 
Unit 3 Tree chapter 5
Unit 3  Tree chapter 5Unit 3  Tree chapter 5
Unit 3 Tree chapter 5
 
Unit 2 linked list
Unit 2   linked listUnit 2   linked list
Unit 2 linked list
 
Unit I-Data structures stack & Queue
Unit I-Data structures stack & QueueUnit I-Data structures stack & Queue
Unit I-Data structures stack & Queue
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expression
 
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
 

Dernier

Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 

Dernier (20)

Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Data Modeling

  • 1. DATABASE DESIGN: DATA MODELING AND NORMALIZATION Dr. R. Khanchana Assistant Professor Department of Computer Science Sri Ramakrishna College of Arts and Science for Women
  • 2. Data Modeling Data Modeling: • Data modeling - A tool used to represent various components and their relationships. • Popular modeling tool is Entity Relational Model(E-R Model) • E-R Model provides  An excellent communication tools  A simple graphical representation of data. • E-R Model uses E-R Diagram(ERD) for graphical representation of the database components. • An entity is represented by a rectangle it uses upper case letters and it should be singular noun Eg. EMPLOYEE,DEPARTMENT etc • Entity Representation in an E-R Diagram EMPLOYEE
  • 3. Representation of Relationship • The line represents the relationship between the two entities it uses lowercase letters and it should be active verb • Passive verb can be used but active verb is preferable. • Representation of relationship in an E-R diagram 1:1 • The types of relationships (1:1,1:M,M:N) between entities are called connectivity or multiplicity. M: N 1: Mmanages employs contains
  • 4. Entity, Relationship, Connectivity • The types of relationships (1:1,1:M,M:N) between entities are called Connectivity or Multiplicity • The connectivity is shown with vertical or angled lines next to each entity
  • 5. Cardinality • The Relationship between two entities can be given suing the lowercase and uppercase limits • Example - (n,m) • n – lower limit • m – upper limit DEPARTMENTEMPLOYEE FACULTYDIVISION ITEMINVOICE Supervises Employees Contains (1, 1) (1, 1) (1, N) (1, 1) (1, N) (1, N)
  • 6. Data Model Basic Building Blocks
  • 7. Cardinality Types • It has 2 types – Mandatory Relationship – Optional Relationship • Oracle set rules for the minimum and maximum values for cardinality. These types of decision are known as business rules.
  • 10. Optional Relationship • Optional relationships are shown with a small circle next to the optional entity. • The optional relational relationship can occur in 1:1,1:M or M:N relationships and it can occur on one or both sides of the relationship. • In relational databases many-to-many (M:N) relationships are allowed but they are not easy to implement.
  • 11. Composite Entity & Relational Schema • The decomposition from M:N to1:M involves a third entity and it is known as Composition entity or Associative entity
  • 12. Weak Entity • There are entities that cannot exist by themselves.
  • 13. Other Elements • Some of the other elements considered in the database design are  Simple Attributes: Attributes that cannot be subdivided Eg. city, gender  Composite Attributes: Attributes that can be subdivided Eg. Full name(Last name, First name, Middle Initial)  Single valued Attributes: Attributes with a single value Eg. Employee Id, Student Id  Multivalued Attributes: Attributes with multiple values Eg. Course details
  • 15. Dependency • A dependency is a constraint that applies to or defines the relationship between attributes. • Primary key which uniquely identifies an entity • The column that do not make up the primary key for the table such columns are called the nonkey column • The non key columns are functionally dependent on the primary key columns • There are three types of dependency in tables – Total or full dependency: A nonkey column dependent on all primary key column – Partial dependency : A nonkey column is dependent on part of the primary key – Transitive dependency :A nonkey column is dependent on another nonkey column.
  • 18. Normal forms • Redundancy - Data Repetition • Anomaly (Data Inconsistency) • – if a change in piece of data, the change has to made in many places
  • 20. Deletion Anomaly • Which results when the deletion of information about one entity leads to the deletion of another entity. • If someone decides to delete Botany department , he may end up deleting all student’s data who had the department of Botany.
  • 21. Insertion Anomaly When the information about an entity cannot be inserted unless the information about another entity is known and it is said to be Insertion Anomaly Jerry is a new Student with department id 6. There is no Department with this Dept_ID 6. Hence , the anomaly. The usual behaviour should be a new department id with 6 and only then Student could have it.
  • 22. Update Anomaly • An update anomaly occurs when data is only partially updated in a database. • English department has now Dept_ID 8 , but unfortunately it was not updated in Student table.
  • 25. Normalization • Normalization is the process of organizing the data in the database. • Normalization is used to minimize the redundancy from a relation or set of relations. • Normalization divides the larger table into the smaller table and links them using relationship. • The normal form is used to reduce redundancy from the database table.
  • 26. Review • Data Modeling – Entity – Attribute – Connectivity – Cardinality -Notation • Dependency • Database design
  • 27. Types of Normal Forms • Higher Normal Form - Lower the redundancy i) First Normal Form(1NF) ii) Second Normal Form(2NF) iii) Third Normal Form(3NF)
  • 28. First Normal Form (1NF) The table said to be first normal form (or) labeled 1NF if the following conditions exists: • The primary key is defined • Also includes composite key if a single column cannot be used as a primary key. • First normal form disallows the multi-valued attribute/ composite attribute, and their combinations. Example: Relation EMPLOYEE is not in 1NF because of multi-valued attribute EMP_PHONE
  • 29. Second Normal Form (2NF) • All 1NF requirements are fulfilled •No partial dependency •Suppose the table is in 1NF and does not have composite key and it is said to be 2NF. Example: A school can store the data of teachers and the subjects they teach. In a school, a teacher can teach more than one subject.
  • 31. Third Normal Form (3NF) • Table is said to be third normal form (or) 3NF if the following requirements are satisfied. – All 2NF requirements are fulfilled. – No transitive dependency- non key column is dependent on another non key column.
  • 32. Third Normal Form (3NF) • Super key in the table above: – {EMP_ID}, {EMP_ID, EMP_NAME}, {EMP_ID, EMP_NAME, EMP_ZIP}....so on • Candidate key: {EMP_ID} • Non-prime attributes: all attributes except EMP_ID are non-prime. – EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP dependent on EMP_ID. – The non-prime attributes (EMP_STATE, EMP_CITY) transitively dependent on super key(EMP_ID). It violates the rule of third normal form. – Hence need to move the EMP_CITY and EMP_STATE to the new <EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.
  • 34. Other Normal forms • BCNF - BoyceCodd Normal Form(BCNF) • 4NF –Fourth Normal Form • 5NF - Fifth Normal Form • DKNF –Domain Key Normal Form
  • 35. Dependency Diagram • Total dependencies arrows are drawn above the boxes. • Partial & transitive dependencies arrows are drawn below the boxes. • i)Conversion from 1NF to 2NF • ii)Conversion from 2NF to 3NF
  • 36. Conversion from 1NF to 2NF • The composite primary key is in the table remove partial dependency. • 1st each primary key component on a separate line , they will become primary key in two new tables. • Composite key on the third line it will be the composite key on the third table. 1NF to 2NF Decomposition
  • 38. Conversion from 2NF to 3NF • Invoice table still has transitive dependency but no partial dependency. • More columns of transitive dependency to a new table. • Keep the primary key of new table as a foreign key at existing table. 2NF to 3NF Decomposition
  • 40. Denormaization • Normalization process - splits tables into smaller tables • Smaller tables are joined together by common columns to retrieve information from different tables. • Denomalization process – reverse process • It reduces normal form and increases data redundancy • Duplicate data are stored more storage space is required
  • 43. Assignment –Case Study • Assume, a video library maintains a database of movies rented out. Without any normalization, all information is stored in one table as shown below.