Attributes and Keys
Attributes are characteristics of entities that provide
descriptive detail about them. A particular instance (or
occurrence) of an attribute within an entity or relationship
is called an attribute value. Attributes of an entity such as
Employee may include emp-id, emp-name, emp-address,
phone-no, fax-no, job-title, and so on. The attribute con-
struct is an ellipse with the attribute name inside (or
oblong as shown in Figure 2.2).
The attribute is connected
to
the entity it characterizes.
There are two types of attributes: identifiers and
descriptors. An identi
fier (or key) is used to uniquely determine
an instance of an entity. For example, an identifier or key of
Employ ee is emp-id; each instance of Emplo yee has a different
value for emp-id, and thus there are no duplicates of emp-id in
the set of Employees. Key attributes are underlined in the ER
diagram, as shown in Figure 2.2.
We note,
briefly, that you
can have more than one identifier (key) for an entity, or you
can have a set of attributes that compose a key (see the “S uper -
keys, Candidate Keys, and Primary Keys ” section in Chapter 6).
A descriptor (or nonk
ey attribute) is used to specify a non-
unique characteristic of a particular entity instance. For
example, a descriptor of Employee might be emp-name or
job-title; different instances of Employee may have the same
value for emp-name (two John Smiths) or job-title (many
Senior Programmers).
Both identifiers and descriptors may consist of either a
single attribute or some composite of attributes. Some
attributes, such as specialty-area, may be multivalued.
The notation for multivalued attributes is shown with a
double attachment line, as shown in Figure 2.2.
Other
attributes may be complex,
such as an address that further
subdivides into street, city, state, and zip code.
Keys may also be categorized as either primary or second-
a
ry. A pr
imary key fits the definition of an identifier given in
this section in that it uniquely determines an instance of an
entity. A secondary key fits the definition of a descriptor in
that it is not necessarily unique to each entity instance. These
definitions are useful when entities are translated into SQL
tables and indexes are built based on either primary or sec-
ondary keys.
18 Chapter 2 THE ENTITY–RELATIONSHIP MODEL