SlideShare a Scribd company logo
Relationships within the
 relational database
Relationships within the relational database
 You already know that relationships are classified as one-to-
  one, one-to-many, and many-to-many.

    The 1:M relationship is the relational modeling ideal.
    Therefore, this relationship type should be the norm in any
    relational database design.

 The 1:1 relationship should be rare in any relational database
  design.

 M:N relationships cannot be implemented as such in the
  relational model.
Relationships within the relational database




          The 1:M
         Relationship
Relationships within the relational database
 The 1:M Relationship

The 1:M relationship is the relational database norm.
Relationships within the relational database
 The 1:M Relationship

• Each painting is painted by one and only one painter, but each
  painter could have painted many paintings.
Relationships within the relational database
 The 1:M Relationship

• There is only one row in the PAINTER table for any given row in the
  PAINTING table, but there are may be many rows in the PAINTING
  table for any given row in the PAINTER table.



• The 1:M relationship is found in any database environment. Students in
  a typical college or university will discover that each COURSE can
  generate many CLASSes but that each CLASS refers to only one
  COURSE.
Relationships within the relational database
 The 1:M Relationship

The ERM( entity relationship model) for the 1:M relationship between
  COURSE and CLASS.
Relationships within the relational database
 The 1:M Relationship
Relationships within the relational database
 The 1:M Relationship

• Each COURSE can have many CLASSes, but each CLASS references
  only one COURSE

• There will be only one row in the COURSE table form any given
  row in the COURSE table.
Relationships within the relational database




          The 1:1
         Relationship
Relationships within the relational database
 The 1:1 Relationship

• As the 1:1 label implies, in this relationship, one entity can be
  related to only one other entity, and vise versa.

• For example, one department chair-a professor-can chair only one
  department, and one department can have only one department
  chair.

• The entities PROFESSOR and DEPARTMENT thus exhibit a 1:1
  relationship.
Relationships within the relational database
 The 1:1 Relationship




      The basic relationship modeled in Figure 3.22
Relationships within the relational database
 The 1:1 Relationship




      As you examine the tables in Figure 3.23, note that there
Relationships within the relational database
1.   Each professor is a Tiny College employee. Therefore, the professor
     identification is through the EMP_Num.

2.   The 1:1 PROFESSOR chairs DEPARTMENT relationship is
     implemented by having the EMP_NUM fereign key in the
     DEPARTMENT table.

3.   Also note that the PROFESSOR table contains the DEPT_CODE
     foreign key to implement the 1:M DEPARTMENT employs
     PROFESSOR relationship.
Relationships within the relational database
•    The preceding “PROFESSOR chairs DEPARTMENT
    example illustrates a proper 1:1 relationship. In fact, the
    use of 1:1 relationship ensures that two entity sets are
    not placed in the same table when they should not be.

However, the existence of 1:1 relationship sometimes
  means that the entity components were not defined
  properly. It could indicate that the two entities actually
  belong in the same table!
Relationships within the relational database




     The M:N
   RELATIONSHIP
Relationships within the relational database


•   A many-to-many (M:N) relationship is not supported directly in the relational
    environment. However, M:N relationships can be implemented by creating a
    new entity in 1:M relationships with the original entities.
Relationships within the relational database
Relationships within the relational database
•   To explore the many-to-many (M:N) relationship, consider a rather typical
    college environment in which each STUDENT can take CLASSes and each
    CLASS can contain many STUDENTs. The ER model in Figure 3.24 show
    the M:N relationship.
Relationships within the relational database
•    Each CLASS can have many STUDENTs, and each STUDENT can
    take many CLASSes.

• There can be many rows in the CLASS table for any given row in the
  STUDENT table, and there can be many rows in the STUDENT table
  for any given row in the class



• To examine the M:N relationship more closely, imagine a small
  college with two students, each of whom takes three classes.
Relationships within the relational database
  The M:N relationship should not be implemented for two god reasons:


 The tables create many redundancies. For example, note that the STU_NUM
 values occur many times in the STUDENT table.


 • Given the structure and contents of the two tables, the relational operations
 become very complex and are likely to lead to system efficiency errors and
 output errors.
Relationships within the relational database
Relationships within the relational database
  Fortunately, the problems inherent in the many-to-many (M:N)
 relationship can easily be avoided by creating a composite entity (also
 referred to as a bridge entity or an associative entity). Because such a table
 is used to link the tables that were originally related in an M:N relationship,
 the composite entity structure includes-as foreign keys – at least the
 primary keys of the tables that are to be linked.
Relationships within the relational database
Relationships within the relational database
  The ENROLL table yields the required M:N to 1:M conversion. Observe that
 the composite entity represented by the ENROLL table must contain at least
 the primary keys of the CLASS and STUDENTS tables (CLASS_CODE and
 STU_NUM, respectively) for which it serves as a connector. Also note that the
 STUDENT and CLASS tables now contain only one row per entity.


 The ENROLL table contains multiple occurrences of the foreign key
 values, but those controlled redundancies are incapable of producing
 anomalies as long as referential integrity is enforced.
Relationships within the relational database




 •As you can examine the figure, note that composite entity named ENROLL
 represents the linking table between STUDENT and CLASS.
Relationships within the relational database




 •This figure shows the expanded ERM, including the expanded 1:M relationship
 between COURSE and CLASS
Relationships within the relational database
Prepared BY:

•HARRY OCHINANG
  •JANE CATALLA
   •RONN RIVERA

More Related Content

PDF
DBMS 3 | ER Diagram to Relational Schema
PDF
Dbms 3: 3 Schema Architecture
PPTX
Aggregate function
PPTX
Relational model
PPTX
Er diagram
PPTX
12. oracle database architecture
PPTX
PDF
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF
DBMS 3 | ER Diagram to Relational Schema
Dbms 3: 3 Schema Architecture
Aggregate function
Relational model
Er diagram
12. oracle database architecture
Normalization | (1NF) |(2NF) (3NF)|BCNF| 4NF |5NF

What's hot (20)

PPT
Data modeling using the entity relationship model
PDF
Relational algebra in dbms
PPTX
Slide 6 er strong & weak entity
PPTX
Data Dictionary
PPT
Chapter 2 database environment
PPTX
relational algebra (joins)
PPT
Introduction to-sql
PPT
Dependency preservation
PDF
CLASE 3_ArquiteturaBD_UsuariosBD_IndependiciaLogFis_ModelosBD.pdf
PDF
4 the relational data model and relational database constraints
PPTX
Functional dependencies in Database Management System
PDF
Enhanced Entity-Relationship (EER) Modeling
PPT
Dbms relational model
PPTX
Object oriented database model
PPT
OODM-object oriented data model
PPTX
Dbms normalization
PPT
Database schema
PPT
Lecture 01 introduction to database
PPTX
Integrity Constraints
Data modeling using the entity relationship model
Relational algebra in dbms
Slide 6 er strong & weak entity
Data Dictionary
Chapter 2 database environment
relational algebra (joins)
Introduction to-sql
Dependency preservation
CLASE 3_ArquiteturaBD_UsuariosBD_IndependiciaLogFis_ModelosBD.pdf
4 the relational data model and relational database constraints
Functional dependencies in Database Management System
Enhanced Entity-Relationship (EER) Modeling
Dbms relational model
Object oriented database model
OODM-object oriented data model
Dbms normalization
Database schema
Lecture 01 introduction to database
Integrity Constraints
Ad

Viewers also liked (20)

PPT
Database Relationships
PPT
Database Relationships
PPTX
Relational Database Design
PPTX
Database : Relational Data Model
ODP
Creating relationships with tables
PPTX
Database Modeling Using Entity.. Weak And Strong Entity Types
PPT
3. Relational Models in DBMS
PDF
Relational Database Management System
PDF
Example : parallelize a simple problem
PPTX
Data Models In Database Management System
PPT
ISDD Database Structure N5
PPT
PPT
Erd optionality
PPT
Data Dictionary
PPT
Relational database management system
PPT
Database Validation
PPT
ISDD Media Types - File Compression
PPT
ISDD Standard File Formats
PPTX
Conditional statements
PPTX
Entity (types, attibute types)
Database Relationships
Database Relationships
Relational Database Design
Database : Relational Data Model
Creating relationships with tables
Database Modeling Using Entity.. Weak And Strong Entity Types
3. Relational Models in DBMS
Relational Database Management System
Example : parallelize a simple problem
Data Models In Database Management System
ISDD Database Structure N5
Erd optionality
Data Dictionary
Relational database management system
Database Validation
ISDD Media Types - File Compression
ISDD Standard File Formats
Conditional statements
Entity (types, attibute types)
Ad

Similar to Relationships within the relational database (20)

PPTX
Sql server ___________session2-data_modeling
PPTX
Cardinality and participation constraints
PPTX
DATABASE DESIGN.pptx
PPTX
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
PPTX
Download different material from slide share
PPTX
Basic building entity relationship model
PPTX
E - R Models.pptx SQL and plsql database
PPTX
5e7ry754.pptx
PPTX
entityrelationshipmodel.pptx
PPTX
Structured system analysis and design
PPTX
UNIT 1-RELATIONAL DATA MODEL for data base subject
PDF
Data Base Security note in data -unit-1.pdf
PPT
enrity relationship model and diagram .ppt
PPT
Data Modeling Er
PPTX
The Relational Model
PPTX
Relational Model
PPTX
RDBMS stands for Relational Database Management System
PPT
Data base lec3 (erd)
PPTX
Data Modeling
PDF
Fundamentals of Database Management Systems 2nd Edition Gillenson Solutions M...
Sql server ___________session2-data_modeling
Cardinality and participation constraints
DATABASE DESIGN.pptx
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Download different material from slide share
Basic building entity relationship model
E - R Models.pptx SQL and plsql database
5e7ry754.pptx
entityrelationshipmodel.pptx
Structured system analysis and design
UNIT 1-RELATIONAL DATA MODEL for data base subject
Data Base Security note in data -unit-1.pdf
enrity relationship model and diagram .ppt
Data Modeling Er
The Relational Model
Relational Model
RDBMS stands for Relational Database Management System
Data base lec3 (erd)
Data Modeling
Fundamentals of Database Management Systems 2nd Edition Gillenson Solutions M...

More from Janecatalla (20)

PPTX
Bedlibrary4
PPTX
Bedlibrary6
PPTX
Bedlibrary5
PPTX
Bedlibrary4
PPTX
Bedlibrary3
PPTX
Bedlibrary2
PPTX
Bedlibrary
PPTX
Lis124
PDF
My presentation-for-infolit-workshop1
PPTX
Pp lis
PPTX
Object oriented database model
PPTX
Jane catalla
PPTX
Catalla & cea
PPTX
PPTX
Indexing report
PPTX
Permuted Title Index
PPTX
Indexing report
PPTX
Jane iii
PPT
Readers advisory services final
PPT
Term paper counseling
Bedlibrary4
Bedlibrary6
Bedlibrary5
Bedlibrary4
Bedlibrary3
Bedlibrary2
Bedlibrary
Lis124
My presentation-for-infolit-workshop1
Pp lis
Object oriented database model
Jane catalla
Catalla & cea
Indexing report
Permuted Title Index
Indexing report
Jane iii
Readers advisory services final
Term paper counseling

Recently uploaded (20)

PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
cuic standard and advanced reporting.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Modernizing your data center with Dell and AMD
PDF
Encapsulation theory and applications.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
Teaching material agriculture food technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Electronic commerce courselecture one. Pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
cuic standard and advanced reporting.pdf
Spectral efficient network and resource selection model in 5G networks
Encapsulation_ Review paper, used for researhc scholars
The Rise and Fall of 3GPP – Time for a Sabbatical?
NewMind AI Weekly Chronicles - August'25 Week I
Modernizing your data center with Dell and AMD
Encapsulation theory and applications.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Teaching material agriculture food technology
Empathic Computing: Creating Shared Understanding
Digital-Transformation-Roadmap-for-Companies.pptx
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MYSQL Presentation for SQL database connectivity
Electronic commerce courselecture one. Pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

Relationships within the relational database

  • 1. Relationships within the relational database
  • 2. Relationships within the relational database  You already know that relationships are classified as one-to- one, one-to-many, and many-to-many.  The 1:M relationship is the relational modeling ideal. Therefore, this relationship type should be the norm in any relational database design.  The 1:1 relationship should be rare in any relational database design.  M:N relationships cannot be implemented as such in the relational model.
  • 3. Relationships within the relational database The 1:M Relationship
  • 4. Relationships within the relational database  The 1:M Relationship The 1:M relationship is the relational database norm.
  • 5. Relationships within the relational database  The 1:M Relationship • Each painting is painted by one and only one painter, but each painter could have painted many paintings.
  • 6. Relationships within the relational database  The 1:M Relationship • There is only one row in the PAINTER table for any given row in the PAINTING table, but there are may be many rows in the PAINTING table for any given row in the PAINTER table. • The 1:M relationship is found in any database environment. Students in a typical college or university will discover that each COURSE can generate many CLASSes but that each CLASS refers to only one COURSE.
  • 7. Relationships within the relational database  The 1:M Relationship The ERM( entity relationship model) for the 1:M relationship between COURSE and CLASS.
  • 8. Relationships within the relational database  The 1:M Relationship
  • 9. Relationships within the relational database  The 1:M Relationship • Each COURSE can have many CLASSes, but each CLASS references only one COURSE • There will be only one row in the COURSE table form any given row in the COURSE table.
  • 10. Relationships within the relational database The 1:1 Relationship
  • 11. Relationships within the relational database  The 1:1 Relationship • As the 1:1 label implies, in this relationship, one entity can be related to only one other entity, and vise versa. • For example, one department chair-a professor-can chair only one department, and one department can have only one department chair. • The entities PROFESSOR and DEPARTMENT thus exhibit a 1:1 relationship.
  • 12. Relationships within the relational database  The 1:1 Relationship The basic relationship modeled in Figure 3.22
  • 13. Relationships within the relational database  The 1:1 Relationship As you examine the tables in Figure 3.23, note that there
  • 14. Relationships within the relational database 1. Each professor is a Tiny College employee. Therefore, the professor identification is through the EMP_Num. 2. The 1:1 PROFESSOR chairs DEPARTMENT relationship is implemented by having the EMP_NUM fereign key in the DEPARTMENT table. 3. Also note that the PROFESSOR table contains the DEPT_CODE foreign key to implement the 1:M DEPARTMENT employs PROFESSOR relationship.
  • 15. Relationships within the relational database • The preceding “PROFESSOR chairs DEPARTMENT example illustrates a proper 1:1 relationship. In fact, the use of 1:1 relationship ensures that two entity sets are not placed in the same table when they should not be. However, the existence of 1:1 relationship sometimes means that the entity components were not defined properly. It could indicate that the two entities actually belong in the same table!
  • 16. Relationships within the relational database The M:N RELATIONSHIP
  • 17. Relationships within the relational database • A many-to-many (M:N) relationship is not supported directly in the relational environment. However, M:N relationships can be implemented by creating a new entity in 1:M relationships with the original entities.
  • 18. Relationships within the relational database
  • 19. Relationships within the relational database • To explore the many-to-many (M:N) relationship, consider a rather typical college environment in which each STUDENT can take CLASSes and each CLASS can contain many STUDENTs. The ER model in Figure 3.24 show the M:N relationship.
  • 20. Relationships within the relational database • Each CLASS can have many STUDENTs, and each STUDENT can take many CLASSes. • There can be many rows in the CLASS table for any given row in the STUDENT table, and there can be many rows in the STUDENT table for any given row in the class • To examine the M:N relationship more closely, imagine a small college with two students, each of whom takes three classes.
  • 21. Relationships within the relational database  The M:N relationship should not be implemented for two god reasons: The tables create many redundancies. For example, note that the STU_NUM values occur many times in the STUDENT table. • Given the structure and contents of the two tables, the relational operations become very complex and are likely to lead to system efficiency errors and output errors.
  • 22. Relationships within the relational database
  • 23. Relationships within the relational database  Fortunately, the problems inherent in the many-to-many (M:N) relationship can easily be avoided by creating a composite entity (also referred to as a bridge entity or an associative entity). Because such a table is used to link the tables that were originally related in an M:N relationship, the composite entity structure includes-as foreign keys – at least the primary keys of the tables that are to be linked.
  • 24. Relationships within the relational database
  • 25. Relationships within the relational database  The ENROLL table yields the required M:N to 1:M conversion. Observe that the composite entity represented by the ENROLL table must contain at least the primary keys of the CLASS and STUDENTS tables (CLASS_CODE and STU_NUM, respectively) for which it serves as a connector. Also note that the STUDENT and CLASS tables now contain only one row per entity. The ENROLL table contains multiple occurrences of the foreign key values, but those controlled redundancies are incapable of producing anomalies as long as referential integrity is enforced.
  • 26. Relationships within the relational database •As you can examine the figure, note that composite entity named ENROLL represents the linking table between STUDENT and CLASS.
  • 27. Relationships within the relational database •This figure shows the expanded ERM, including the expanded 1:M relationship between COURSE and CLASS
  • 28. Relationships within the relational database
  • 29. Prepared BY: •HARRY OCHINANG •JANE CATALLA •RONN RIVERA