Professional Documents
Culture Documents
Entity-Relationship Model
Wk 4 – Lec 1
Topics:
This model is good to design a database, which can then be turned into tables in
relational model.
ER models and data models are typically drawn at up to three levels of detail:
https://www.visual-paradigm.com/support/documents/vpuserguide/3563/3564/85378_conceptual,l.html
Entity-Relationship (ER) Model/ ER Diagram
• One or more physical model may be developed from each logical model.
• The physical models must show enough technology detail to produce and
implement the actual database.
Conceptual ERD models
A physical data model elaborates on the logical data model by assigning each
column with type, length, nullable, etc.
Components of Entity-Relationship (ER) Model/ ER Diagram
1. Entity
• Entity Set
• Weak entity
3. Relationship of Entities
• Degree of Relationship: Unary, Binary, Ternary
• Cardinality of the relationship:
• 1:1, 1: M, M: M
Components of Entity-Relationship (ER) Model/ ER Diagram
1. Entity
Entity Set – is the complete dataset of the entity. For entity Student, its entity
set is the complete dataset of all the students.
Components of Entity-Relationship (ER) Model/ ER Diagram
2. Attribute
Categories of Attributes:
• Simple
• Composite
• Derived attribute -- is calculated derived from another attribute,
such as age from a birthdate.
• Single-valued
• Multi-valued
Categories of Attributes:
Attribute Type Description Example
values that are atomic and cannot be
Simple broken down further birthdate
attribute that is made up of more address -> housenum, streetName,
Composite than one simple attribute barangay, townOrCity, province, et
not present in the whole database
management system, but can be
Derived derived from other attributes age from birthdate
Single-valued It has single Value Birthdate, gender/sex
Multi-valued It can have multiple values Hobbies
Attribute/s as Entity Keys
When an attribute or attributes can uniquely define an an entity in an entity set, then these attributes
can be called as entity key/s.
• Super key -- is a set of attributes (one or more) that together define an entity in an entity set.
• Candidate key -- is an attribute or set of attributes that uniquely identify an instance of an entity
or each record in a table. Some entities have more than one candidate key.
• Primary key -- is a candidate key that is most appropriate to become the main key for any table. It
is a key that can uniquely identify each record in a table. It should:
• NOT be NULL, and does NOT change its value over the life of each entity instance.
• Avoid intelligent-keys (stored data as part of a key such as a code). For example, a key where
the first two digits indicates a warehouse location would be a poor choice because the coding
scheme could change over time.
• Substitute single-attribute surrogate keys for large composite keys. A surrogate key can be a
system generated sequence of unique numbers.
Attribute/s as Entity Keys
Example:
The table containing the foreign key is called the child table, and the
table containing the candidate key is called the referenced or parent
table.
Components of Entity-Relationship (ER) Model/ ER Diagram
3. Relationship between Entities
It occurs when there are more than one entity. It is the logical association between
entities. Relationships are mapped with entities in various ways. Mapping cardinalities
define the number of association between two entities.
For example: A Teacher Entity is related to Student entity, because Teacher teaches the
students.
E-R Models are defined to represent the relationships into pictorial form to make it easier
for different stakeholders to understand.
Entity-Relationship (ER) Model/ ER Diagram
A unary/ recursive
relationship exists when an
association is maintained
within a single entity.
http://www.shsu.edu/~csc_tjm/summer2000/cs334/Chapter04/part1/Chap04-97.html
Degree of the Relationship between Entities
http://www.shsu.edu/~csc_tjm/summer2000/cs334/Chapter04/part1/Chap04-97.html
Degree of the Relationship between Entities
A ternary relationship exists when three entities are
associated.
To understand the relationship better or
to define rules around the model, we
should relate two entities and then derive
the third one.
http://www.shsu.edu/~csc_tjm/summer2000/cs334/Chapter04/part1/Chap04-97.html
Cardinality of Association/ Relationship
Cardinality expresses the specific number of instances or occurrences of an entity that can be
linked with the instances of another entity. It is the specific number of instances or occurrences of
an entity that participate in a relationship.
One-to-one (1:1)
• This is where one occurrence of an entity relates to only one occurrence in another entity.
• A one-to-one relationship rarely exists in practice, but it can.
• For example,
• an employee is allocated a company car
• A country has one capital city
• An employee/person is marries to an employee/person
Cardinality of Association
One-to-many (1: M)
A cardinality of 1:M involving 2 entities. This is A cardinality of 1:M involving a single entity. This
read as a department has many employee is interpreted as an employee manages many
employees
Cardinality of Association
Many-to-many (M: N)
• This is where many occurrences in an entity relate to many occurrences in another entity.
• For example:
• an employee may work on several projects at the same time and
• a project has a team of many employees.
Cardinality of Association
Many-to-many (M: N)
What is Generalization?
What is Specialization?
Aggregration is a process when relation between two entities is treated as a single entity.
1. https://www.w3schools.in/dbms/
2. https://www.studytonight.com/dbms/overview-of-dbms.php
3. https://www.quackit.com/database/tutorial/
4. https://beginnersbook.com/2015/04/dbms-introduction/
5. https://www.tutorialspoint.com/dbms/index.htm
6. https://www.lucidchart.com/pages/er-diagrams
7. https://www.visual-paradigm.com/support/documents/vpuserguide/3563/
3564/85378_conceptual,l.html
8. https://www.visual-paradigm.com/tutorials/
Thank you!
https://www.visual-paradigm.com/guide/data-modeling/
what-is-entity-relationship-diagram/
Topics:
References:
1. https://www.youtube.com/watch?v=NlGRINAJXrI
2. https://www.youtube.com/watch?v=PH17p5vORyk&t=51s
3. https://www.youtube.com/watch?v=NvrpuBAMddw
4. https://techdifferences.com/difference-between-e-r-and-relational-model-in-dbms.html
Learning outcomes:
Background:
• Relational Model was developed by Codd in 1970 along with the non-procedural method to query
the data from Relational Model.
• Relational Model represents data and relation among those data in the form of tables.
• Relational model is also called Record-based Model.
Physical data model represents how the model will be built in the database. A physical
database model shows all table structures, including column name, column data type, column
constraints, primary key, foreign key, and relationships between tables.