0% found this document useful (0 votes)
25 views

Database Notes Data Modeling and Entity Relationship Diagram

Modeling

Uploaded by

oniskatsande
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Database Notes Data Modeling and Entity Relationship Diagram

Modeling

Uploaded by

oniskatsande
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Data Modeling and Entity Relationship

Diagram (ERD)
Data Modeling
Data modeling is a technique to document a software system using diagrams and symbols. It
is used to represent communication of data.

The highest level of abstraction for the data model is called the Entity Relationship Diagram
(ERD). It is a graphical representation of data requirements for a database.

Entity Relationship Diagram


The main value of carefully constructing an ERD is that it can readily be converted into a
database structure.

There are three components in ERD.

 Entities: Number of tables you need for your database.


 Attributes: Information such as property, facts you need to describe each table.
 Relationships: How tables are linked together.

Uses of entity relationship diagrams


 Database design: ER diagrams are used to model and design relational databases, in
terms of logic and business rules (in a logical data model) and in terms of the specific
technology to be implemented (in a physical data model.) In software engineering, an
ER diagram is often an initial step in determining requirements for an information
systems project. It’s also later used to model a particular database or databases. A
relational database has an equivalent relational table and can potentially be expressed
that way as needed.
 Database troubleshooting: ER diagrams are used to analyze existing databases to
find and resolve problems in logic or deployment. Drawing the diagram should reveal
where it’s going wrong.
 Business information systems: The diagrams are used to design or analyze relational
databases used in business processes. Any business process that uses fielded data
involving entities, actions and interplay can potentially benefit from a relational
database. It can streamline processes, uncover information more easily and improve
results.
 Business process re-engineering (BPR): ER diagrams help in analyzing databases
used in business process re-engineering and in modeling a new database setup.
 Education: Databases are today’s method of storing relational information for
educational purposes and later retrieval, so ER Diagrams can be valuable in planning
those data structures.
 Research: Since so much research focuses on structured data, ER diagrams can play a
key role in setting up useful databases to analyze the data.

1
Entity
Entities are the basic objects of ERDs. These are the tables of your database. Entity are nouns
and the types usually fall into five classes: concepts, locations, roles, events or things.
For example: students, courses, books, campus, employees, payment, projects.

A specific example of an entity is called an instance. Each instance becomes a record or a


row in a table.
For example: the student John Smith is a record in a table called students.

Relationships
Relationships are the associations between the entities. Verbs often describe relationships
between entities. We will use Crow's Foot Symbols to represent the relationships. Three types
of relationships are discussed in this lab. If you read or hear cardinality ratios, it also refers to
types of relationships.

One to One Relationship (1:1)

A single entity instance in one entity class is related to a single entity instance in another
entity class.

For example:

 Each student fills one seat and one seat is assigned to only one student.
 Each professor has one office space.

One to Many Relationship (1:M)

A single entity instance in one entity class (parent) is related to multiple entity instances in
another entity class (child)

For example:

 One instructor can teach many courses, but one course can only be taught by one
instructor.
 One instructor may teach many students in one class, but all the students have one
instructor for that class.

Many to Many Relationship (M:M)

2
Each entity instance in one entity class is related to multiple entity instances in another entity
class; and vice versa.

For example:

 Each student can take many classes, and each class can be taken by many students.
 Each consumer can buy many products, and each product can be bought by many
consumers.

The detailed Crow's Foot Relationship symbols can be found here. Crow's Foot Relationship
Symbols

Many to many relationships are difficult to represent. We need to decompose a many to many
(M:M) relationship into two one-to-many (1:M) relationships.

Attributes
Attributes are facts or description of entities. They are also often nouns and become the
columns of the table. For example, for entity student, the attributes can be first name, last
name, email, address and phone numbers.

Primary Key

Primary Key* or identifier is an attribute or a set of attributes that uniquely identifies an


instance of the entity. For example, for a student entity, student number is the primary key
since no two students have the same student number. We can have only one primary key in a
table. It identify uniquely every row and it cannot be null.

Foreign key

A foreign key+ (sometimes called a referencing key) is a key used to link two tables together.
Typically you take the primary key field from one table and insert it into the other table
where it becomes a foreign key (it remains a primary key in the original table). We can have
more than one foreign key in a table.

An Example
Here's a sample crowsfoot diagram from a past offering of CS270 taught here at the
University of Regina. We've redrawn the diagrams using more modern diagramming tools,
but the content is unchanged. It uses a lot of ERD symbols, so you might want to use Vivek
Chawla's quick guide while you read it.

3
Quick Questions

How many entities are there in this diagram and what are they?
What are the attributes for entity STUDENT?
What is the primary key for STUDENT?
What is the primary key for COURSE?
What foreign keys do STUDENT and COURSE contain?

How to draw a basic ER diagram


1. Purpose and scope: Define the purpose and scope of what you’re analyzing or
modeling.
2. Entities: Identify the entities that are involved. When you’re ready, start drawing
them in rectangles (or your system’s choice of shape) and labeling them as nouns.
3. Relationships: Determine how the entities are all related. Draw lines between them to
signify the relationships and label them. Some entities may not be related, and that’s
fine. In different notation systems, the relationship could be labeled in a diamond,
another rectangle or directly on top of the connecting line.
4. Attributes: Layer in more detail by adding key attributes of entities. Attributes are
often shown as ovals.
5. Cardinality: Show whether the relationship is 1-1, 1-many or many-to-many.

4
Cardinality
Defines the numerical attributes of the relationship between two entities or entity sets.

Different types of cardinal relationships are:

 One-to-One Relationships
 One-to-Many Relationships
 May to One Relationships
 Many-to-Many Relationships

1.One-to-one:

One entity from entity set X can be associated with at most one entity of entity set Y and vice
versa.

Example: One student can register for numerous courses. However, all those courses have a
single line back to that one student.

5
2.One-to-many:

One entity from entity set X can be associated with multiple entities of entity set Y, but an
entity from entity set Y can be associated with at least one entity.

For example, one class is consisting of multiple students.

3. Many to One

More than one entity from entity set X can be associated with at most one entity of entity set
Y. However, an entity from entity set X may or may not be associated with more than one
entity from entity set X.

For example, many students belong to the same class.

4. Many to Many:

One entity from X can be associated with more than one entity from Y and vice versa.

For example, Students as a group are associated with multiple faculty members, and faculty
members can be associated with multiple students.

6
ERD symbols and notations
There are several notation systems, which are similar but vary in a few specifics.

Chen notation style

7
8
9
10
11
12
13

You might also like