SlideShare a Scribd company logo
1 of 20
Database System Concepts, 6th Ed.
©Silberschatz, Korth and Sudarshan
See www.db-book.com for conditions on re-use
Relational Database Design
Functional dependency
©Silberschatz, Korth and Sudarshan
8.2
Database System Concepts - 6th Edition
Relational Database Design
 Features of Good Relational Design
 Atomic Domains and First Normal Form
 Decomposition Using Functional Dependencies
 Functional Dependency Theory
 Algorithms for Functional Dependencies
 Decomposition Using Multivalued Dependencies
 More Normal Form
 Database-Design Process
 Modeling Temporal Data
©Silberschatz, Korth and Sudarshan
8.3
Database System Concepts - 6th Edition
University Database
©Silberschatz, Korth and Sudarshan
8.4
Database System Concepts - 6th Edition
Combine Schemas?
 Suppose we combine instructor and department into inst_dept
 (No connection to relationship set inst_dept)
 Result is possible repetition of information
©Silberschatz, Korth and Sudarshan
8.5
Database System Concepts - 6th Edition
A Combined Schema Without Repetition
 Consider combining relations
 sec_class(sec_id, building, room_number) and
 section(course_id, sec_id, semester, year)
into one relation
 section(course_id, sec_id, semester, year,
building, room_number)
 No repetition in this case
©Silberschatz, Korth and Sudarshan
8.6
Database System Concepts - 6th Edition
What About Smaller Schemas?
 Suppose we had started with inst_dept. How would we know to split up
(decompose) it into instructor and department?
 Write a rule “if there were a schema (dept_name, building, budget), then
dept_name would be a candidate key”
 Denote as a functional dependency:
dept_name  building, budget
 In inst_dept, because dept_name is not a candidate key, the building
and budget of a department may have to be repeated.
 This indicates the need to decompose inst_dept
 Not all decompositions are good. Suppose we decompose
employee(ID, name, street, city, salary) into
employee1 (ID, name)
employee2 (name, street, city, salary)
 The next slide shows how we lose information -- we cannot reconstruct
the original employee relation -- and so, this is a lossy decomposition.
©Silberschatz, Korth and Sudarshan
8.7
Database System Concepts - 6th Edition
A Lossy Decomposition
©Silberschatz, Korth and Sudarshan
8.8
Database System Concepts - 6th Edition
Example of Lossless-Join Decomposition
 Lossless join decomposition
 Decomposition of R = (A, B, C)
R1 = (A, B) R2 = (B, C)
A B


1
2
A


B
1
2
r B,C(r)
A (r) B (r)
A B


1
2
C
A
B
B
1
2
C
A
B
C
A
B
A,B(r)
©Silberschatz, Korth and Sudarshan
8.9
Database System Concepts - 6th Edition
First Normal Form
 Domain is atomic if its elements are considered to be indivisible units
 Examples of non-atomic domains:
 Set of names, composite attributes
 Identification numbers like CS101 that can be broken up into
parts
 A relational schema R is in first normal form if the domains of all
attributes of R are atomic
 Non-atomic values complicate storage and encourage redundant
(repeated) storage of data
 Example: Set of accounts stored with each customer, and set of
owners stored with each account
 We assume all relations are in first normal form (and revisit this in
Chapter 22: Object Based Databases)
©Silberschatz, Korth and Sudarshan
8.10
Database System Concepts - 6th Edition
First Normal Form (Cont’d)
 Atomicity is actually a property of how the elements of the domain are
used.
 Example: Strings would normally be considered indivisible
 Suppose that students are given roll numbers which are strings of
the form CS0012 or EE1127
 If the first two characters are extracted to find the department, the
domain of roll numbers is not atomic.
 Doing so is a bad idea: leads to encoding of information in
application program rather than in the database.
©Silberschatz, Korth and Sudarshan
8.11
Database System Concepts - 6th Edition
Goal — Devise a Theory for the Following
 Decide whether a particular relation R is in “good” form.
 In the case that a relation R is not in “good” form, decompose it into a
set of relations {R1, R2, ..., Rn} such that
 each relation is in good form
 the decomposition is a lossless-join decomposition
 Our theory is based on:
 functional dependencies
 multivalued dependencies
a multivalued dependency is a full constraint between two sets
of attributes in a relation.
©Silberschatz, Korth and Sudarshan
8.12
Database System Concepts - 6th Edition
Functional Dependencies
 Constraints on the set of legal relations.
 Require that the value for a certain set of attributes determines
uniquely the value for another set of attributes.
 A functional dependency is a generalization of the notion of a key.
©Silberschatz, Korth and Sudarshan
8.13
Database System Concepts - 6th Edition
Functional Dependencies (Cont.)
 Let R be a relation schema
  R and   R
 The functional dependency
  
holds on R if and only if for any legal relations r(R), whenever any
two tuples t1 and t2 of r agree on the attributes , they also agree
on the attributes . That is,
t1[] = t2 []  t1[ ] = t2 [ ]
 Example: Consider r(A,B ) with the following instance of r.
 On this instance, A  B does NOT hold, but B  A does hold.
1 4
1 5
3 7
©Silberschatz, Korth and Sudarshan
8.14
Database System Concepts - 6th Edition
Functional Dependencies (Cont.)
 K is a superkey for relation schema R if and only if K  R
 K is a candidate key for R if and only if
 K  R, and
 for no   K,   R
 Functional dependencies allow us to express constraints that cannot be
expressed using superkeys. Consider the schema:
inst_dept (ID, name, salary, dept_name, building, budget ).
We expect these functional dependencies to hold:
dept_name building
and ID  building
but would not expect the following to hold:
dept_name  salary
©Silberschatz, Korth and Sudarshan
8.15
Database System Concepts - 6th Edition
Use of Functional Dependencies
 We use functional dependencies to:
 test relations to see if they are legal under a given set of functional
dependencies.
 If a relation r is legal under a set F of functional dependencies, we
say that r satisfies F.
 specify constraints on the set of legal relations
 We say that F holds on R if all legal relations on R satisfy the set
of functional dependencies F.
 Note: A specific instance of a relation schema may satisfy a functional
dependency even if the functional dependency does not hold on all legal
instances.
 For example, a specific instance of instructor may, by chance, satisfy
name  ID.
©Silberschatz, Korth and Sudarshan
8.16
Database System Concepts - 6th Edition
Types Functional Dependencies (Cont.)
» Trivial
» Non-trivial
» Transitive
» Multivalued
©Silberschatz, Korth and Sudarshan
8.17
Database System Concepts - 6th Edition
Types Functional Dependencies (Cont.)
 Trivial The dependency of an attribute on a set of attributes is known
as trivial functional dependency if the set of attributes includes that
attribute. That means If a functional dependency (FD)    holds,
where  is a subset of  , then it is called a trivial FD. Trivial FDs
always hold.
 Non-trivial − If an FD )    holds, where  is not a subset of ,
then it is called a non-trivial FD.
 For example:
An employee table with three attributes: emp_id, emp_name,
emp_address.
The following functional dependencies are non-trivial:
emp_id -> emp_name (emp_name is not a subset of emp_id)
emp_id -> emp_address (emp_address is not a subset of emp_id)
On the other hand, the following dependencies are trivial:
{emp_id, emp_name} -> emp_name [emp_name is a subset of {emp_id,
emp_name}]
.
©Silberschatz, Korth and Sudarshan
8.18
Database System Concepts - 6th Edition
Types Functional Dependencies (Cont.)
 Transitive: A functional dependency is said to be transitive if it is
indirectly formed by two functional dependencies. For e.g.
X -> Z is a transitive dependency if the following three functional
dependencies hold true:
X->Y
Y does not ->X
Y->Z
Book Author Author_age
Game of
Thrones
George R. R.
Martin
66
Harry Potter J. K. Rowling 49
Dying of the
Light
George R. R.
Martin
66
Example: Let’s take an example to
understand it better:
{Book} ->{Author} (if we know the book,
we knows the author name)
{Author} does not ->{Book}
{Author} -> {Author_age
©Silberschatz, Korth and Sudarshan
8.19
Database System Concepts - 6th Edition
Types Functional Dependencies (Cont.)
 Multivalued: Multivalued dependency occurs when there are more
than one independent multivalued attributes in a table.
 For example: Consider a bike manufacture company, which produces
two colors (Black and white) in each model every year.
 bike_model ->> manuf_year
 bike_model ->> color
ike_model manuf_year color
M1001 2007 Black
M1001 2007 Red
M2012 2008 Black
M2012 2008 Red
M2222 2009 Black
M2222 2009 Red
©Silberschatz, Korth and Sudarshan
8.20
Database System Concepts - 6th Edition
Closure of a Set of Functional
Dependencies
 Given a set F of functional dependencies, there are certain other
functional dependencies that are logically implied by F.
 For example: If A  B and B  C, then we can infer that A 
C
 The set of all functional dependencies logically implied by F is the
closure of F.
 We denote the closure of F by F+.
 F+ is a superset of F.

More Related Content

Similar to Functional dependency.pptx

Relational database concept
Relational database conceptRelational database concept
Relational database conceptfikirabc
 
Database System Concepts, 6th Ed.©Silberschatz, Korth and .docx
Database System Concepts, 6th Ed.©Silberschatz, Korth and .docxDatabase System Concepts, 6th Ed.©Silberschatz, Korth and .docx
Database System Concepts, 6th Ed.©Silberschatz, Korth and .docxrandyburney60861
 
DBMS _Relational model
DBMS _Relational modelDBMS _Relational model
DBMS _Relational modelAzizul Mamun
 
Relational Algebra and relational queries .ppt
Relational Algebra and relational queries .pptRelational Algebra and relational queries .ppt
Relational Algebra and relational queries .pptShahidSultan24
 
DATABASE MANAGEMENT SYSTEMS ER MODEL.ppt
DATABASE MANAGEMENT SYSTEMS ER MODEL.pptDATABASE MANAGEMENT SYSTEMS ER MODEL.ppt
DATABASE MANAGEMENT SYSTEMS ER MODEL.pptYashShirude1
 
Intro to Relational Model
Intro to Relational ModelIntro to Relational Model
Intro to Relational ModelHazemWaheeb1
 
relational algebra and calculus queries .ppt
relational algebra and calculus queries .pptrelational algebra and calculus queries .ppt
relational algebra and calculus queries .pptShahidSultan24
 
Database System Concepts ch4.pdf
Database System Concepts ch4.pdfDatabase System Concepts ch4.pdf
Database System Concepts ch4.pdfUsamaAlZayan
 
RDBMS, theory class - 1 (UIU CSI 221)
RDBMS, theory class - 1 (UIU CSI 221)RDBMS, theory class - 1 (UIU CSI 221)
RDBMS, theory class - 1 (UIU CSI 221)Muhammad T Q Nafis
 
U2_ER_upto_map_relations.pdf
U2_ER_upto_map_relations.pdfU2_ER_upto_map_relations.pdf
U2_ER_upto_map_relations.pdfssusera7b660
 
Query optimization
Query optimizationQuery optimization
Query optimizationNeha Behl
 

Similar to Functional dependency.pptx (20)

ch7-clean.ppt
ch7-clean.pptch7-clean.ppt
ch7-clean.ppt
 
Relational Model
Relational ModelRelational Model
Relational Model
 
Relational database concept
Relational database conceptRelational database concept
Relational database concept
 
Database System Concepts, 6th Ed.©Silberschatz, Korth and .docx
Database System Concepts, 6th Ed.©Silberschatz, Korth and .docxDatabase System Concepts, 6th Ed.©Silberschatz, Korth and .docx
Database System Concepts, 6th Ed.©Silberschatz, Korth and .docx
 
DBMS _Relational model
DBMS _Relational modelDBMS _Relational model
DBMS _Relational model
 
Relational Algebra and relational queries .ppt
Relational Algebra and relational queries .pptRelational Algebra and relational queries .ppt
Relational Algebra and relational queries .ppt
 
Ch7
Ch7Ch7
Ch7
 
DATABASE MANAGEMENT SYSTEMS ER MODEL.ppt
DATABASE MANAGEMENT SYSTEMS ER MODEL.pptDATABASE MANAGEMENT SYSTEMS ER MODEL.ppt
DATABASE MANAGEMENT SYSTEMS ER MODEL.ppt
 
ER Models.ppt
ER Models.pptER Models.ppt
ER Models.ppt
 
Intro to Relational Model
Intro to Relational ModelIntro to Relational Model
Intro to Relational Model
 
Ch 2.pdf
Ch 2.pdfCh 2.pdf
Ch 2.pdf
 
relational algebra and calculus queries .ppt
relational algebra and calculus queries .pptrelational algebra and calculus queries .ppt
relational algebra and calculus queries .ppt
 
ch7
ch7ch7
ch7
 
Database System Concepts ch4.pdf
Database System Concepts ch4.pdfDatabase System Concepts ch4.pdf
Database System Concepts ch4.pdf
 
RDBMS, theory class - 1 (UIU CSI 221)
RDBMS, theory class - 1 (UIU CSI 221)RDBMS, theory class - 1 (UIU CSI 221)
RDBMS, theory class - 1 (UIU CSI 221)
 
U2_ER_upto_map_relations.pdf
U2_ER_upto_map_relations.pdfU2_ER_upto_map_relations.pdf
U2_ER_upto_map_relations.pdf
 
L8 design1
L8 design1L8 design1
L8 design1
 
ch3[1].ppt
ch3[1].pptch3[1].ppt
ch3[1].ppt
 
check 11
check 11check 11
check 11
 
Query optimization
Query optimizationQuery optimization
Query optimization
 

Recently uploaded

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 

Recently uploaded (20)

MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 

Functional dependency.pptx

  • 1. Database System Concepts, 6th Ed. ©Silberschatz, Korth and Sudarshan See www.db-book.com for conditions on re-use Relational Database Design Functional dependency
  • 2. ©Silberschatz, Korth and Sudarshan 8.2 Database System Concepts - 6th Edition Relational Database Design  Features of Good Relational Design  Atomic Domains and First Normal Form  Decomposition Using Functional Dependencies  Functional Dependency Theory  Algorithms for Functional Dependencies  Decomposition Using Multivalued Dependencies  More Normal Form  Database-Design Process  Modeling Temporal Data
  • 3. ©Silberschatz, Korth and Sudarshan 8.3 Database System Concepts - 6th Edition University Database
  • 4. ©Silberschatz, Korth and Sudarshan 8.4 Database System Concepts - 6th Edition Combine Schemas?  Suppose we combine instructor and department into inst_dept  (No connection to relationship set inst_dept)  Result is possible repetition of information
  • 5. ©Silberschatz, Korth and Sudarshan 8.5 Database System Concepts - 6th Edition A Combined Schema Without Repetition  Consider combining relations  sec_class(sec_id, building, room_number) and  section(course_id, sec_id, semester, year) into one relation  section(course_id, sec_id, semester, year, building, room_number)  No repetition in this case
  • 6. ©Silberschatz, Korth and Sudarshan 8.6 Database System Concepts - 6th Edition What About Smaller Schemas?  Suppose we had started with inst_dept. How would we know to split up (decompose) it into instructor and department?  Write a rule “if there were a schema (dept_name, building, budget), then dept_name would be a candidate key”  Denote as a functional dependency: dept_name  building, budget  In inst_dept, because dept_name is not a candidate key, the building and budget of a department may have to be repeated.  This indicates the need to decompose inst_dept  Not all decompositions are good. Suppose we decompose employee(ID, name, street, city, salary) into employee1 (ID, name) employee2 (name, street, city, salary)  The next slide shows how we lose information -- we cannot reconstruct the original employee relation -- and so, this is a lossy decomposition.
  • 7. ©Silberschatz, Korth and Sudarshan 8.7 Database System Concepts - 6th Edition A Lossy Decomposition
  • 8. ©Silberschatz, Korth and Sudarshan 8.8 Database System Concepts - 6th Edition Example of Lossless-Join Decomposition  Lossless join decomposition  Decomposition of R = (A, B, C) R1 = (A, B) R2 = (B, C) A B   1 2 A   B 1 2 r B,C(r) A (r) B (r) A B   1 2 C A B B 1 2 C A B C A B A,B(r)
  • 9. ©Silberschatz, Korth and Sudarshan 8.9 Database System Concepts - 6th Edition First Normal Form  Domain is atomic if its elements are considered to be indivisible units  Examples of non-atomic domains:  Set of names, composite attributes  Identification numbers like CS101 that can be broken up into parts  A relational schema R is in first normal form if the domains of all attributes of R are atomic  Non-atomic values complicate storage and encourage redundant (repeated) storage of data  Example: Set of accounts stored with each customer, and set of owners stored with each account  We assume all relations are in first normal form (and revisit this in Chapter 22: Object Based Databases)
  • 10. ©Silberschatz, Korth and Sudarshan 8.10 Database System Concepts - 6th Edition First Normal Form (Cont’d)  Atomicity is actually a property of how the elements of the domain are used.  Example: Strings would normally be considered indivisible  Suppose that students are given roll numbers which are strings of the form CS0012 or EE1127  If the first two characters are extracted to find the department, the domain of roll numbers is not atomic.  Doing so is a bad idea: leads to encoding of information in application program rather than in the database.
  • 11. ©Silberschatz, Korth and Sudarshan 8.11 Database System Concepts - 6th Edition Goal — Devise a Theory for the Following  Decide whether a particular relation R is in “good” form.  In the case that a relation R is not in “good” form, decompose it into a set of relations {R1, R2, ..., Rn} such that  each relation is in good form  the decomposition is a lossless-join decomposition  Our theory is based on:  functional dependencies  multivalued dependencies a multivalued dependency is a full constraint between two sets of attributes in a relation.
  • 12. ©Silberschatz, Korth and Sudarshan 8.12 Database System Concepts - 6th Edition Functional Dependencies  Constraints on the set of legal relations.  Require that the value for a certain set of attributes determines uniquely the value for another set of attributes.  A functional dependency is a generalization of the notion of a key.
  • 13. ©Silberschatz, Korth and Sudarshan 8.13 Database System Concepts - 6th Edition Functional Dependencies (Cont.)  Let R be a relation schema   R and   R  The functional dependency    holds on R if and only if for any legal relations r(R), whenever any two tuples t1 and t2 of r agree on the attributes , they also agree on the attributes . That is, t1[] = t2 []  t1[ ] = t2 [ ]  Example: Consider r(A,B ) with the following instance of r.  On this instance, A  B does NOT hold, but B  A does hold. 1 4 1 5 3 7
  • 14. ©Silberschatz, Korth and Sudarshan 8.14 Database System Concepts - 6th Edition Functional Dependencies (Cont.)  K is a superkey for relation schema R if and only if K  R  K is a candidate key for R if and only if  K  R, and  for no   K,   R  Functional dependencies allow us to express constraints that cannot be expressed using superkeys. Consider the schema: inst_dept (ID, name, salary, dept_name, building, budget ). We expect these functional dependencies to hold: dept_name building and ID  building but would not expect the following to hold: dept_name  salary
  • 15. ©Silberschatz, Korth and Sudarshan 8.15 Database System Concepts - 6th Edition Use of Functional Dependencies  We use functional dependencies to:  test relations to see if they are legal under a given set of functional dependencies.  If a relation r is legal under a set F of functional dependencies, we say that r satisfies F.  specify constraints on the set of legal relations  We say that F holds on R if all legal relations on R satisfy the set of functional dependencies F.  Note: A specific instance of a relation schema may satisfy a functional dependency even if the functional dependency does not hold on all legal instances.  For example, a specific instance of instructor may, by chance, satisfy name  ID.
  • 16. ©Silberschatz, Korth and Sudarshan 8.16 Database System Concepts - 6th Edition Types Functional Dependencies (Cont.) » Trivial » Non-trivial » Transitive » Multivalued
  • 17. ©Silberschatz, Korth and Sudarshan 8.17 Database System Concepts - 6th Edition Types Functional Dependencies (Cont.)  Trivial The dependency of an attribute on a set of attributes is known as trivial functional dependency if the set of attributes includes that attribute. That means If a functional dependency (FD)    holds, where  is a subset of  , then it is called a trivial FD. Trivial FDs always hold.  Non-trivial − If an FD )    holds, where  is not a subset of , then it is called a non-trivial FD.  For example: An employee table with three attributes: emp_id, emp_name, emp_address. The following functional dependencies are non-trivial: emp_id -> emp_name (emp_name is not a subset of emp_id) emp_id -> emp_address (emp_address is not a subset of emp_id) On the other hand, the following dependencies are trivial: {emp_id, emp_name} -> emp_name [emp_name is a subset of {emp_id, emp_name}] .
  • 18. ©Silberschatz, Korth and Sudarshan 8.18 Database System Concepts - 6th Edition Types Functional Dependencies (Cont.)  Transitive: A functional dependency is said to be transitive if it is indirectly formed by two functional dependencies. For e.g. X -> Z is a transitive dependency if the following three functional dependencies hold true: X->Y Y does not ->X Y->Z Book Author Author_age Game of Thrones George R. R. Martin 66 Harry Potter J. K. Rowling 49 Dying of the Light George R. R. Martin 66 Example: Let’s take an example to understand it better: {Book} ->{Author} (if we know the book, we knows the author name) {Author} does not ->{Book} {Author} -> {Author_age
  • 19. ©Silberschatz, Korth and Sudarshan 8.19 Database System Concepts - 6th Edition Types Functional Dependencies (Cont.)  Multivalued: Multivalued dependency occurs when there are more than one independent multivalued attributes in a table.  For example: Consider a bike manufacture company, which produces two colors (Black and white) in each model every year.  bike_model ->> manuf_year  bike_model ->> color ike_model manuf_year color M1001 2007 Black M1001 2007 Red M2012 2008 Black M2012 2008 Red M2222 2009 Black M2222 2009 Red
  • 20. ©Silberschatz, Korth and Sudarshan 8.20 Database System Concepts - 6th Edition Closure of a Set of Functional Dependencies  Given a set F of functional dependencies, there are certain other functional dependencies that are logically implied by F.  For example: If A  B and B  C, then we can infer that A  C  The set of all functional dependencies logically implied by F is the closure of F.  We denote the closure of F by F+.  F+ is a superset of F.