The Entity-Relationship Model
By Stephen Bucaro
After you have a data model that meets the organizations business requirements,
the easiest way to transform that model into a relational database is to first transform
that model into an entity-relationship model.
An entity-relationship model consists of four components; entities, attributes,
identifiers, and relationships.
An entity is something that can be uniquely identified. An entity is a physical
object or a data object that can be distinguished separately from other physical
object or a data objects. An entity can be a physical object, such as a house or
a car, an event such as a transaction or an order, or a piece of data such as a
date or a price. An EMPLOYEE would be an example of an entity.
An attribute is an aspect, property, or parameter) that can be used to describe
an entity. Attributes of an EMPLOYEE entity might be NAME (one value might
be: Bob Sled), JOB TITLE (one value might be SALESPERSON).
Entities with common characteristics is called an entity class. EMPLOYEE
would be an entity class because there are multiple EMPLOYEEs with common
characteristics like NAME, SS Number, Job Title, Salary, etc. Any one instance of an
entity class is an entity instance. An example of an entity class would be
a particular EMPLOYEE, such as Bob Sled.
A relationship is how two (or more) entities relate to one another. For example
a company might have a SALESPERSON entity, a PRODUCT entity, and a CUSTOMER
entity. When a product is sold, these entities relate to each other through a
TRANSACTION relationship.
There are three kinds of relationships: one-to-one (1:1), one-to-many (1:N),
and many-to-many (N:M).
A one-to-one (1:1) relationship relates one instance of an entity class to one
instance of a second entity class. An example of a one-to-one relationship
would be a marriage. In a marriage, one husband can be married to one wife
(disregarding polygamy which in most countries is illegal).
A one-to-many (1:N) relationship relates one instance of an entity class to
multiple instances of a second entity class. An example of a one-to-many relationship
would be a driver. With a driver, one person can have many driver's licenses form
different countries or states.
A many-to-many (N:M) relationship relates multiple instances of one entity
class to multiple instances of a second entity class. A example of a many-to-many
relationship would be a music collection. With a music collection, multiple performers
can perform a song, and multiple songs can be performed by a single performer.
Another term for an (N:M) relationship is cardinality. Cardinality is the number
of entity classes in a relationship. You can indicate the minimum and maximum cardinality
as shown above. The diagram above indicates you can have at minimum one manager
for a department. You can also have a maximum of one manager for a department.
You can have a minimum of one manager for an employee, or a manager may have
zero employees under them.
As stated earlier, the reason for creating a entity-relationship model of an organizations
data is to ease the transformation into a relational database. In a relational database
a table with rows (records) and columns (fields), where at least one field is related to
another table in "one-to-one","one-to-many", or "many-to-many" relationship.
|