SlideShare a Scribd company logo
1 of 29
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

What's hot

Unit 3 slide (1)
Unit 3 slide (1)Unit 3 slide (1)
Unit 3 slide (1)
Lu Vivian
 
Adat dalam masyarakat malaysia dan
Adat dalam masyarakat malaysia danAdat dalam masyarakat malaysia dan
Adat dalam masyarakat malaysia dan
Tika Daud
 
HUBUNGAN ETNIK konsep perpaduan, integrasi & hub etnik
HUBUNGAN ETNIK konsep perpaduan,  integrasi & hub etnik  HUBUNGAN ETNIK konsep perpaduan,  integrasi & hub etnik
HUBUNGAN ETNIK konsep perpaduan, integrasi & hub etnik
Amin Upsi
 

What's hot (20)

Teori kedatangan Islam ke Tanah Melayu
Teori kedatangan Islam ke Tanah MelayuTeori kedatangan Islam ke Tanah Melayu
Teori kedatangan Islam ke Tanah Melayu
 
Data Modeling Basics
Data Modeling BasicsData Modeling Basics
Data Modeling Basics
 
2. Jurang Pendidikan
2.  Jurang Pendidikan2.  Jurang Pendidikan
2. Jurang Pendidikan
 
Unit 3 slide (1)
Unit 3 slide (1)Unit 3 slide (1)
Unit 3 slide (1)
 
Database concepts
Database conceptsDatabase concepts
Database concepts
 
Data dictionary
Data dictionaryData dictionary
Data dictionary
 
Pengenalan kepada pangkalan data
Pengenalan kepada pangkalan dataPengenalan kepada pangkalan data
Pengenalan kepada pangkalan data
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Hnp power-poiNT( Dato'Maharaja Lela-Pembunuhan Birch di Pasir Salak)
Hnp power-poiNT( Dato'Maharaja Lela-Pembunuhan Birch di Pasir Salak)Hnp power-poiNT( Dato'Maharaja Lela-Pembunuhan Birch di Pasir Salak)
Hnp power-poiNT( Dato'Maharaja Lela-Pembunuhan Birch di Pasir Salak)
 
Database Normalization by Dr. Kamal Gulati
Database Normalization by Dr. Kamal GulatiDatabase Normalization by Dr. Kamal Gulati
Database Normalization by Dr. Kamal Gulati
 
Database Administrator - Job Scope
Database Administrator - Job ScopeDatabase Administrator - Job Scope
Database Administrator - Job Scope
 
Adat dalam masyarakat malaysia dan
Adat dalam masyarakat malaysia danAdat dalam masyarakat malaysia dan
Adat dalam masyarakat malaysia dan
 
normaliztion
normaliztionnormaliztion
normaliztion
 
REKA BENTUK & TEKNOLOGI BAB 1
REKA BENTUK & TEKNOLOGI BAB 1REKA BENTUK & TEKNOLOGI BAB 1
REKA BENTUK & TEKNOLOGI BAB 1
 
HUBUNGAN ETNIK konsep perpaduan, integrasi & hub etnik
HUBUNGAN ETNIK konsep perpaduan,  integrasi & hub etnik  HUBUNGAN ETNIK konsep perpaduan,  integrasi & hub etnik
HUBUNGAN ETNIK konsep perpaduan, integrasi & hub etnik
 
Pembentangan Hikayat Merong Mahawangsa
Pembentangan Hikayat Merong MahawangsaPembentangan Hikayat Merong Mahawangsa
Pembentangan Hikayat Merong Mahawangsa
 
Tanggungjawab warganegara
Tanggungjawab warganegaraTanggungjawab warganegara
Tanggungjawab warganegara
 
DBMS & Data Models - In Introduction
DBMS & Data Models - In IntroductionDBMS & Data Models - In Introduction
DBMS & Data Models - In Introduction
 
2.1 sistem nombor perduaan
2.1 sistem nombor perduaan2.1 sistem nombor perduaan
2.1 sistem nombor perduaan
 
MPU3122 Cabaran Usaha Integrasi Nasional
MPU3122 Cabaran Usaha Integrasi NasionalMPU3122 Cabaran Usaha Integrasi Nasional
MPU3122 Cabaran Usaha Integrasi Nasional
 

Viewers also liked

Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
wmassie
 
Creating relationships with tables
Creating relationships with tablesCreating relationships with tables
Creating relationships with tables
Jhen Articona
 
Database Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity TypesDatabase Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity Types
aakanksha s
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
Kumar
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
koolkampus
 

Viewers also liked (20)

Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
Creating relationships with tables
Creating relationships with tablesCreating relationships with tables
Creating relationships with tables
 
Database Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity TypesDatabase Modeling Using Entity.. Weak And Strong Entity Types
Database Modeling Using Entity.. Weak And Strong Entity Types
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
Example : parallelize a simple problem
Example : parallelize a simple problemExample : parallelize a simple problem
Example : parallelize a simple problem
 
Data Models In Database Management System
Data Models In Database Management SystemData Models In Database Management System
Data Models In Database Management System
 
ISDD Database Structure N5
ISDD Database Structure N5ISDD Database Structure N5
ISDD Database Structure N5
 
Field Types
Field TypesField Types
Field Types
 
Erd optionality
Erd optionalityErd optionality
Erd optionality
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Relational database management system
Relational database management systemRelational database management system
Relational database management system
 
Database Validation
Database ValidationDatabase Validation
Database Validation
 
ISDD Media Types - File Compression
ISDD Media Types - File CompressionISDD Media Types - File Compression
ISDD Media Types - File Compression
 
ISDD Standard File Formats
ISDD Standard File FormatsISDD Standard File Formats
ISDD Standard File Formats
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 

Similar to Relationships within the relational database

Sql server ___________session2-data_modeling
Sql server  ___________session2-data_modelingSql server  ___________session2-data_modeling
Sql server ___________session2-data_modeling
Ehtisham Ali
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
Nikhil Deswal
 
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Anwar Patel
 
entity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptentity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.ppt
IRWANBINISMAILKPMGur1
 

Similar to Relationships within the relational database (20)

Sql server ___________session2-data_modeling
Sql server  ___________session2-data_modelingSql server  ___________session2-data_modeling
Sql server ___________session2-data_modeling
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
 
DATABASE DESIGN.pptx
DATABASE DESIGN.pptxDATABASE DESIGN.pptx
DATABASE DESIGN.pptx
 
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
 
Download different material from slide share
Download different material from slide shareDownload different material from slide share
Download different material from slide share
 
5e7ry754.pptx
5e7ry754.pptx5e7ry754.pptx
5e7ry754.pptx
 
entityrelationshipmodel.pptx
entityrelationshipmodel.pptxentityrelationshipmodel.pptx
entityrelationshipmodel.pptx
 
Structured system analysis and design
Structured system analysis and design Structured system analysis and design
Structured system analysis and design
 
Data Modeling Er
Data Modeling ErData Modeling Er
Data Modeling Er
 
Relational Model
Relational ModelRelational Model
Relational Model
 
The Relational Model
The Relational ModelThe Relational Model
The Relational Model
 
Data base lec3 (erd)
Data base lec3 (erd)Data base lec3 (erd)
Data base lec3 (erd)
 
Data Modeling
Data ModelingData Modeling
Data Modeling
 
Fundamentals of Database Management Systems 2nd Edition Gillenson Solutions M...
Fundamentals of Database Management Systems 2nd Edition Gillenson Solutions M...Fundamentals of Database Management Systems 2nd Edition Gillenson Solutions M...
Fundamentals of Database Management Systems 2nd Edition Gillenson Solutions M...
 
Data modeling
Data modelingData modeling
Data modeling
 
Create table relationships
Create table relationshipsCreate table relationships
Create table relationships
 
Create table relationships
Create table relationshipsCreate table relationships
Create table relationships
 
entity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.pptentity-relationship-diagram-chen-&-crow -model.ppt
entity-relationship-diagram-chen-&-crow -model.ppt
 
UNIT II DBMS.pptx
UNIT II DBMS.pptxUNIT II DBMS.pptx
UNIT II DBMS.pptx
 
09.01 normalization
09.01 normalization09.01 normalization
09.01 normalization
 

More from Janecatalla

More from Janecatalla (20)

Bedlibrary4
Bedlibrary4Bedlibrary4
Bedlibrary4
 
Bedlibrary6
Bedlibrary6Bedlibrary6
Bedlibrary6
 
Bedlibrary5
Bedlibrary5Bedlibrary5
Bedlibrary5
 
Bedlibrary4
Bedlibrary4Bedlibrary4
Bedlibrary4
 
Bedlibrary3
Bedlibrary3Bedlibrary3
Bedlibrary3
 
Bedlibrary2
Bedlibrary2Bedlibrary2
Bedlibrary2
 
Bedlibrary
BedlibraryBedlibrary
Bedlibrary
 
Lis124
Lis124Lis124
Lis124
 
My presentation-for-infolit-workshop1
My presentation-for-infolit-workshop1My presentation-for-infolit-workshop1
My presentation-for-infolit-workshop1
 
Pp lis
Pp  lisPp  lis
Pp lis
 
Object oriented database model
Object oriented database modelObject oriented database model
Object oriented database model
 
Jane catalla
Jane catallaJane catalla
Jane catalla
 
Catalla & cea
Catalla & ceaCatalla & cea
Catalla & cea
 
Dbms
DbmsDbms
Dbms
 
Indexing report
Indexing reportIndexing report
Indexing report
 
Permuted Title Index
Permuted Title IndexPermuted Title Index
Permuted Title Index
 
Indexing report
Indexing reportIndexing report
Indexing report
 
Jane iii
Jane iiiJane iii
Jane iii
 
Readers advisory services final
Readers advisory services finalReaders advisory services final
Readers advisory services final
 
Term paper counseling
Term paper counselingTerm paper counseling
Term paper counseling
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

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