0% found this document useful (0 votes)
23 views31 pages

Data Modeling (Week 2)

Uploaded by

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

Data Modeling (Week 2)

Uploaded by

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

DATA MODELING

PREPARED BY: JAY-LOURD E. CALLUENG


OBJECTIVES
AT THE END OF THIS TOPIC, STUDENTS WILL BE ABLE TO:
-Define and explain the key components of the ER Model
-Construct ER diagrams
-Analyze and apply ER modeling concepts
The Entity-Relationship Model (ER Model) is a
conceptual model for designing a databases. This
model represents the logical structure of a database,
including entities, their attributes and relationships
between them.

•Entity: An objects that is stored as data such


as Student, Course or Company.
•Attribute: Properties that describes an entity such
as StudentID, CourseName.
•Relationship: A connection between entities such as
"a Student enrolls in a Course".
ENTITY RELATION MODEL
Why Use ER Diagrams In DBMS?
•ER diagrams represent the E-R model in a
database, making them easy to convert into
relations (tables).
•These diagrams serve the purpose of real-world
modeling of objects which makes them intently
useful.
•They visually model data and its relationships,
making complex systems easier to understand.
SYMBOLS USED IN ER
MODEL
ER Model is used to model the logical view of the system from a data perspective which
consists of these symbols:
Rectangles: Rectangles represent entities in the ER Model.
Ellipses: Ellipses represent attributes in the ER Model.
Diamond: Diamonds represent relationships among Entities.
Lines: Lines represent attributes to entities and entity sets with other relationship types.
Double Ellipse: Double ellipses represent multi-valued Attributes, such as a student's multiple
phone numbers
Double Rectangle: Represents weak entities, which depend on other entities for identification.
WHAT IS AN ENTITY?
An Entity represents a real-world object, concept or thing about
which data is stored in a database. It act as a building block of a
database.
Tables in relational database represent these entities.
Example of entities:
Real-World Objects: Person, Car, Employee etc.
Concepts: Course, Event, Reservation etc.
Things: Product, Document, Device etc.
WHAT IS AN ENTITY SET?
An entity refers to an individual object of an entity type, and the collection of
all entities of a particular type is called an entity set.
For example, E1 is an entity that belongs to the entity type "Student," and the
group of all students forms the entity set.
In the ER diagram below, the entity type is represented as:
We can represent the entity sets in an ER Diagram
but we can't represent individual entities because an
entity is like a row in a table, and an ER diagram
shows the structure and relationships of data, not
specific data entries (like rows and columns).
An ER diagram is a visual representation of the data
model, not the actual data itself.
WHAT IS A STRONG ENTITY?
A strong entity is not dependent on any other entity
in the schema.
A strong entity will always have a primary key.
Strong entities are represented by a single rectangle.
The relationship of two strong entities is represented
by a single diamond. Various strong entities, when
combined together, create a strong entity set.
WHAT IS A WEAK ENTITY?
A weak entity is dependent on a strong entity to ensure
its existence.
Unlike a strong entity, a weak entity does not have any
primary key. It instead has a partial discriminator key.
A weaken entity is represented by a double rectangle.
The relation between one strong and one weak entity is
represented by a double diamond. This relationship is also
known as an identifying relationship.
DIFFERENCE BETWEEN STRONG AND
WEAK ENTITY
MORE
Example:
A company may store the information of dependents (Parents,
Children, Spouse) of an Employee. But the dependents can't exist
without the employee. So dependent will be a Weak Entity Type and
Employee will be identifying entity type for dependent, which means
it is Strong Entity Type.
ATTRIBUTES
Attributes are the properties that define the entity type.
For example, for a Student entity Roll_No, Name, DOB, Age,
Address, and Mobile_No are the attributes that define
entity type Student. In ER diagram, the attribute is
represented by an oval.
TYPES OF ATTRIBUTES
1. Key Attribute
The attribute which uniquely identifies each entity in the
entity set is called the key attribute.
For example, Roll_No will be unique for each student. In ER
diagram, the key attribute is represented by an oval with an
underline.
2. Composite Attribute
An attribute composed of many other attributes is called a composite attribute.
For example, the Address attribute of the student Entity type consists of Street,
City, State, and Country. In ER diagram, the composite attribute is represented
by an oval comprising of ovals.
3. Multivalued Attribute
An attribute consisting of more than one value for a given entity.
For example, Phone_No (can be more than one for a given student).
In ER diagram, a multivalued attribute is represented by a double
oval.
4. Derived Attribute
An attribute that can be derived from other attributes of the entity
type is known as a derived attribute. e.g.; Age (can be derived from
DOB). In ER diagram, the derived attribute is represented by a
dashed oval.
The Complete Entity Type
Student with its Attributes
can be represented as:
RELATIONSHIP TYPE AND
RELATIONSHIP SET
A Relationship type represents the association between entity types.
For example, ‘Enrolled in’ is a relationship type that exists between
entity type Student and Course. In ER diagram, the relationship type
is represented by a diamond and connecting the entities with lines.
A set of relationships of the same type is known as a
relationship set.
The following relationship set depicts S1 as enrolled in C2, S2
as enrolled in C1, and S3 as registered in C3.
TYPES OF RELATIONSHIPS
One-to-One Relationship
Each record in Table A is related to exactly
one record in Table B, and vice versa.
Example: A person and their passport. Each
person can have only one passport, and
each passport is assigned to only one
person.
You can use a primary key in one table that
also serves as a foreign key in the other
table.
One-to-Many Relationship
A single record in Table A can be related to multiple
records in Table B, but each record in Table B is
related to only one record in Table A.
Example: A customer and their orders. A customer
can place multiple orders, but each order is
associated with only one customer.
The primary key of Table A is used as a foreign key in
Table B.
Many-to-Many Relationship
Definition: Multiple records in Table A can
relate to multiple records in Table B.
Example: Students and courses. A student
can enroll in multiple courses, and each
course can have multiple students.
This is typically implemented using a
junction table (or associative entity) that
contains foreign keys from both Table A
and Table B.
PK AND FK
Primary Key
A unique identifier for each record in a table. It ensures that no two
records can have the same primary key value.
Example: A user ID in a users table.
Foreign Key
A field (or a collection of fields) in one table that uniquely identifies a row
of another table. It establishes a link between the two tables.
Example: The customer ID in an orders table, which refers back to the
primary key in the customers table.
PK AND FK
Definition of Terms
AutoNumber – A field that automatically generates incremental numbers; usually used as the Primary
Key (PK).
Primary Key (PK) – A unique identifier for each record in a table; cannot be duplicate or null.
Foreign Key (FK) – A field that links to the Primary Key of another table; used to establish relationships.
One-to-One Relationship – A record in one table corresponds to only one record in another table.
One-to-Many Relationship – A record in one table can be related to many records in another table.
Many-to-Many Relationship – Many records in one table can be related to many records in another
table (often through a junction table).
Junction Table – A table used to handle Many-to-Many relationships by linking two tables together
(e.g., Student_Course).
DRILLS

You might also like