Assignment 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

ER Diagram

ER Diagram stands for Entity Relationship Diagram, also known as ERD is a diagram that
displays the relationship of entity sets stored in a database. In other words, EtR diagrams help to
explain the logical structure of databases. ER diagrams are created based on three basic concepts:
entities, attributes and relationships.
1. One to one relationship with ER Diagram:
 When only one instance of an entity is associated with the relationship, it is marked as
'1:1'. Only one instance of each entity should be associated with the relationship. It
depicts one-to-one relationship. For example- a student has 1 Contact Info and one
Contact Info is associated with one Student only.
Here, we can reduce relationship (has) table and we can link Student and Contact Info
table using foreign key as shown in below;

Table name / Entity : Student


Std_id First_name Last_name DOB
101 Geeta Thapa 2000 April
10
102 Ram Chetri 1995 May
7

Table Name / Entity : Contact Info

Contact_id Address Phone Std_id


1 Kalanki 98765433224 102
2 Thapathali 08767654433 101

In this example, the key field in each table, Student ID, is designed to contain unique values. In the
Students table, the Student ID field is the primary key; in the Contact Info table, the Student ID
field is a foreign key.
This relationship returns related records when the value in the Student ID field in the Contact Info
table is the same as the Student ID field in the Students table.

2. One to Many relationship with ER diagram:


When more than one instance of an entity is associated with a relationship, it is marked as
'1: M'. Only one instance of entity on the left and more than one instance of an entity on
the right can be associated with the relationship. It depicts one-to-many relationship. For
example- Single customer can place different orders but different orders can be placed by
single customer.
Here, we reduce relationship (has) table and we can link Customer and Order table using
foreign key as shown in below;

Table name/ Entity : Customer


Customer_id First_name Last-name Phone Address
202 Sita Pokharel 9841565203 Sitapaila
203 Mina Adhikari 9849683198 Balaju

Table name/ Entity : Order


Order_id Order_items Rate Customer-id
13 Momo 180 203
14 Chowmein 150 203

In this example the primary key field in the Customers table, Customer ID, is designed to contain
unique values. The foreign key field in the Orders table, Customer ID, is designed to allow
multiple instances of the same value.
This relationship returns related records when the value in the Customer ID field in the Orders
table is the same as the value in the Customer ID field in the Customers table.

3. Many to one relationship with ER diagram:


When more than one instance of entity is associated with the relationship, it is marked as
'N:1'. More than one instance of an entity on the left and only one instance of an entity on
the right can be associated with the relationship. It depicts many-to-one relationship. For
example- many students can study in a single college but a student cannot study
in many colleges at the same time.

Table name / Entity: Student


Student_id First_name Last_name Address Phone DOB College_id
401 Rina Shrestha Ktm 01428858 200 1011
May 21
402 Hari Sapkota Kalanki 984156377 1988 1011
7 January
3

Table name / Entity: College


College_id College_name Address Faculty
1011 ABC Sitapaila HM
1043 ERW Balaju IT

In this example the primary key field in the College table, College ID, is designed to contain
unique values. The foreign key field in the Student table, Student ID, is designed to allow multiple
instances of the same value.
This relationship returns related records when the value in the College ID field in the Student table
is the same as the value in the College ID field in the College table.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy