New Page 1
Welcome to basicsofcomputer.com
 

Share This Free Knowledge With Your Friends:

Home » Transformation of E-R Model into Relational Data Model » Types of Relationships in Database and Representing Relationship » Representing Unary Relationship in DBMS

Representing Unary Relationship in DBMS:

Unary or recursive relationship is a relationship between the instances of a single entity type. Recursive relationship is also further divided into 1:1, 1:N, and M:N.

(1) Representing One-to-One (1:1) Unary Relationship

The one-to-one (1:1) unary relationship is represented in the similar way as 1:1 for binary relationship. For example, recursive relationship is shown below.

In the above relationship, an employee may work under another employee. Each employee may or may not work under another employee, and each employee can not work under more than one employee. Therefore, cardinality is optional zero or one in both directions. For example:

  • Peon works under Clerk.
  • Clerk works under Assistant Manager.
  • Assistant Manager works under Manager.
  • Manager works under General Manager and so on.

There is one-to-one relationship in the recursive entity "EMPLOYEE". The 1:1 relationship of the above entity type can be converted into a relation. The primary key of the "EMPLOYEE" relation is the same as for the entity type, but a foreign key is added to the relation that references the primary key values. Suppose foreign key is taken as "work-under". Domain of primary key and foreign key is same. This foreign key is known as recursive foreign key. The "EMPLOYEE" relation is represented as:

EMPLOYEE (Emp-ID, Name, Designation, Work-under)

Emp-ID Name Designation Work-under
Pmd-125 A Peon Pmd-147
Pmd-147 M Clerk Pmd-128
Pmd-128 N Assistant Manager Pmd-129
Pmd-129 S Manager Pmd-130
Pmd-131 H General Manager  

The above table shows that "H" is working independently.

(2) Representing One-to-Many (1:N) Unary Relationship

The one-to-many (1:N) recursive relationship is shown in figure below. This relationship is named 'Manages' that associates employees of an organization with another employee who is their manager.

The 1 :N relationship of the above entity type (i.e. EMPLOYEE) can be converted into relation. The primary key of the EMPLOYEE relation is the same as for the entity type, but a foreign key is added to the relation that references the primary key values. The EMPLOYEE relation is written as:

EMPLOYEE (Emp-ID, Name, Address, Manager-ID)

In the EMPLOYEE relation, Manager-ID is the recursive foreign key that has same domain as primary key. When the data is stored into the relation, one row represents the manager, and the other rows represent those who have been managed by manager. The manager row takes the role of the parent, and the managed rows take the role of the child. We place the key of the parent in the child.

Emp-ID Name Address Manager-ID
AD-023 B City: L Ad-023
IT-025 M City: L AD-023
AC-021 F City: R AD-023
Ad-045 E City: H AD-023

(3) Representing Many-to-Many (M:N) Unary Relationship

Now consider M:N unary relationship. The Treated-By relationship in the figure below represents the situation in which doctors give treatments to each other. Although this entity has one relation. After converting this entity into a relation, we must have to create a separate relations to represent the M:N relationship. It means that we have to create a new intersection relation to show the related rows. The name of the doctor in the first relation is one who provided the treatment, and the name of the doctor in the second relation is one who received the treatment.

The Doctor and Treatment relations are:

DOCTOR (Doctor-ID, Name, Address)

TREATMENT (Doctor-ID, Patient)

The primary key of the DOCTOR relation is "Doctor-ID" and the primary key of the new relation is a composite key that consists (Doctor-ID, Patient) attributes. These attributes have the same domain as primary key domain.

Representing Binary Relationship

Representing Unary Relationship

Representing Ternary Relationship

Representing IS-A Relationship

Relevant Articles:

Steps to Convert E-R Model into Relational database design
Representing Entities
Types of Relationships in Database and Representing Relationship
Normalize the Relation
Representing Entities Case Study
 
New Page 1

Basic Computer Science

   
» The Age of Information

» Types of Computer and Digital Age

» Input and Output Devices

» Storage Devices Of Computer

» Central Processing Unit

» Software: The Power Behind The Power

» Data Communication and Computer Networks

» The Nature Of Information

» The System Theory

» Transaction Processing System (TPS) and Management Information System (MIS)

» Decision Support System (DSS) and Executive Support System (ESS)

» Expert System (ES) and Office Information System (OIS)

 

Operating Systems

   
» Introduction to Operating System

» Introduction to Process Management

» Threads and CPU Scheduling

» Process Synchronization in Operating System

» Deadlocks

» Memory Management in Operating System

» Virtual Memory in Operating System

» File System Management in Operating System

» I/O and Device Management

» Security

» Linux Operating System

 

Database Management System

   
» Introduction to Database Systems

» Database System Architecture

» Database Administration and Database Development Process

» The Entity-Relationship Model

» Semantic Object Model

» Logical Database Design and Relational Data Model

» Normalization in Database

» Transformation of E-R Model into Relational Data Model

» Representing Semantic Object Model and Types of Semantic Object Model

» Physical Database Design

» Introduction to Structured Query Language (SQL)

» Implementation of Relational Database and Database Application Design

» Client Server Database Systems & Open Database Connectivity (ODBC)

 

Questions and Answers

   
» Basics of Information Technology

» Computer Architecture

» Data Communication

» Information Networks

» Fundamentals of the Internet

» Application and Uses of Computer

» Security, Copyright and The Law

» Windows Operating Systems

» Spreadsheet Software

» Process Management in CPU

» CPU Scheduling

» Process Synchronization

» Deadlocks

» Memory Management

» Database Systems

» Database System Architecture

» Database Administration and Database Development Process
 
 
New Page 1
 

Home                Dictionary                 Contact us                   About us                    Privacy policy                  Link to us                   Advertise

Copy right ©  2012