Database Systems

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Practical 4: Entity relationship model and entity-relationship diagrams

Objective
In this Lab students will learn about Entity relationship models and entity-relationship diagrams.

Introduction
Entity Relationship Model (ER Modelling) is a graphical approach to database design. It is a
high-level data model that defines data elements and their relationship for a specified software
system. An ER model is used to represent real-world objects.

What is an 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, ER diagrams help
to explain the logical structure of databases. ER diagrams are created based on three basic
concepts: entities, attributes and relationships. ER Diagrams contain different symbols that use
rectangles to represent entities, ovals to define attributes and diamond shapes to represent
relationships.

At first look, an ER diagram looks very similar to the flowchart. However, ER Diagram
includes many specialized symbols, and its meanings make this model unique. The purpose of
ER Diagram is to represent the entity framework infrastructure

ER Diagrams Symbols & Notations

Entity Relationship Diagram Symbols & Notations mainly contains three basic symbols
which are rectangle, oval and diamond to represent relationships between elements,
entities and attributes. There are some sub-elements which are based on main elements in
the ERD Diagram. ER Diagram is a visual representation of data that describes how data is
related to each other using different ERD Symbols and Notations.
Following are the main components and its symbols in ER Diagrams:

 Rectangles: This Entity Relationship Diagram symbol represents entity


types
 Ellipses: Symbol represent attributes
 Diamonds: This symbol represents relationship types
 Lines: It links attributes to entity types and entity types with other
relationship types
 Primary key: attributes are underlined
 Double Ellipses: Represent multi-valued attributes

ER Diagram Symbols

Crows foot notation guide


https://www.vertabelo.com/blog/crow-s-foot-notation/

Lab Task 1

Scenario: Online Bookstore

You've been tasked with designing a database for an online bookstore that sells books
to customers. The bookstore has multiple book categories and a large number of
customers who can place orders. In order to model this system using an ERD, we can
start by identifying the entities, attributes, and relationships that are involved.

Here are the main entities involved:


1. Book: Represents a book in the bookstore. Contains attributes such as title,
author, ISBN, and price.

2. Category: Represents a category or genre of books in the bookstore.


Contains attributes such as name and description.

3. Customer: Represents a customer who has registered with the bookstore.


Contains attributes such as name, address, and email.

4. Order: Represents an order placed by a customer. Contains attributes


such as order date and total price. Also has a foreign key reference to the
Customer entity, indicating which customer placed the order.

5. Book_Category: Represents the many-to-many relationship between


books and categories. Contains foreign key references to both the Book
and Category entities.

6. Order_Book: Represents the many-to-many relationship between orders


and books. Contains foreign key references to both the Order and Book
entities.

Relationships:
 One book can belong to multiple categories (Many-to-Many).

 One category can have multiple books (One-to-Many).

 One customer can place multiple orders (One-to-Many).

 One order can contain multiple books (One-to-Many).

Lab Task 2

Design a database system for a university. The university has multiple departments, each
offering several courses. Students enroll in courses offered by these departments. Professors
teach these courses. Each course has multiple assessments (exams, assignments, etc.), and
students receive grades for these assessments. Students may also belong to various clubs and
organizations within the university. Clubs organize events and have members. Design an Entity-
Relationship Diagram (ERD) to represent the university system, considering the entities,
relationships, and attributes involved.

You might also like