Sie sind auf Seite 1von 5

The Entity-Relationship Model of Data

The database design process:

 Requirements identification
 Conceptual design
 Logical design
 Physical design

Requirements gathering

 Complex task, implies knowing the problem and identifying stakeholder’s needs
 There are user, funcional, non-functional, hardware, software,…, requirements
 Gathering techniques include observation, questionaires, prototyping
 After the problem is known, it can be modeled and analyzed
 Requirements must be shared between all stakeholders, revised, negotiated,…
 They correspond to an interpretation of a reality, which can have multiple perspectives
 Most of the time they are interdisciplinary
o “client” can have a marketing, commercial, taxbasedinterpretation
o It is one of the most complex taks in a programming project
 Some errors are uncovered too late…in the implementation

Why a conceptual model?

 Requirements’ gathering implies:


o Several stakeholders
o They may not know each other’s reality and needs
 There is a need to
o Document what the stakeholders want
o Add clear requirements to the contract
o Review and track modifications
o Communicate with other teams
 For example with the Logical Design team
 Using only textual descriptions may be harder:
o Some words may be interpreted differently (”should”, “must”, “has”,…)
o Not practical to use dozens of text pages as reference material
o Not practical for collaborative work
o Even small projects need lots of text
 Graphical models were introduced as a result

The E-R Model

 1976: Chen Peter Pin-Shan published the EntityRelationship model (E-R)


 Basic concepts:
o Entities
o Relationships
o Attributes (for entities and relationships)
 Relationships may link:
o 1 entity type (unary relationship)
o 2 entity types (binaries)
o N entity types (N-aries)

Concepts

 Our world is made of Entities


 Entities can be grouped by type
o E.g., all clients are grouped in CLIENT
 Each entity has a unique identity
 An entity has properties
 An entity can be linked to other entities, through relationships1

E-R model

 Chen’s example:

 Deals only with static aspects of the world (entities, relationships and properties)
 Must be well documented
 Does not allow for the representation of dynamic aspects (dataflows)
 Easy to use, even by non-technical people, easy to translate to a database schema
 We’ll see later the mapping to the relational model is very easy
 It's a “semantic”, or “extended”, data model; no reference is made to physical aspects of data
 Is used to allow more information to be available
 Augments the semantic expressiveness
 Top-down methodology: from most abstract concepts to most specific
 There are several software tools to help build models
o They produce documentation, and help translate to the relational model

Concepts 1
 Entity: any Object in our world (eg: student, course,...). Entities have instances
 Property: data about a specific entity (eg: age, name, weight,...)
 Relationship: entity linking two or more entity types (eg: attends)
o A role can be defined for each end of a relationship
 Subtypes: student is a subtype of person

Concepts 2
 An entity is represented by a rectangl
 A set of the entity’s properties must have unique values (it is used as the identity)
o Can be a natural one (eg VAT Number) or artificial (eg a “code”)

Concepts (3)

 Some entities can only be identified using the ID of others


o Eg, “dependents” must use the “parents” ID (implies they are “unique” in the relation)
 They are called “weak entities”

Concepts (4)

 Some examples of weak entities:


o Sections for a given course; they don’t make sense if the course does not exists
o Course offerings for a given course
o A receipt for a given invoice (and client)
o An appointment envolving a patient and a doctor

Concepts (5)

 A relationship is represented by a losangle

 Entities may participate in several relationships


 A relationship has a degree (how many entity types are involved)
 A relationship has also a multiplicity

Drawing the diagram

 Entities and relationships can be identified from texts, interviews, and own knowledge
 In a textual description care should be taken when writing; subject translates to entities,
verbs generally translate to relationships
 Must use a coherent, clear writing style, free of ambiguities
o Easy to read, easy to understan
Our interpretation

 There's a relationship “attends” between the entities “student” and “course”


 That relationship is characterized by the attribute “date”
 The entities “student” and “course” have the attributes shown

Multiplicity

 Relationships have a “multiplicity”, which specifies how many elements of each entity can
participate in the relationship
 Eg, one student can only sign for only one degree
 A degree can have zero or N students
 It’s a (semantic) restriction
o It depends on laws, regulations, professional practices, practical restrictions

From the Sets:

 A student can sign for exactly 1 degree


 A degree can have 0 or N students
For each relationship we must identify the minimum and maximum multiplicity
Note: sometimes you'll read Cardinality, but it's a different concept (the number of elements
of a Set). Multiplicity it's a restriction on the number of instances

E-R diagram
Ternary relacionships
 Multiplicity must be represented in another way
 Given an occurrence of a pair of entities, how many of the other can be??

Some options

 The E-R model is subjective (but the world is also!)


 There is always more than one diagram for the same problem
o Depends on the experience of the analyst
 Common choices are about:
o To create entities or attributes?
o To create entities or relationships?

Examples

 A class is an entity or a relationship?


o It involves a TEACHER, SECTION, COURSE, ROOM, START_HOUR, DURATION
 An address is an entity or an attribute?
o It involves a STREET/AV, NUMBER, POSTCODE, PLACE

Das könnte Ihnen auch gefallen