Attributes-Entities   «Prev  Next»

Lesson 5Instances of Entities
ObjectiveDescribe instances of entities.

Entity Instances in Database Design: An Employee Example

An entity instance is one particular occurrence of an entity type: a specific employee, customer, order, or appointment. The entity type defines the attributes that describe its occurrences. Each instance supplies particular values for those attributes and has an identifier that distinguishes it within the model.

For example, Employee is an entity type, Name is an attribute, and Beth Johnson is a value for the employee identified by 11672. In the simple relational design used here, one Employee row represents one employee instance. The row stores the identifier and the descriptive values together.

This lesson explains how to recognize an instance, describe it precisely, and distinguish it from the type definition, an attribute value, or a query result. That distinction helps you decide what a row represents before counting records or designing relationships.

One Employee Type, Three Example Instances

Employee type with EmployeeID, Name, Street, and City attributes; instances 11672 Beth Johnson, 15502 Randy Masters, and 17244 Luke Santana.
Each card describes one Employee instance using the same four attributes. EmployeeID distinguishes the instances; Name, Street, and City provide descriptive values. Connecting lines show the common type, not an ER relationship.

The illustration preserves three example employees from the earlier diagram. These names and addresses are teaching data, not verified personnel or address records. The same information appears below as accessible table text.

Values for three Employee instances
EmployeeIDNameStreetCity
11672Beth Johnson419 S. PresaSan Diego
15502Randy Masters14 Broadway Ave.New Orleans
17244Luke Santana2605 W. PlainfieldPhiladelphia

All three instances share an attribute structure. They do not share the same values. EmployeeID 15502 identifies the instance whose Name value is Randy Masters, whose Street value is 14 Broadway Ave., and whose City value is New Orleans.

The City values are not the names of entity types in this diagram. San Diego is a value describing Beth's record, not a category containing a separate kind of employee. Explicit labels make that distinction easier to see than an unlabeled collection of names and addresses.

What Exactly Is an Entity Instance?

An entity type defines the category being modeled; an entity instance is a member of that category. A stored record is a representation of the instance. Keeping these ideas separate avoids treating a person as if they were literally a row of text.

The database records selected facts about the person for a particular purpose. It does not capture every fact about them. This Employee example includes four attributes because those are enough to illustrate the distinction. A payroll, staffing, or contact system would require additional definitions and rules.

The word entity is sometimes used for either the type or the individual occurrence. Use the full terms when explaining a design:

  • Entity type: Employee, the category with a shared definition.
  • Entity instance: The employee represented by EmployeeID 11672.
  • Attribute: Name, a property recorded for employees.
  • Attribute value: Beth Johnson, the Name value for that instance.
  • Identifier: EmployeeID, the attribute used here to distinguish instances.

An identifier is itself an attribute. It has a special role, but it is not outside the entity's attribute structure. The earlier lesson on entities and attributes introduces these terms; here the emphasis is on describing individual occurrences correctly.

Describe an Instance with a Complete Sentence

A useful description states the type, identifier, and relevant values: “Employee 17244 has the name Luke Santana, street value 2605 W. Plainfield, and city value Philadelphia.” The identifier anchors the statement to one instance, while the other attributes say something about it.

“Philadelphia” alone is not an employee instance. Neither is the attribute name City. A value only becomes a specific recorded fact when you know which attribute and which instance it belongs to. The same city could describe hundreds of employees.

Likewise, an employee's name is not necessarily enough to identify one instance. Two people can share the same name. The system needs an identifier whose uniqueness follows an explicit rule rather than an assumption based on a small sample.

You do not need to list every attribute every time you refer to an instance. A screen may show only EmployeeID and Name. That abbreviated view still refers to the same stored employee, provided it retains enough context to distinguish the intended record.

Instances and ER Diagrams Serve Different Purposes

A conventional schema-level ER diagram describes entity types, attributes, relationships, and participation rules. It explains what kinds of instances may exist and how they may be related. It does not usually enumerate every employee currently recorded.

An instance illustration supplies concrete examples of that structure. The three employee cards above are such an illustration. Their connections to the common Employee definition do not mean that Employee is a parent table related to three child entity types. The cards are three occurrences of the same type.

You can discuss sample instances before implementing a database. During requirements analysis, example records help business users check whether the proposed attributes capture the information they need. The instances do not become meaningful only when an INSERT statement runs.

For example, reviewing the cards might prompt a question about address meaning. Does Street describe a home address, work location, or mailing address? The picture alone does not answer that. Sample instances help uncover missing definitions, while the model must record the chosen meaning.

Once implemented, the table definition is the schema and its stored rows form the data at a particular time. The schema can remain unchanged as employees are added or descriptive values are updated. See mapping conceptual models to tables for the next level of implementation detail.

Decide What One Row Represents

For this lesson, assume the Employee table keeps one current record per employee identity. Under that assumption, three rows represent three employee instances. The same conclusion does not apply automatically to every table containing an EmployeeID column.

An EmploymentEpisode table might record separate periods of employment. A person who leaves and is rehired could have two episode rows while retaining one employee or person identity. An AddressHistory table might have several dated addresses for the same employee. Those rows describe different kinds of occurrences.

This level of detail is often called the table's grain. State it in plain language: one row per employee, one row per employment episode, or one row per address period. Choose the identifier and uniqueness rules to match that statement.

If a database contains 10,000 people, it does not necessarily contain exactly 10,000 rows across its employee-related tables. History, assignments, and contacts can add many more rows. Counting rows is meaningful only after identifying what each row represents and which records the query includes.

A similar distinction applies outside personnel data. One customer can place many orders, and one order can contain many order lines. Customer, Order, and OrderLine instances answer different questions even though their records are related.

Store the Employee Instances in a Table

The following illustrative PostgreSQL 18 example implements the four attributes shown in the diagram. EmployeeID values are supplied explicitly to match the teaching data. Name is required for this example; Street and City may be absent. A production system would define its address and naming requirements more carefully.

CREATE TABLE Employee (
    EmployeeID INTEGER PRIMARY KEY,
    Name       VARCHAR(200) NOT NULL,
    Street     VARCHAR(200),
    City       VARCHAR(100)
);

INSERT INTO Employee (EmployeeID, Name, Street, City)
VALUES
    (11672, 'Beth Johnson', '419 S. Presa', 'San Diego'),
    (15502, 'Randy Masters', '14 Broadway Ave.', 'New Orleans'),
    (17244, 'Luke Santana', '2605 W. Plainfield', 'Philadelphia');

SELECT EmployeeID, Name, Street, City
FROM Employee
WHERE EmployeeID = 15502;

The expected result is Randy Masters' row with Street 14 Broadway Ave. and City New Orleans. This follows from the sample statements; it is not a captured execution result. The identifier selects at most one stored Employee row because it is the primary key.

The chosen column sizes are illustrative, not universal limits for names or addresses. The following lesson on attribute domains and data types explains how permitted values and their representations should be defined.

Queries Can Show Only Part of an Instance

A query can select some rows and show only some columns. Neither action changes the underlying Employee instances. For example, a list of identifiers and names omits the address values from the result without removing them from the stored records.

SELECT EmployeeID, Name
FROM Employee
ORDER BY EmployeeID;

The expected list contains Beth Johnson, Randy Masters, and Luke Santana in ascending EmployeeID order. An explicit ORDER BY requests that arrangement; the table's key does not itself promise a particular display order. PostgreSQL documents this distinction in Sorting Rows.

If a query selects only City, the output contains city values rather than complete employee descriptions. Different employees can produce identical displayed values. Using DISTINCT City would count or display distinct cities, not distinct employees.

A join can also repeat an employee's details when several related records match. Beth might appear twice in a report that joins Employee to two project assignments. That does not prove there are two Beth instances in the Employee table. Inspect the keys and the query's intended level of detail before diagnosing duplicate records.

PostgreSQL's table-expression documentation explains how joins and filters produce result rows. For modeling purposes, remember that a query result and a base entity table need not have the same one-row meaning.

Updating Values Does Not Normally Create a New Instance

Suppose Beth moves to a different city. If the table stores current address information, updating her descriptive values leaves EmployeeID 11672 attached to the same employee identity. Changing a fact about an instance is different from adding another instance.

UPDATE Employee
SET Street = '10 Example Lane',
    City = 'Example City'
WHERE EmployeeID = 11672;

This hypothetical update changes the current record. The diagram continues to show the original sample values. If the application needs to answer where Beth lived previously, replacing the values alone is insufficient; it needs a deliberate history design.

A historical row records a version or time-bounded fact about the employee. It should include the information needed to distinguish that historical occurrence, such as its own identifier or a suitable combination of employee and effective-time attributes. Historical versions should not be counted as new people merely because they occupy separate rows.

Deletion also follows business rules. An employee leaving the organization may call for an employment end date or inactive status rather than deleting every reference to that employee. Decide what the system must retain and what each status means before treating deletion as the default end of an instance's lifecycle.

Keys and Constraints Protect Declared Rules

The primary key rejects repeated EmployeeID values and prevents missing identifiers. A required Name column rejects NULL for that attribute. These are specific guarantees; they do not establish that an address is real, a name is correctly spelled, or every represented employee is eligible for a business process.

Nor does assigning different IDs automatically prevent duplicate records for the same person. Two records could contain the same descriptive values and different identifiers. They might be duplicate entries, or they might represent different people. Resolving that ambiguity needs appropriate business evidence and review.

Foreign keys help preserve references between related records. If an assignment must refer to an existing employee, a foreign key can enforce that relationship. Required participation, allowed assignment dates, and other rules need their own definitions and enforcement.

The important principle is to state each rule precisely rather than saying that constraints make every instance “valid.” They enforce the rules actually declared. Revisit identifier design rules and entity and attribute constraints for those complementary topics.

Common Misunderstandings About Instances

  • Confusing a type with a person: Employee is the shared category; employee 11672 is one occurrence.
  • Confusing an attribute with a value: City names the property; San Diego supplies a value for it.
  • Identifying people by name alone: Equal names do not establish equal identity.
  • Counting report rows as people: Joins and historical data can show the same employee more than once.
  • Treating a move as a new employee: A descriptive update usually preserves the existing identity.
  • Assuming every missing value means the same thing: Unknown, unavailable, and not applicable may need different treatment.

There is also a separate technical use of the word instance: a running DBMS environment may be called a database or server instance. That is not the meaning here. Employee instances are occurrences in the business data model, not running database processes.

Check the Model with Sample Instances

Review examples that challenge assumptions as well as ordinary records. Consider two employees with the same name, an employee without a known address, someone with several contact addresses, and someone who leaves and returns. Ask whether the existing attributes and identifiers can represent each case without changing their meaning.

If one employee can have several independently maintained addresses, repeating columns such as Address1, Address2, and Address3 may impose an arbitrary limit. A related address structure may be more appropriate. The later lesson on resolving multivalued attributes explores that design decision.

As a short self-check, describe the middle card in one sentence. It is Employee instance 15502, named Randy Masters, with the displayed Street and City values. Name the type separately from those values, then explain why changing the city would not normally change the identifier.

For additional reading: Database Systems.

From Instances to Attribute Domains

An entity instance is a particular occurrence described by attribute values. In this lesson's simple Employee table, one row represents one employee identity, and EmployeeID distinguishes that row. A query, history table, or related table may represent a different level of detail.

Being able to describe an instance precisely prepares you to define which values are allowed for its attributes. Continue to attribute domains and data types to connect the sample values with explicit definitions and constraints.


SEMrush Software 5 SEMrush Banner 5