Skip to content Skip to main navigation Skip to footer

Entities, Instances, Attributes and Identifiers

In this article, we look at the concepts of Entity of Database and Instances and identifying Attributes and Unique Identifiers for Entities.

Objectives

This article covers the following objectives:

  • Define and give an example of an entity of database
  • Distinguish between an entity and an instance of an entity
  • Name and describe attributes for a given entity
  • Distinguish between an attribute and its value
  • Distinguish between mandatory and optional attributes, and between volatile and nonvolatile attributes
  • Select and justify a unique identifier (UID) for an entity

Purpose of Entity of Database

  • Knowing how to organize and classify data makes it possible to draw useful conclusions about seemingly random facts.
  • Our technology-rich world produces vast quantities of facts in need of structure and order.
  • It is important to learn about entities because they are the things about which we store data.
  • For example:
    • A school needs to store data about (as a minimum): STUDENTs, TEACHERs, COURSEs, ROOMs, GRADEs.

Purpose of Attribute in Database

  • It is important to learn about attributes in database because they provide more specific information about an entity.
  • Attributes help you distinguish between one instance and another by providing greater detail for the entity.
  • For example:
    • In a restaurant, you need to list the individual items on a customer’s order so that you can calculate the bill.
    • When building several sales reports, you must be able to identify a specific report from the list of reports.

Purpose of Unique Identifiers in SQL

  • What about unique identifiers in SQL?
  • It is important to learn about unique identifiers in SQL because they distinguish one instance of an entity from another.
  • For example:
    • In a classroom, you need to distinguish between one student and another.
    • When classifying your CD collection, you need to distinguish between one CD and another.
    • When listing transactions on a financial statement, you need to distinguish between one transaction and another.

Identifying Purpose

  • Look at the magazine advertisements and the websites identified by the teacher.
  • What is the “main thing” that each ad or website is about?
Entity of Database

Look at commercial websites. Some suggestions are:

Entity of Database Defined

An entity is:

  • “Something” of significance to the business about which data must be known
  • A name for a set of similar things that you can list
  • Usually a noun
  • Examples: objects, events, people
  • Entities have instances.
  • An instance is a single occurrence of an entity.

Entities and Instances

Entities and Instances
  • A Dalmatian, a Siamese cat, a cow and a pig are instances of ANIMAL
  • A convertible, a sedan and a station wagon are instances of CAR
  • Some entities have many instances and some have only a few
  • Entities can be:
    • Tangible, like PERSON or PRODUCT
    • Intangible, like SKILL LEVEL
    • An event, like CONCERT
  • Is DOG an instance or an entity?
Entities and Instances
  • It depends:
    • If we consider many different kinds of animals, it makes sense to think of the entity ANIMAL to include instances DOG, CAT, HORSE and so on.
    • But what if we run a dog-breeding business? We will need to keep data on many different breeds of dog, but not on other species of animal.
    • For a dog-breeder, it is more natural to think of an entity DOG to include instances TERRIER, POODLE, LABRADOR and so on.

What is an Attribute?

  • Like an entity, an attribute represents something of significance to the business.
  • An attribute is a specific piece of information that helps:
    • Describe an entity
    • Quantify an entity
    • Qualify an entity
    • Classify an entity
    • Specify an entity
  • An attribute has a single value.

Assume that all entities have at least one attribute. Later, we will discover exceptions to this assumption. Usually, there are many attributes for an entity, but again, we are interested only in those attributes that are of importance to the business. Example: The Entity FRUIT has attributes of name, type, region, and date picked. An instance of this would be: Orange, citrus, west coast, 10-APR-2005.

Attributes

  • Attributes have values. An attribute value can be a number, a character string, a date, an image, a sound, etc.
  • These are called “data types” or “formats.” Every attribute stores one piece of data of one specific data type.
Attributes

The only attributes we need to model are those that the business wants to track. So for example, you may want to track shoe size as an attribute of customer if you are a shoe store, but maybe not if you are a grocery store. It all depends on the business requirements.

Every attribute has a data type. For example, the attribute “name” has a data type of character string (text), the attribute “salary” has a data type of number, and the attribute “photograph” has a data type of image.

Attribute Is Single-Valued

An attribute for an entity must be single-valued. In more precise terms, an instance of an entity can have only one value for each attribute at any point in time. This is the most important characteristic of an attribute. The attribute value, however, may change over time.

For example: The entity CAR may have attributes “model” and “color.” There can be only one value for these (for example, “Beetle” and “green”) at one time, for each instance (i.e. for each individual car). Although the model remains the same over the lifetime of the car, its color can change.

  • What is the data type of each attribute in CUSTOMER?
  • For example: family name is a character string. Attributes are single-valued. Each attribute can have only one value (at any point in time) for each instance of the entity.
  • Some attributes (such as age) have values that constantly change.
  • These are called volatile attributes.
  • Other attributes (such as order date) will rarely change, if ever.
  • These are nonvolatile attributes.

Volatile: Highly changeable.

One reason for preferring nonvolatile attributes (if there is a choice) is that volatile attributes will need to be updated frequently. For example, age must be updated every year. How long would this take if we had 1 million customers? If we need to know a customer’s age, we can easily deduce it from the birth date.

  • If given a choice, select the nonvolatile attribute.
  • For example, use birth date instead of age.
  • Some attributes must contain a value—these are mandatory attributes.
  • For example: in most businesses that track personal information, name is required.
  • Other attributes may either contain a value or be left null—these are optional attributes.
  • For example: cell phone number is often optional except in mobile or wireless applications.
  • Example: Email address could be a mandatory attribute for EMPLOYEE in an email application, but an optional attribute for CUSTOMER in an online catalog.
Attributes
  • If we were to model a Human Resource system, we would have an entity to store data for each worker called EMPLOYEE.
  • What attributes does EMPLOYEE have?
  • Give one or two examples of the values that each EMPLOYEE attribute might contain.
Attributes

Possible answers for attributes may include:

  • First Name
  • Last name
  • Address
  • Salary
  • Social Security Number

Identifiers

  • An EMPLOYEE has a unique identifier (UID).
  • A UID is either a single attribute or a combination of multiple attributes that distinguishes one employee from another.
  • How do you find a specific employee that works for the company?
  • What information uniquely identifies one EMPLOYEE?
  • Think about all the students in the classroom.
  • Each student is described by several traits or attributes.
  • Which attribute or attributes allow you to pick a single student from the rest of the class?
  • That is the student’s UID.
Student identifier.

What combination of traits uniquely identifies a single STUDENT? Student’s name? No, there could be two students with the same name. Date of birth? No, there could be two students born on the same day.

For almost any combination of student attributes, it is at least possible that two students could have the same combination of values. This is why for entities such as STUDENT, we create an artificial student number or student ID.

Terminology

Key terms used in this tutorial included:

  • Attribute
  • Data type
  • Entity
  • Instance
  • Mandatory
  • Intangible
  • Null
  • Optional
  • Single valued
  • Tangible
  • Unique identifier (UID)
  • Volatile

Summary

In this tutorial, you should have learned how to:

  • Define and give an example of an entity of Database
  • Distinguish between an entity and an instance of an entity
  • Name and describe attributes for a given entity
  • Distinguish between an attribute and its value
  • Distinguish between mandatory and optional attributes, and between volatile and nonvolatile attributes
  • Select and justify a unique identifier (UID) for an entity

Was This Article Helpful?

-1
Related Articles
0 Comments

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *