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

P2-DataModel-ER Model

Uploaded by

simonkp.live
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

P2-DataModel-ER Model

Uploaded by

simonkp.live
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Data Models

Why is data modelling important?


 A comprehensive and optimized data model helps create a simplified, logical database that eliminates redundancy,
reduces storage requirements, and enables efficient retrieval.

 Underlying structure of a database is called Data Model.


 It defines the data elements and the relationships between the data elements. Data Models are used to show how data is
stored, connected, accessed and updated in the database management system.
 Here, we use a set of symbols and text to represent the information so that members of the organization can
communicate and understand it.
Data model Vs Data architecture
1. Data modeling focuses on the representation of the data while data architecture is concerned with what tools and
platforms to use for storing and analyzing it.
2. Data modeling is all about the accuracy of data while data architecture is about the infrastructure housing that data.
3. Data modeling is concerned with the reliability of the data, while data architecture is concerned with keeping the data
safe.
4. A data model is an attempted representation of reality, while data architecture is a framework of systems and logistics.
5. A data model represents a limited set of business concepts and how they relate to one another. Data architecture covers
the data infrastructure of the entire organization.
ER (Entity Relationship) Model

 Entity-relationship Data Modelling was introduced by Peter Chen in 1976.


 It is widely used model.
 It provides convenient graphical representation to view data elements , relationship and constraints.
 In ER modeling, the database structure is portrayed as a diagram called an entity-relationship diagram(ER
Diagram).
 This model consists of a collection of entities (Real word objects) and their relationships.
ER Model VS Relational Model

18 ER model Relational Model

Basic It's used to describe a set of objects It's used to represent a collection of tables as well
known as entities, as well as the as the relationships between them.
relationships between them.

Type It is a high-level or conceptual model. It is the implementation or representational model.

Components It represents components as Entity, It represents components as domain, attributes, and


Entity Type, and Entity Set. tuples.

Used By This model is helpful for those people This model is mostly famous among programmers.
who don't have any knowledge about
how data is implemented.

Relationship It is easy to understand the relationship Compared to ER model, it is easier to derive the
between entities. relation between tables in the Relational model.
Entity: It is a “thing” or “object” in the real world that is distinguishable from other objects.
-In terms of DBMS, an entities are described by a set of attributes or table.
Example:
-Account is one entity and acc_no and balance are the attributes of account entity.

Relationship: It is an association among entities.


Example:
A depositor relationship associates a customer with each account that she has.

Entity set
 It is a collection of entities of the same type which share similar properties.
For example:
- student: a group of students in a college.
- customer: All customers of a bank

 Entity sets do not need to be disjoint.


For example: A person entity may be an employee entity, a customer entity, both, or neither.
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.
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 weak 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 identifying relationship.
Attributes
• The entities are represented by a set of attributes.
• These are the descriptive properties of entities.

Example

• Each entity has a value for each of its attributes.


• For each attribute, there is a set of permitted values, called the domain or value-set.
For Example:
Student name might be the set of all text strings of a certain length
Types of attributes
The types of attributes in the Entity Relationship (ER) model are as follows −
1. Simple and composite attributes:
 Simple attributes are not divided into subparts and composite attributes can be divided into subparts(other
attributes).
2. Single-valued and Multivalued attributes
 Single-valued attributes have one value for a particular entity.
 Multivalued-attributes have multiple values for a particular entity.
Example:

3. Derived attribute:
• The attribute that can be derived from the values of other related attributes or entities.
For example:
age-can be calculate from Date-of-birth(base attribute) and current date.
Relationship:
 A relationship represents the association among the entities.
For example:

• ‘Enrolled in’ is a relationship type that exists between entity type Student and Course.
 In ER diagram, relationship type is represented by a diamond and connecting the entities with lines.
 A set of relationships of same type is known as relationship set.

 In the above relationship set depicts S1 is enrolled in C2, S2 is enrolled in C1 and S3 is enrolled in C3
Degree of Relationship:

 The number of different entity sets participating in a relationship set is called as degree of a
relationship set.
1. Unary Relationship –
When there is only ONE entity set participating in a relation, the relationship is called as unary
relationship. For example, one person is married to only one person.

2.Binary Relationship –
When there are TWO entities set participating in a relation, the relationship is called as binary relationship.
For example, Student is enrolled in Course.
3. n-ary Relationship –
 When there are n entities set participating in a relation, the relationship is called as n-ary relationship.
Constraints:
 Constraints are used for modeling limitations on the relations between entities.
 There are two types of constraints on the Entity Relationship (ER) model −
Mapping cardinality or cardinality ratio.
Participation constraints.
1. Mapping Cardinality:
 The number of times an entity of an entity set participates in a relationship set is known as cardinality.
 Cardinality can be of different types:
 One to one – When each entity in each entity set can take part only once in the relationship, the cardinality is
one to one.
Let us assume that a male can marry to one female and a female can marry to one male. So the relationship will be
one to one.
 Many to one –
 When entities in one entity set can take part only once in the relationship set and entities in other
entity set can take part more than once in the relationship set.

 Many to many – When entities in all entity sets can take part more than once in the
relationship cardinality is many to many.
2. Participation Constraint:
 It refers to whether an entity must participate in a relationship with another entity to exist
 Total Participation – Each entity in the entity set must participate in the relationship.
-Total participation is shown by double line in ER diagram.
EX: If each student must enroll in a course, the participation of student will be total.

 Partial Participation – The entity in the entity set may or may NOT participate in the relationship. If
some courses are not enrolled by any of the student, the participation of course will be partial.
 The diagram depicts the ‘Enrolled in’ relationship set with Student Entity set having total participation
and Course Entity set having partial participation.
Keys in ER diagrams

 A key/primary key is an attribute in ER diagrams whose values are distinct for each individual
entity in an entity set.
For example:
- for a student entity set Roll Number or Registration Number can be a key because these are unique for
each student entity.
Super Key
It is the attribute or set of attributes that can uniquely identify each entity in an entity set.
For Example:
• Customer_id of customer entity set.
• Combination of customer_id and customer_name of customer entity set but not customer_name.
Candidate Keys
It is the super key for which no proper subset is a super key. Such minimal super keys are called candidate
keys.
Extended E-R Features
 These features are needed for the complex database.
Specialization
Generalization
Aggregation
Specialization
 The process of designing sub groupings within an entity set is called specialization.
 It’s a top-down approach.
 In the E-R diagram specialization is represented by triangle components labeled ISA. The ISA relationship is
referred as superclass- subclass relationship.
 Examples:
Generalization
 It is the reverse process of specialization. It is a bottom-up approach.
 It converts subclasses to superclasses.
 This process combines a number of entity sets that share the same features into higher-level entity sets.
Aggregation
 Aggregation allows to indicate that a relationship set participates in another relationship set.
 The relation between two entities is treated as a single entity. In aggregation, relationship with its corresponding
entities is aggregated into a higher level entity.
 Example:

customer
Company

employee Work on dept

Borrower

Loan
Examples: Company ER Model
Examples:University Database
• The university offers one or more programs.
• A program is made up of one or more courses.
• A student must enroll in a program.
• A student takes the courses that are part of her program.
• A program has a name, a program identifier, the total credit points required to graduate, and the year it commenced.
• A course has a name, a course identifier, a credit point value, and the year it commenced.
• Students have given names, a surname, a student identifier, a date of birth, and the year they first enrolled.
• When a student takes a course, the year and semester he attempted it are recorded. When he finishes the course, a grade
(such as A or B) and a mark (such as 60 percent) are recorded.
• Each course in a program is sequenced into a year (for example, year 1) and a semester (for example, semester 1).
Entity Sets and Attributes:
Program: Name, program_id, creditPoints, YearCommenced
Course(weak entity set): Name,course_id, creditPoints, YearCommenced
Student: GivenNames, Surname, Student_Id, Date_of_Birth,YearEnrolled

Relationship Sets :

EnrollsIn: Total participation( many-to-one)of entity set(Student) in relationship EnrollsIn.


Contains: Relationship with weak entity set(Course) and total participation(many-to-one) of entity set(course)
Attempts: Relationship with student and course.

You might also like