Download presentation
Presentation is loading. Please wait.
Published byJoanna Higgins Modified over 9 years ago
1
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types Different Relationship Types in a Logical Relational Model
2
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1. Entity Types 1.1 Entity 1.1 Strong and Weak Entity 1.2 Representing Weak Entity 2. Binary Relationship Types 2.1 One-to-One Relationship 2.2 One-to-Many Relationship 2.3 Many-to-Many Relationship 2.4 Problem with Recursive Relationship 2.5 Other Problems for Relational Models Topics
3
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1. Entity Types 1.1 Entity 1.1 Strong and Weak Entity 1.2 Representing Weak Entity 2. Binary Relationship Types 2.1 One-to-One Relationship 2.2 One-to-Many Relationship 2.3 Many-to-Many Relationship 2.4 Problem with Recursive Relationship 2.5 Other Problems for Relational Models Topics
4
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1.1 Entity An entity is an object that exists and is distinguishable from other objects Example: specific person, company, event plant Entities have attributes Example: people have names and adresses An entity set is a set of entities of the same type that share the same properties. Example: set of all persons, companies, trees, holidays An entity is an object that exists and is distinguishable from other objects Example: specific person, company, event plant Entities have attributes Example: people have names and adresses An entity set is a set of entities of the same type that share the same properties. Example: set of all persons, companies, trees, holidays
5
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1.1 Example for Entity EmployeeNewOfKin Employee name salary position NewOfKin name phone
6
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1.2 Strong and Weak Entity Types Create a relation that includes all simple attributes of that entity. Has sufficient attributes to form a primary key is called a strong entity. Entity Strong Entity Weak Entity Lacks sufficient attributes to form a primary key. A weak entity is an entity that exists only if is related to a set of uniquely determined entities, which are called the owners of the weak entity. A strong entity set is a dominant entity A weak entity set is a subordinate entity
7
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1.3 Representing Weak Entity But every entity needs a key: What to do? - Must import attributes from strong entity set(s) - Importation is done via many-to-one relationship(s) - A weak entity set member is subordinate to the dominant entity(-ies) from strong entity set(s) providing (reliably) attributes to complete its key 1n The idea of strong and weak entity sets is related to the existence dependencies seen earlier.
8
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1. Entity Types 1.1 Entity 1.1 Strong and Weak Entity 1.2 Representing Weak Entity 2. Binary Relationship Types 2.1 One-to-One Relationship 2.2 One-to-Many Relationship 2.3 Many-to-Many Relationship 2.4 Problem with Recursive Relationship 2.5 Other Problems for Relational Models Topics
9
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 1 : 1 One-to-One Entity B Entity A N : M Many-to- Many Entity B 1 : N One-to-Many Entity B 2. Binary Relationship Types Entity A
10
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.1 One-to-One Binary Relationship Types Each employee has one or none locker One locker is owned by one employee 0..11..1 LOCKER EMPLOYEE 1:1 A 1:1 relationship cannot be used to identify parent and child entities in a relationship.
11
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.1 One-to-One Binary Relationship Types The key from one relation is placed in the other as a foreign key. It does not matter which table receives the foreign key. Foreign Key LOCKER EMPLOYEE 1:1 Emp_ID Locker_ID Emp_ID Locker_Desc Location Primary Key Foreign Key Primary Key EmpName
12
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.2 One-to-Many Binary Relationship Types Each employee is employed in only one Department Each department employs one ore more employees 1..11..N DEPARTMENT EMPLOYEE 1:N Entity on the ‘1..1 side‘ is designated the parent entity and entity on the ‘1..N side‘ is the child entity.
13
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.2 One-to-Many Binary Relationship Types Like a 1:1 relationship, a 1:N relationship is saved by placing the key from one table into another as a foreign key However, in a 1:N the foreign key always goes into the ‘1..N side’ Foreign Key DEPARTMENT EMPLOYEE 1:N Emp_ID Emp_Name Dep_ID Dep_Address Dep_Phone Primary Key Dep_ID
14
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.3 Many-to-Many Binary Relationship Types Each employee has one or more skills Each skill is “owned “ by one or more employees 1..* SKILL EMPLOYEE N:M
15
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.3 N:M ->: not capable with Rel. Model IdentifiesDescribes EMP_Skill Skill_ID Emp_ID To save a N:M relationship, a new relation has to be created: the intersection relation SKILL EMPLOYEE N:M Skill_ID Emp_ID Skill_Desc Emp_Name 1..1 1..n
16
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.4 Problem with Recursive Relationships TeamMember N:M SUPPORTER SUPORTEE Supports 0.. * TeamMember Support Supports Supported by 1.. 1 0.. *
17
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types 2.5 Other Problems for Relational Models Complex relationship types have to be removed Solution: Create new relation Foreign keys: Primary keys of the participated entities Primary key: Foreign keys that represent a many (1..*,0..*) relationship + perhaps other attributes of new relation Multi-valued attributes (mva) aren‘t allowed Solution: Create new relation Primary key: Combination of mva and primary key of the related entity
18
Database R.Fröhlich, M. Schaffer, J. Konicek Database Relationship Types THE END Thank you for attention !
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.