0% found this document useful (0 votes)
16 views4 pages

Introduction To ER Diagrams: Entity-Relationship Diagram (ERD) Tutorial

An Entity-Relationship Diagram (ERD) visually represents a database structure, showcasing entities, attributes, and relationships essential for designing relational databases. Key components include strong and weak entities, various types of attributes, and relationships categorized as one-to-one, one-to-many, or many-to-many. The document also provides an example of a library system ERD and concludes by emphasizing the importance of ERDs in ensuring database integrity and efficiency.

Uploaded by

Romeo Balcita
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

Introduction To ER Diagrams: Entity-Relationship Diagram (ERD) Tutorial

An Entity-Relationship Diagram (ERD) visually represents a database structure, showcasing entities, attributes, and relationships essential for designing relational databases. Key components include strong and weak entities, various types of attributes, and relationships categorized as one-to-one, one-to-many, or many-to-many. The document also provides an example of a library system ERD and concludes by emphasizing the importance of ERDs in ensuring database integrity and efficiency.

Uploaded by

Romeo Balcita
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Entity-Relationship Diagram (ERD) Tutorial

R. Balcita

Introduction to ER Diagrams
An Entity-Relationship Diagram (ERD) is a visual representation of a database structure that
depicts entities, attributes, and relationships among data. ERDs are essential in designing
relational databases before implementation.

Key Components of an ER Diagram


1. Entities

An entity is a real-world object or concept that stores data. Entities can be:

 Strong Entity: Has a primary key (e.g., Student, Course, Employee).


 Weak Entity: Depends on another entity and lacks a primary key (e.g., Order Items in an
Invoice).

� Notation: Represented as rectangles in ERDs.

Example:
� Student
� Course

2. Attributes

Attributes describe the properties of an entity. They can be:

 Simple Attribute: Cannot be divided further (e.g., Name, Age).


 Composite Attribute: Can be broken down (e.g., Full Name → First Name, Last Name).
 Derived Attribute: Computed from other attributes (e.g., Age from Date of Birth).
 Multivalued Attribute: Can have multiple values (e.g., Phone Numbers).

� Notation: Represented as ovals connected to an entity.

Example:
� Student → (Student_ID, Name, DOB, Phone)
3. Relationships

Relationships define the association between entities. They are categorized into:

 One-to-One (1:1): Each entity instance is related to at most one instance of another entity.
 One-to-Many (1:M): One entity is related to multiple instances of another entity.
 Many-to-Many (M:N): Multiple instances of one entity relate to multiple instances of another.

� Notation: Represented as diamonds between entities.

Example:
� Student (1:M) � Enrolled In � Course

4. Keys in ERD

 Primary Key (PK): A unique identifier for an entity.


 Foreign Key (FK): Links one entity to another.
 Candidate Key: A possible PK, but only one is chosen.

� Notation: PK is underlined in entity tables.

Example:
� Student (Student_ID [PK], Name, DOB)
� Course (Course_ID [PK], Course_Name)

Example of an ERD
Scenario: A Library System

A library has Students who borrow Books. Books belong to different Categories.

ERD Representation

1. Entities:
o � Student (Student_ID, Name, Email)
o � Book (Book_ID, Title, Author, ISBN)
o � Category (Category_ID, Category_Name)
o � Borrow (Transaction_ID, Borrow_Date, Return_Date)
2. Relationships:
o Student (1:M) Borrow (M:1) Book
o Book (M:1) Category

� ER Diagram Sketch (Text-based Representation)

pgsql
CopyEdit
[STUDENT] -----< (BORROW) >----- [BOOK] -----< (CATEGORY)
|PK Student_ID |PK Transaction_ID |PK Book_ID
| Name | Borrow_Date | Title
| Email | Return_Date | Author

Quiz: Test Your ERD Knowledge!


1. Which of the following is NOT a type of attribute in an ERD?
a) Composite Attribute
b) Derived Attribute
c) Logical Attribute
d) Multivalued Attribute
2. In an ER Diagram, what shape represents a relationship?
a) Rectangle
b) Oval
c) Diamond
d) Triangle
3. Which relationship type means that a single entity instance is associated with
multiple instances of another entity?
a) One-to-One (1:1)
b) One-to-Many (1:M)
c) Many-to-Many (M:N)
d) None of the above
4. What does a Foreign Key (FK) do in an ERD?
a) Ensures data redundancy
b) Links one entity to another
c) Acts as a unique identifier for a table
d) Represents a weak entity
5. In a Library ERD, if a Book can belong to multiple Categories and each Category
can contain multiple Books, what type of relationship is this?
a) One-to-One
b) One-to-Many
c) Many-to-Many
d) None of the above

Conclusion
An ER Diagram is crucial in designing a structured and efficient database. It helps in identifying
entities, attributes, relationships, and keys to avoid redundancy and improve database
integrity.

You might also like