SlideShare a Scribd company logo
1 of 50
DATABASE MANAGAMENT SYSTEM
Dr. Gopinath D
Assistant Professor
Department of Computer Science
Kristu Jayanti College
Bengaluru
NORMALIZATION AND RELATIONAL DATA MODEL
Functional dependencies and normalization for relational
databases
No. DBMS RDBMS
1) DBMS applications store data as file. RDBMS applications store data in a tabular form.
2) In DBMS, data is generally stored in either a
hierarchical form or a navigational form.
In RDBMS, the tables have an identifier called
primary key and the data values are stored in the form
of tables.
3) Normalization is not present in DBMS. Normalization is present in RDBMS.
4) DBMS does not apply any security with
regards to data manipulation.
RDBMS defines the integrity constraint for the
purpose of ACID (Atomocity, Consistency, Isolation
and Durability) property.
5) DBMS uses file system to store data, so there
will be no relation between the tables.
in RDBMS, data values are stored in the form of
tables, so a relationship between these data values
will be stored in the form of a table as well.
6) DBMS has to provide some uniform methods to
access the stored information.
RDBMS system supports a tabular structure of the
data and a relationship between them to access the
stored information.
7) DBMS does not support distributed
database.
RDBMS supports distributed database.
8) DBMS is meant to be for small organization
and deal with small data. it supports single
user.
RDBMS is designed to handle large amount of
data. it supports multiple users.
9) Examples of DBMS are file systems, xml etc. Example of RDBMS are mysql, postgre, sql
server, oracle etc.
Database design
• Database design
• Bottom up - breaking down a big problem into smaller
• Top down - solving the smaller problems at the fundamental level and then
integrating them into a whole and complete solution.
Grouping of attributes to form
relational schema
Design guideline for Evaluating relation DB
schemas
Chp
5
4
• Schema – design a structure for database
• Two levels of relation schemas
• The logical or conceptual view
• How users interpret the relation schemas and
the meaning of their attributes.
• Implementation or storage view or physical
view
• How the tuples in the base relation are stored
and updated.
Pitfalls in relational database
design
Chp
5
5
1. Poor semantics of the attributes
2. Redundant values in tuples
3. Null values in tuples
4. Possibility of generating spurious
tuples.
1.Semantics of the Relation Attributes
Semantic data is data that has been structured to add meaning to the data.)
• GUIDELINE 1: Informally, each tuple in a relation should
represent one entity or relationship instance. (Applies to
individual relations and their attributes).
• Attributes of different entities (EMPLOYEEs,
DEPARTMENTs, PROJECTs) should not be mixed in
the same relation
• Only foreign keys should be used to refer to other entities
• Entity and relationship attributes should be kept apart as
much as possible.
• Bottom Line: Design a schema that can be explained easily
relation by relation. The semantics of attributes should be easy
to interpret. 7
A Simplified COMPANY relational database schema
Chp
5
7
2.Redundant Information in Tuples and Update Anomalies(inconsistency in
the pattern from the normal form)
Chp
5
8
• Goal of schema design is to minimize the storage space used by the
base relations.
• Information is stored redundantly
• Wastes storage
• Causes problems with update anomalies
• Insertion anomalies
• Deletion anomalies
• Modification anomalies
Two relation schemas suffering from update anomalies
Chp
5
1
0
ENAM
E
SSN BDATE ADDRE
SS
DNUMB
ER
DNAM
E
DMGRS
SN
SSN PNUMB
ER
HOUR
S
ENAM
E
PNAM
E
PLOCA
TI
O
N
EMP_DEPT
EMP_PROJ
Chp
5
1
1
EXAMPLE OF AN INSERT ANOMALY
Chp
5
1
2
• Consider the relation:
• EMP_PROJ(Emp#, Proj#, Ename, Pname,
No_hours)
• Insert Anomaly:
• Cannot insert a project unless an employee is
assigned to it.
• Conversely
• Cannot insert an employee unless an he/she is
assigned to a project.
EXAMPLE OF AN DELETE ANOMALY
Chp
5
1
3
• Consider the relation:
• EMP_PROJ(Emp#, Proj#, Ename, Pname, No_hours)
• Delete Anomaly:
• When a project is deleted, it will result in deleting all the
employees who work on that project.
• Alternately, if an employee is the sole employee on a
project, deleting that employee would result in
deleting the corresponding project.
EXAMPLE OF AN UPDATE ANOMALY
Chp
5
1
4
• Consider the relation:
• EMP_PROJ(Emp#, Proj#, Ename, Pname,
No_hours)
• Update Anomaly:
• Changing the name of project number P1
from “Billing” to “Customer-Accounting”
may cause this update to be made for all 100
employees working on project P1.
Guideline to Redundant InformationinTuples and
UpdateAnomalies
Chp
5
1
5
• GUIDELINE 2:
• Design a schema that does not suffer from the insertion,
deletion and update anomalies.
• If there are any anomalies present, then note
them so that applications can be made to take
them into account.
• In general, it is advisable to use anomaly free base
relations and to specify views that include the joins for
placing together the attributes frequently referenced in
important queries.
Problems with Nulls
Chp
5
1
6
• If many attributes are grouped together as a
fat relation, it gives rise to many nulls in the
tuples.
• Waste storage
• Problems in understanding the meaning of
the attributes
• Difficult while using Nulls in aggregate
operators like count or sum
3. Null Values in Tuples
Chp
5
1
7
• Interpretations of nulls:
a. The attribute does not apply to this tuple.
b. The attribute value for this tuple is not known.
c. The value is known but has not been recorded yet.
• GUIDELINE 3:
• void placing attributes in a base relation whose values may
frequently be null.
• Relations should be designed such that their tuples will
have as few NULL values as possible
• Attributes that are NULL frequently could be placed in
separate relations (with the primary key)
• Example:-
• if only 10% of employees have individual offices, it is
better not to include office_number as an attribute in the
employee relation.
• Better create a new relation emp_offices(essn,
office_number)
Chp
5
1
8
Example of Fake Tuples
Chp
5
1
9
Generation of spurious tuples
Chp
5
2
0
• The two relations EMP_PROJ1 and EMP_LOCS as the
base relations of EMP_PROJ, is not a good schema
design.
• Problem is if a Natural Join is performed on the above two
relations it produces more tuples than original set of tuples in
EMP_PROJ.
• These additional tuples that were not in EMP_PROJ are called
spurious tuples because they represent spurious or wrong
information that is not valid.
• This is because the PLOCATION attribute which is used for
joining is neither a primary key, nor a foreign key in either
EMP_LOCS AND EMP_PROJ1.
Example of Spurious Tuples
contd
Chp
5
2
1
4. Spurious Tuples
Chp
5
2
2
• Bad designs for a relational database may result in
erroneous results for certain JOIN operations
• The "lossless join" property is used to guarantee
meaningful results for join operations
• GUIDELINE 4:
• Design relation schemas so that they can be joined
with equality conditions on attributes that are either
primary keys or foreign keys in a way that guarantees
that no spurious tuples are generated.
• Non-additive or losslessness of the corresponding
join
• Preservation of the functionaldependencies.
Summary and Discussion of Design
Guidelines
2
3
Problems pointed out:
• Anomalies cause redundant work to be done during
• Insertion
• Modification
• Deletion
• Waste of storage space due to nulls and difficulty of
performing aggregation operations and joins due to null
values
• Generation of invalid and spurious data during joins on
improperly related base relations.
Functional dependencies - normalization
• A functional dependency is a constraint between two sets of
attributes from the database.
• Normalization is the process of organizing the data in the
database.
Normalization:
• Normalization is used to minimize the redundancy from a relation
or set of relations. It is also used to eliminate the undesirable
characteristics like Insertion, Update and Deletion Anomalies.
• 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
TYPES:
Boyce-codd NF
NF
• 1NF – Not allowed multivalued attribute
• 2NF – No partial dependency
• 3nf – no transitive dependency
• BCNF – Remove non trivial functional dependency
• Multivalued – more than one value for single attribute value
• Dependency – one attribute depend on other
• Partial – one attribute partially depend on other attribute
• Transitive – x->y and y->z = x->z [ no intermediate]
• Trivial -
1NF
• A relation is in first normal form if every attribute in that relation
is single valued attribute.
• Not allowed multi value attributed
• Example 1:
• Example 2:
• I NF
ID Name Courses
1 A C1,C2
2 E C3
3 M C2,C3
ID Name Courses
1 A C1
1 A C2
2 E C3
3 M C2
3 M C3
2nf
• No partial dependency
• A relation must be in first normal form and relation must not contain
any partial dependency.
• Partial Dependency – If the proper subset of candidate key
determines non-prime attribute, it is called partial dependency.
2NF
Stud_no Course_no Courses_Fee
1 C1 1000
2 C2 1500
1 C4 2000
4 C3 1000
4 C1 1000
2 C5 2000
 COURSE_FEE cannot alone decide the value of
COURSE_NO or STUD_NO;
 COURSE_FEE together with STUD_NO cannot
decide the value of COURSE_NO;
 COURSE_FEE together with COURSE_NO cannot
decide the value of STUD_NO;
COURSE_FEE would be a non-prime attribute, as it
does not belong to the one only candidate key
{STUD_NO, COURSE_NO} ;
To convert the above relation to 2NF,
we need to split the table into two tables such as :
Table 1: STUD_NO, COURSE_NO
Table 2: COURSE_NO, COURSE_FEE
Stud_no Course_no
1 C1
2 C2
1 C4
4 C3
4 C1
2 C5
Course_no Courses_Fee
C1 1000
C2 1500
C4 2000
C3 1000
C1 1000
C5 2000
 NOTE: 2NF tries to reduce the redundant data getting stored in memory. For instance, if there are 100
students taking C1 course, we don’t need to store its Fee as 1000 for all the 100 records, instead once we
can store it in the second table as the course fee for C1 is 1000.
3nf
• no transitive dependency
• A relation will be in 3NF if it is in 2NF and not contain any transitive
partial dependency.
• 3NF is used to reduce the data duplication. It is also used to achieve
the data integrity.
• If there is no transitive dependency for non-prime attributes, then
the relation must be in third normal form.
• A relation is in third normal form if it holds atleast one of the
following conditions for every non-trivial function dependency X → Y.
• X is a super key.
• Y is a prime attribute, i.e., each element of Y is part of some candidate key.
3nf
• Transitive dependency – If A->B and B->C are two FDs then A->C is called transitive dependency. No intermediate.
STUDENT
•
Example 1 – In relation STUDENT given in Table,
FD set: {STUD_NO -> STUD_NAME, STUD_NO -> STUD_STATE,
STUD_STATE -> STUD_COUNTRY, STUD_NO -> STUD_AGE}
Candidate Key: {STUD_NO}
 For this relation in table , STUD_NO -> STUD_STATE and
STUD_STATE -> STUD_COUNTRY are true. So STUD_COUNTRY
is transitively dependent on STUD_NO. It violates the third
normal form. To convert it in third normal form, we will
decompose the relation STUDENT (STUD_NO, STUD_NAME,
STUD_STATE, STUD_COUNTRY_STUD_AGE) as:
STUDENT (STUD_NO, STUD_NAME, STUD_STATE, STUD_AGE)
STATE_COUNTRY (STATE, COUNTRY)

STUD_NO STUD_NAME STUD_AGE STUD_STATE
1 RAM 20 HARYANA
2 RAM 19 PUNJAB
3 SURESH 21 PUNJAB
STUD_STATE STUD_COUNR
Y
HARYANA INDIA
PUNJAB INDIA
PUNJAB INDIA
BCNF
• BCNF is the advance version of 3NF. It is stricter than 3NF.
• A table is in BCNF if every functional dependency X → Y, X is the
super key of the table.
• For BCNF, the table should be in 3NF, and for every FD, LHS is
super key.
• Example: Let's assume there is a company where employees
work in more than one department.
• EMPLOYEE table:
In the above table Functional dependencies are as follows:
• EMP_ID → EMP_COUNTRY
• EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate key: {EMP-ID, EMP-DEPT}
The table is not in BCNF because neither EMP_DEPT nor EMP_ID alone are keys.
MP_ID EMP_COUNTRY EMP_DEPT DEPT_TYPE EMP_DEPT_NO
264 India Designing D394 283
264 India Testing D394 300
364 UK Stores D283 232
364 UK Developing D283 549
BCNF
• Remove the non trivial functional dependency.
• Make a separate table for the determinants.
• To convert the given table into BCNF, we decompose it
into three tables:
• EMP_COUNTRY table:
• EMP_DEPT table:
• EMP_DEPT_MAPPING table:
• Functional dependencies:
EMP_ID → EMP_COUNTRY
EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO}
Candidate keys:
• For the first table: EMP_ID
For the second table: EMP_DEPT
For the third table: {EMP_ID, EMP_DEPT}
• this is in BCNF because left side part of both the functional dependencies is a key.
EMP_ID EMP_COUNTRY
264 India
264 India
EMP_DEPT DEPT_TYPE EMP_DEPT_NO
Designing D394 283
Testing D394 300
Stores D283 232
Developing D283 549
EMP_ID EMP_DEPT
D394 283
D394 300
D283 232
D283 549
Example -1 nf
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM
DATABASE MANAGEMENT SYSTEM

More Related Content

Similar to DATABASE MANAGEMENT SYSTEM

database management system
database management systemdatabase management system
database management systemNivetha Ganesan
 
Database - Normalization
Database - NormalizationDatabase - Normalization
Database - NormalizationMudasir Qazi
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelKunal Anand
 
Relational data modeling trends for transactional applications
Relational data modeling trends for transactional applicationsRelational data modeling trends for transactional applications
Relational data modeling trends for transactional applicationsIke Ellis
 
Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)Vijayananda Ratnam Ch
 
Database normalization
Database normalizationDatabase normalization
Database normalizationEdward Blurock
 
introduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptintroduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptrekhasai2468
 
Week 1 and 2 Getting started with DBMS.pptx
Week 1 and 2 Getting started with DBMS.pptxWeek 1 and 2 Getting started with DBMS.pptx
Week 1 and 2 Getting started with DBMS.pptxRiannel Tecson
 
chapter 4-Functional Dependency and Normilization.pdf
chapter 4-Functional Dependency and Normilization.pdfchapter 4-Functional Dependency and Normilization.pdf
chapter 4-Functional Dependency and Normilization.pdfMisganawAbeje1
 

Similar to DATABASE MANAGEMENT SYSTEM (20)

database management system
database management systemdatabase management system
database management system
 
Distributed DBMS - Unit 2 - Overview of RDBMS
Distributed DBMS - Unit 2 - Overview of RDBMSDistributed DBMS - Unit 2 - Overview of RDBMS
Distributed DBMS - Unit 2 - Overview of RDBMS
 
Database - Normalization
Database - NormalizationDatabase - Normalization
Database - Normalization
 
Chapter-5 The Relational Data Model
Chapter-5 The Relational Data ModelChapter-5 The Relational Data Model
Chapter-5 The Relational Data Model
 
Relational data modeling trends for transactional applications
Relational data modeling trends for transactional applicationsRelational data modeling trends for transactional applications
Relational data modeling trends for transactional applications
 
Dbms relational data model and sql queries
Dbms relational data model and sql queries Dbms relational data model and sql queries
Dbms relational data model and sql queries
 
Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)Introduction to Database Management Systems (DBMS)
Introduction to Database Management Systems (DBMS)
 
Database normalization
Database normalizationDatabase normalization
Database normalization
 
database1.pdf
database1.pdfdatabase1.pdf
database1.pdf
 
Relational model
Relational modelRelational model
Relational model
 
normalization-1.pptx
normalization-1.pptxnormalization-1.pptx
normalization-1.pptx
 
Year 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st TermYear 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st Term
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
 
introduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptintroduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.ppt
 
ERD.ppt
ERD.pptERD.ppt
ERD.ppt
 
ERD.ppt
ERD.pptERD.ppt
ERD.ppt
 
Data Modeling
Data ModelingData Modeling
Data Modeling
 
Week 1 and 2 Getting started with DBMS.pptx
Week 1 and 2 Getting started with DBMS.pptxWeek 1 and 2 Getting started with DBMS.pptx
Week 1 and 2 Getting started with DBMS.pptx
 
chapter 4-Functional Dependency and Normilization.pdf
chapter 4-Functional Dependency and Normilization.pdfchapter 4-Functional Dependency and Normilization.pdf
chapter 4-Functional Dependency and Normilization.pdf
 
02 Related Concepts
02 Related Concepts02 Related Concepts
02 Related Concepts
 

Recently uploaded

Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Module 4: Mendelian Genetics and Punnett Square
Module 4:  Mendelian Genetics and Punnett SquareModule 4:  Mendelian Genetics and Punnett Square
Module 4: Mendelian Genetics and Punnett SquareIsiahStephanRadaza
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...jana861314
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfnehabiju2046
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
The Black hole shadow in Modified Gravity
The Black hole shadow in Modified GravityThe Black hole shadow in Modified Gravity
The Black hole shadow in Modified GravitySubhadipsau21168
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡anilsa9823
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 
Recombination DNA Technology (Microinjection)
Recombination DNA Technology (Microinjection)Recombination DNA Technology (Microinjection)
Recombination DNA Technology (Microinjection)Jshifa
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsssuserddc89b
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxAleenaTreesaSaji
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.aasikanpl
 

Recently uploaded (20)

Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
Engler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomyEngler and Prantl system of classification in plant taxonomy
Engler and Prantl system of classification in plant taxonomy
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
9953056974 Young Call Girls In Mahavir enclave Indian Quality Escort service
 
Module 4: Mendelian Genetics and Punnett Square
Module 4:  Mendelian Genetics and Punnett SquareModule 4:  Mendelian Genetics and Punnett Square
Module 4: Mendelian Genetics and Punnett Square
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
 
A relative description on Sonoporation.pdf
A relative description on Sonoporation.pdfA relative description on Sonoporation.pdf
A relative description on Sonoporation.pdf
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
The Black hole shadow in Modified Gravity
The Black hole shadow in Modified GravityThe Black hole shadow in Modified Gravity
The Black hole shadow in Modified Gravity
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service  🪡
CALL ON ➥8923113531 🔝Call Girls Kesar Bagh Lucknow best Night Fun service 🪡
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Munirka Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 
Recombination DNA Technology (Microinjection)
Recombination DNA Technology (Microinjection)Recombination DNA Technology (Microinjection)
Recombination DNA Technology (Microinjection)
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physics
 
GFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptxGFP in rDNA Technology (Biotechnology).pptx
GFP in rDNA Technology (Biotechnology).pptx
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
Call Girls in Mayapuri Delhi 💯Call Us 🔝9953322196🔝 💯Escort.
 

DATABASE MANAGEMENT SYSTEM

  • 1. DATABASE MANAGAMENT SYSTEM Dr. Gopinath D Assistant Professor Department of Computer Science Kristu Jayanti College Bengaluru NORMALIZATION AND RELATIONAL DATA MODEL Functional dependencies and normalization for relational databases
  • 2. No. DBMS RDBMS 1) DBMS applications store data as file. RDBMS applications store data in a tabular form. 2) In DBMS, data is generally stored in either a hierarchical form or a navigational form. In RDBMS, the tables have an identifier called primary key and the data values are stored in the form of tables. 3) Normalization is not present in DBMS. Normalization is present in RDBMS. 4) DBMS does not apply any security with regards to data manipulation. RDBMS defines the integrity constraint for the purpose of ACID (Atomocity, Consistency, Isolation and Durability) property. 5) DBMS uses file system to store data, so there will be no relation between the tables. in RDBMS, data values are stored in the form of tables, so a relationship between these data values will be stored in the form of a table as well. 6) DBMS has to provide some uniform methods to access the stored information. RDBMS system supports a tabular structure of the data and a relationship between them to access the stored information. 7) DBMS does not support distributed database. RDBMS supports distributed database. 8) DBMS is meant to be for small organization and deal with small data. it supports single user. RDBMS is designed to handle large amount of data. it supports multiple users. 9) Examples of DBMS are file systems, xml etc. Example of RDBMS are mysql, postgre, sql server, oracle etc.
  • 3. Database design • Database design • Bottom up - breaking down a big problem into smaller • Top down - solving the smaller problems at the fundamental level and then integrating them into a whole and complete solution. Grouping of attributes to form relational schema
  • 4. Design guideline for Evaluating relation DB schemas Chp 5 4 • Schema – design a structure for database • Two levels of relation schemas • The logical or conceptual view • How users interpret the relation schemas and the meaning of their attributes. • Implementation or storage view or physical view • How the tuples in the base relation are stored and updated.
  • 5. Pitfalls in relational database design Chp 5 5 1. Poor semantics of the attributes 2. Redundant values in tuples 3. Null values in tuples 4. Possibility of generating spurious tuples.
  • 6. 1.Semantics of the Relation Attributes Semantic data is data that has been structured to add meaning to the data.) • GUIDELINE 1: Informally, each tuple in a relation should represent one entity or relationship instance. (Applies to individual relations and their attributes). • Attributes of different entities (EMPLOYEEs, DEPARTMENTs, PROJECTs) should not be mixed in the same relation • Only foreign keys should be used to refer to other entities • Entity and relationship attributes should be kept apart as much as possible. • Bottom Line: Design a schema that can be explained easily relation by relation. The semantics of attributes should be easy to interpret. 7
  • 7. A Simplified COMPANY relational database schema Chp 5 7
  • 8. 2.Redundant Information in Tuples and Update Anomalies(inconsistency in the pattern from the normal form) Chp 5 8 • Goal of schema design is to minimize the storage space used by the base relations. • Information is stored redundantly • Wastes storage • Causes problems with update anomalies • Insertion anomalies • Deletion anomalies • Modification anomalies
  • 9.
  • 10. Two relation schemas suffering from update anomalies Chp 5 1 0 ENAM E SSN BDATE ADDRE SS DNUMB ER DNAM E DMGRS SN SSN PNUMB ER HOUR S ENAM E PNAM E PLOCA TI O N EMP_DEPT EMP_PROJ
  • 12. EXAMPLE OF AN INSERT ANOMALY Chp 5 1 2 • Consider the relation: • EMP_PROJ(Emp#, Proj#, Ename, Pname, No_hours) • Insert Anomaly: • Cannot insert a project unless an employee is assigned to it. • Conversely • Cannot insert an employee unless an he/she is assigned to a project.
  • 13. EXAMPLE OF AN DELETE ANOMALY Chp 5 1 3 • Consider the relation: • EMP_PROJ(Emp#, Proj#, Ename, Pname, No_hours) • Delete Anomaly: • When a project is deleted, it will result in deleting all the employees who work on that project. • Alternately, if an employee is the sole employee on a project, deleting that employee would result in deleting the corresponding project.
  • 14. EXAMPLE OF AN UPDATE ANOMALY Chp 5 1 4 • Consider the relation: • EMP_PROJ(Emp#, Proj#, Ename, Pname, No_hours) • Update Anomaly: • Changing the name of project number P1 from “Billing” to “Customer-Accounting” may cause this update to be made for all 100 employees working on project P1.
  • 15. Guideline to Redundant InformationinTuples and UpdateAnomalies Chp 5 1 5 • GUIDELINE 2: • Design a schema that does not suffer from the insertion, deletion and update anomalies. • If there are any anomalies present, then note them so that applications can be made to take them into account. • In general, it is advisable to use anomaly free base relations and to specify views that include the joins for placing together the attributes frequently referenced in important queries.
  • 16. Problems with Nulls Chp 5 1 6 • If many attributes are grouped together as a fat relation, it gives rise to many nulls in the tuples. • Waste storage • Problems in understanding the meaning of the attributes • Difficult while using Nulls in aggregate operators like count or sum
  • 17. 3. Null Values in Tuples Chp 5 1 7 • Interpretations of nulls: a. The attribute does not apply to this tuple. b. The attribute value for this tuple is not known. c. The value is known but has not been recorded yet.
  • 18. • GUIDELINE 3: • void placing attributes in a base relation whose values may frequently be null. • Relations should be designed such that their tuples will have as few NULL values as possible • Attributes that are NULL frequently could be placed in separate relations (with the primary key) • Example:- • if only 10% of employees have individual offices, it is better not to include office_number as an attribute in the employee relation. • Better create a new relation emp_offices(essn, office_number) Chp 5 1 8
  • 19. Example of Fake Tuples Chp 5 1 9
  • 20. Generation of spurious tuples Chp 5 2 0 • The two relations EMP_PROJ1 and EMP_LOCS as the base relations of EMP_PROJ, is not a good schema design. • Problem is if a Natural Join is performed on the above two relations it produces more tuples than original set of tuples in EMP_PROJ. • These additional tuples that were not in EMP_PROJ are called spurious tuples because they represent spurious or wrong information that is not valid. • This is because the PLOCATION attribute which is used for joining is neither a primary key, nor a foreign key in either EMP_LOCS AND EMP_PROJ1.
  • 21. Example of Spurious Tuples contd Chp 5 2 1
  • 22. 4. Spurious Tuples Chp 5 2 2 • Bad designs for a relational database may result in erroneous results for certain JOIN operations • The "lossless join" property is used to guarantee meaningful results for join operations • GUIDELINE 4: • Design relation schemas so that they can be joined with equality conditions on attributes that are either primary keys or foreign keys in a way that guarantees that no spurious tuples are generated. • Non-additive or losslessness of the corresponding join • Preservation of the functionaldependencies.
  • 23. Summary and Discussion of Design Guidelines 2 3 Problems pointed out: • Anomalies cause redundant work to be done during • Insertion • Modification • Deletion • Waste of storage space due to nulls and difficulty of performing aggregation operations and joins due to null values • Generation of invalid and spurious data during joins on improperly related base relations.
  • 24. Functional dependencies - normalization • A functional dependency is a constraint between two sets of attributes from the database. • Normalization is the process of organizing the data in the database. Normalization: • Normalization is used to minimize the redundancy from a relation or set of relations. It is also used to eliminate the undesirable characteristics like Insertion, Update and Deletion Anomalies. • 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. NF • 1NF – Not allowed multivalued attribute • 2NF – No partial dependency • 3nf – no transitive dependency • BCNF – Remove non trivial functional dependency • Multivalued – more than one value for single attribute value • Dependency – one attribute depend on other • Partial – one attribute partially depend on other attribute • Transitive – x->y and y->z = x->z [ no intermediate] • Trivial -
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34. 1NF • A relation is in first normal form if every attribute in that relation is single valued attribute. • Not allowed multi value attributed • Example 1:
  • 35. • Example 2: • I NF ID Name Courses 1 A C1,C2 2 E C3 3 M C2,C3 ID Name Courses 1 A C1 1 A C2 2 E C3 3 M C2 3 M C3
  • 36. 2nf • No partial dependency • A relation must be in first normal form and relation must not contain any partial dependency. • Partial Dependency – If the proper subset of candidate key determines non-prime attribute, it is called partial dependency. 2NF Stud_no Course_no Courses_Fee 1 C1 1000 2 C2 1500 1 C4 2000 4 C3 1000 4 C1 1000 2 C5 2000  COURSE_FEE cannot alone decide the value of COURSE_NO or STUD_NO;  COURSE_FEE together with STUD_NO cannot decide the value of COURSE_NO;  COURSE_FEE together with COURSE_NO cannot decide the value of STUD_NO; COURSE_FEE would be a non-prime attribute, as it does not belong to the one only candidate key {STUD_NO, COURSE_NO} ; To convert the above relation to 2NF, we need to split the table into two tables such as : Table 1: STUD_NO, COURSE_NO Table 2: COURSE_NO, COURSE_FEE Stud_no Course_no 1 C1 2 C2 1 C4 4 C3 4 C1 2 C5 Course_no Courses_Fee C1 1000 C2 1500 C4 2000 C3 1000 C1 1000 C5 2000  NOTE: 2NF tries to reduce the redundant data getting stored in memory. For instance, if there are 100 students taking C1 course, we don’t need to store its Fee as 1000 for all the 100 records, instead once we can store it in the second table as the course fee for C1 is 1000.
  • 37. 3nf • no transitive dependency • A relation will be in 3NF if it is in 2NF and not contain any transitive partial dependency. • 3NF is used to reduce the data duplication. It is also used to achieve the data integrity. • If there is no transitive dependency for non-prime attributes, then the relation must be in third normal form. • A relation is in third normal form if it holds atleast one of the following conditions for every non-trivial function dependency X → Y. • X is a super key. • Y is a prime attribute, i.e., each element of Y is part of some candidate key.
  • 38. 3nf • Transitive dependency – If A->B and B->C are two FDs then A->C is called transitive dependency. No intermediate. STUDENT • Example 1 – In relation STUDENT given in Table, FD set: {STUD_NO -> STUD_NAME, STUD_NO -> STUD_STATE, STUD_STATE -> STUD_COUNTRY, STUD_NO -> STUD_AGE} Candidate Key: {STUD_NO}  For this relation in table , STUD_NO -> STUD_STATE and STUD_STATE -> STUD_COUNTRY are true. So STUD_COUNTRY is transitively dependent on STUD_NO. It violates the third normal form. To convert it in third normal form, we will decompose the relation STUDENT (STUD_NO, STUD_NAME, STUD_STATE, STUD_COUNTRY_STUD_AGE) as: STUDENT (STUD_NO, STUD_NAME, STUD_STATE, STUD_AGE) STATE_COUNTRY (STATE, COUNTRY)  STUD_NO STUD_NAME STUD_AGE STUD_STATE 1 RAM 20 HARYANA 2 RAM 19 PUNJAB 3 SURESH 21 PUNJAB STUD_STATE STUD_COUNR Y HARYANA INDIA PUNJAB INDIA PUNJAB INDIA
  • 39. BCNF • BCNF is the advance version of 3NF. It is stricter than 3NF. • A table is in BCNF if every functional dependency X → Y, X is the super key of the table. • For BCNF, the table should be in 3NF, and for every FD, LHS is super key. • Example: Let's assume there is a company where employees work in more than one department.
  • 40.
  • 41. • EMPLOYEE table: In the above table Functional dependencies are as follows: • EMP_ID → EMP_COUNTRY • EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO} Candidate key: {EMP-ID, EMP-DEPT} The table is not in BCNF because neither EMP_DEPT nor EMP_ID alone are keys. MP_ID EMP_COUNTRY EMP_DEPT DEPT_TYPE EMP_DEPT_NO 264 India Designing D394 283 264 India Testing D394 300 364 UK Stores D283 232 364 UK Developing D283 549
  • 42. BCNF • Remove the non trivial functional dependency. • Make a separate table for the determinants. • To convert the given table into BCNF, we decompose it into three tables: • EMP_COUNTRY table: • EMP_DEPT table: • EMP_DEPT_MAPPING table: • Functional dependencies: EMP_ID → EMP_COUNTRY EMP_DEPT → {DEPT_TYPE, EMP_DEPT_NO} Candidate keys: • For the first table: EMP_ID For the second table: EMP_DEPT For the third table: {EMP_ID, EMP_DEPT} • this is in BCNF because left side part of both the functional dependencies is a key. EMP_ID EMP_COUNTRY 264 India 264 India EMP_DEPT DEPT_TYPE EMP_DEPT_NO Designing D394 283 Testing D394 300 Stores D283 232 Developing D283 549 EMP_ID EMP_DEPT D394 283 D394 300 D283 232 D283 549
  • 43.