Вы находитесь на странице: 1из 2

entity-relationship (E-R) entity-relationship data model

data model † introduced by Peter Chen in March 1976


† high-level, conceptual, semantic data model
† based on a perception of a real world that consists of a
set of basic objects called entities, and of relationships
among these objects
† used to depict the overall structure of a database in a
graphical form known as an E-R diagram

entity-relationship data model entity-relationship data model


† basic building blocks: † basic building blocks:
„ entity „ relationship
† a “thing” or object in the real world that is † an “association” among several (not necessarily
distinguishable from all other objects distinct) entities (e.g., an employee works for a
† may have physical existence (e.g., employee, department, a student is enrolled in a course)
student) or be conceptual (e.g., a job, a college
course) in nature † may also have attributes (e.g., job designation
† has particular properties, a.k.a. attributes, that of employee for specific departments, enrollment
describe it (e.g., employee name, salary, student date of student for a given subject)
ID number) † relationship type/set: a set of relationship
† entity type/set: a set of entities that share the instances that have the same characteristics
same attributes; individual entities are called
entity instances

Example: E-R Diagram


(empid, ename, job, hiredate, (date, hourlyrate)
address, bday, age) (projid, projname, status)
entity types/sets
EMPPROJ
EMP PROJECT
(0, N) (1, N) † collection of entity instances of a particular entity type,
(1, 1) (0, N) characterized by a common set of attributes
(1, 1) † types of attributes:
PROJHEAD „ simple vs. composite
supervisor
supervisee

(0, 1) (1, 1)
PROJDEPT
„ single-valued vs. multi-valued
„ stored (or, base) vs. derived
† key attributes: attributes whose values are distinct for
each individual entity instance (establishes a uniqueness
SUPERVISION
(0, N) constraint on entities)
† a simple attribute is associated with a domain or value
set, specifying the valid values for the attribute
NOTE: DEPT
EMP.ename (lastname, firstname, middlename) -> composite † composite multi-valued attributes may be nested (a.k.a.
{EMP.address} -> multi-valued: up to two addresses per
(deptid, dname)
complex attributes)
employee
EMP.age -> derived: current date - EMP.bday (in years)

1
relationship types/sets relationship types/sets
† a relationship type, R, among entity types E1, E2,… En † degree of a relationship type:
defines a set of association among entities from these „ number of entity types associated by the relationship
types (referred to as the participating entity types); „ may be one of unary (a.k.a. recursive relationships),
each relationship instance in R represents an association binary, ternary, … n-ary
which includes exactly one entity instance from each
participating entity type
† a relationship type is characterized by its degree and its
structural constraints; furthermore, a relationship type
may also have attributes
† one or more entity types may be associated via one or
more distinct relationship types

Structural Constraints

relationship types/sets optional M:N obligatory

† structural constraints on a relationship type:


„ cardinality ratio or mapping cardinality
† indicates the number of relationship instances that
an entity instance may participate in
† for binary relationships, the common mapping
cardinalities are 1:1 (one-to-one), 1:N (one-to-
many), or M:N (many-to-many)
„ participation constraint
† indicates whether the existence of an entity (0,N) (1,N)
instance depends on its being related to another
entity instance via the relationship
EMP EMPPROJ PROJECT
† may be total (or obligatory) or partial (or optional)

Structural Constraints

optional 1:1 obligatory

(0,1) (1,1)

EMP PROJHEAD PROJECT

Вам также может понравиться