Loading content...
We've established that entity types define structure—the blueprint for what entities look like. But databases don't store blueprints; they store data. They store entity instances—the concrete, actual entities that exist in the database at any given moment.
When a company creates a customer record for Alice Chen with email alice@example.com, they're not creating an entity type—that already exists. They're creating an entity instance: a specific, uniquely identified entity that conforms to the Customer entity type.
This distinction—between the abstract definition (type) and concrete realization (instance)—is fundamental to understanding how databases work. Tables define structure; rows are instances. Entity types define what can exist; entity instances are what actually exists. Schema is potential; data is actual.
This page explores entity instances in depth: their lifecycle, their identity, how they differ from types, how they participate in relationships, and how they change over time. Understanding instances completes our picture of entities as the foundation of database modeling.
By the end of this page, you will understand entity instances as concrete realizations of types, grasp the instance lifecycle, appreciate identity preservation across updates, see how instances participate in relationships, and understand how instances are represented across different modeling and implementation levels.
An entity instance (sometimes called an entity occurrence or simply an entity) is formally defined as:
A specific, uniquely identifiable occurrence of an entity type, existing in the database at a particular point in time.
Let's analyze this definition:
'A specific occurrence' — Not the general concept of 'customer', but a particular customer: Customer #10042, Alice Chen. One individual realization of the type.
'Uniquely identifiable' — Distinguished from every other instance of the same type by its key value. Two customers cannot have the same customer_id. The key makes the instance unique.
'Of an entity type' — The instance conforms to a type. It has exactly the attributes defined by the type, subject to the type's constraints.
'Existing in the database at a particular point in time' — Instances are temporal. They come into existence (INSERT), change (UPDATE), and cease to exist (DELETE). The database state at any moment is a snapshot of currently existing instances.
Mathematical Perspective:
In set theory terms:
Example Illustration:
Entity Type Definition:
Employee(
employee_id: INTEGER [PRIMARY KEY],
first_name: VARCHAR(50) [NOT NULL],
last_name: VARCHAR(50) [NOT NULL],
email: VARCHAR(100) [UNIQUE],
hire_date: DATE [NOT NULL],
salary: DECIMAL(10,2)
)
Entity Instances:
| employee_id | first_name | last_name | hire_date | salary | |
|---|---|---|---|---|---|
| 1001 | Alice | Chen | alice@corp.com | 2020-03-15 | 85000.00 |
| 1002 | Bob | Smith | bob@corp.com | 2019-07-22 | 72000.00 |
| 1003 | Carol | Davis | carol@corp.com | 2021-01-10 | 91000.00 |
Each row represents one entity instance. Instance 1001 is Alice Chen. Instance 1002 is Bob Smith. Each is a unique occurrence of the Employee type, identifiable by employee_id, with specific values for each attribute.
In object-oriented programming: Class = Entity Type. Object = Entity Instance. Just as you can create multiple objects from one class, you can have multiple entity instances of one entity type. The class defines structure; objects hold actual data.
Entity instances have a lifecycle—they're created, potentially modified, and eventually may be deleted. Understanding this lifecycle is crucial for database design and application development.
1. Creation (Birth):
An instance comes into existence when inserted into the database:
INSERT INTO Employee (employee_id, first_name, last_name, email, hire_date, salary)
VALUES (1004, 'David', 'Wilson', 'david@corp.com', '2023-06-01', 78000.00);
At this moment, a new entity instance exists. It has:
2. Active Life (Existence):
During its existence, an instance:
3. Modification (Change):
Instances can be updated while preserving identity:
UPDATE Employee
SET salary = 82000.00, email = 'david.wilson@corp.com'
WHERE employee_id = 1004;
The instance is still the same entity (same employee_id). Only attributes changed. This is identity preservation—the instance remains the same 'thing' despite changing properties.
4. Deletion (Death):
An instance ceases to exist when removed from the database:
DELETE FROM Employee WHERE employee_id = 1004;
After deletion:
Soft Delete vs. Hard Delete:
Many systems distinguish between:
Hard Delete: The instance is physically removed from the database.
Soft Delete: The instance is marked as deleted but retained.
is_deleted = TRUE) or status change (status = 'DELETED')| Stage | Trigger | Database Effect | Relationship Impact |
|---|---|---|---|
| Creation | INSERT statement | New row added; key assigned | Instance becomes available for relationships |
| Active Life | Ongoing existence | Queryable; participates in operations | Can be referenced by foreign keys |
| Modification | UPDATE statement | Attribute values change; identity preserved | Relationships unchanged (unless FK updated) |
| Soft Deletion | UPDATE to deleted flag | Still exists but filtered from queries | May still be referenced; constraints remain |
| Hard Deletion | DELETE statement | Row removed from table | Cascades or restricts per FK rules |
Deleting an entity instance that's referenced by other instances creates an integrity problem. Foreign key constraints define behavior: RESTRICT prevents deletion, CASCADE deletes dependents, SET NULL nullifies references. Design these constraints carefully—cascading deletes can be very destructive.
A fundamental aspect of entity instances is their identity—what makes an instance 'that specific instance' and distinguishes it from all others.
Identity vs. Equality:
Identity asks: Are these references pointing to the same instance? Equality asks: Do these instances have the same attribute values?
Two instances might have identical names, addresses, and other attributes, yet be different instances because they have different identifiers:
Instance A: {id: 1001, name: 'John Smith', city: 'Boston'}
Instance B: {id: 1042, name: 'John Smith', city: 'Boston'}
These are equal in attributes but not identical—they're different people named John Smith.
Key-Based Identity:
In relational databases, identity is determined by the primary key. Two references point to the same instance if and only if they have the same primary key value.
-- Finding an instance by identity
SELECT * FROM Customer WHERE customer_id = 1001;
-- This returns exactly one instance (or none)
Identity Preservation:
When we update an entity instance, we change its attributes while preserving its identity:
-- Before: {customer_id: 1001, name: 'John Smith', email: 'john@old.com'}
UPDATE Customer
SET email = 'john@new.com', name = 'Jonathan Smith'
WHERE customer_id = 1001;
-- After: {customer_id: 1001, name: 'Jonathan Smith', email: 'john@new.com'}
The customer_id remains 1001. This is still the same customer—just with updated information. Relationships referencing customer_id 1001 still reference the same customer.
Why Identity Matters:
Relationships depend on it: Foreign keys reference primary keys. If identity weren't stable, relationships would break.
History tracking requires it: "What was Customer 1001's address in 2020?" requires stable identity across time.
Business logic assumes it: "This is the same customer who complained last month" requires persistent identity.
Concurrency depends on it: Locking 'row X' during updates requires stable identity.
Object Identity vs. Value Identity:
Some modeling approaches distinguish:
Object Identity: Instances are identified by their key, regardless of attributes. Used for entities.
Value Identity: Instances are identified by their attribute values. Used for value objects (e.g., a Money amount, a DateRange).
In ER modeling, entities always have object identity. Attributes are values.
The primary key IS the identity in relational databases. This is why key selection matters so much—keys must be stable, unique, and non-null. If you could change a primary key, you'd be changing identity—essentially creating a new entity and destroying the old one, breaking all references.
Relationships in the ER model connect entity types conceptually, but at runtime, it's entity instances that actually participate in relationships.
Relationship Instances:
Just as entity types have entity instances, relationship types have relationship instances:
Relationship Type:
Customer --places--> Order
Relationship Instances:
(Customer#1001, Order#5001) -- Alice placed Order 5001
(Customer#1001, Order#5002) -- Alice placed Order 5002
(Customer#1042, Order#5003) -- Bob placed Order 5003
Each is a relationship instance connecting two entity instances.
Foreign Keys as Relationship Implementation:
In relational databases, relationships are implemented via foreign keys. The foreign key value in one row references the primary key of another row:
-- Order table
CREATE TABLE Order (
order_id INT PRIMARY KEY,
order_date DATE,
customer_id INT REFERENCES Customer(customer_id) -- FK
);
-- Data
| order_id | order_date | customer_id |
|----------|-------------|-------------|
| 5001 | 2023-01-15 | 1001 | -- Order 5001 placed by Customer 1001
| 5002 | 2023-01-16 | 1001 | -- Order 5002 placed by Customer 1001
| 5003 | 2023-01-17 | 1042 | -- Order 5003 placed by Customer 1042
The customer_id value in each Order instance creates the relationship with a Customer instance.
Cardinality at the Instance Level:
Cardinality constraints describe limits on relationship participation:
1:1 — One instance relates to at most one other:
1:N — One instance relates to many others:
M:N — Many instances relate to many others:
Participation at the Instance Level:
Total Participation: Every instance must participate.
Partial Participation: Instances may not participate.
When reading ER diagrams, translate to instances: 'A Customer places zero or more Orders' means each specific customer instance (Alice, Bob, Carol) may have zero, one, or many order instances associated with them. Thinking in concrete instances helps validate that the model matches real-world expectations.
Each entity instance has a state—the current values of all its attributes at a given moment. Understanding how state works is essential for data modeling and application development.
Current State:
At any moment, an instance has exactly one value (or NULL) for each attribute:
Customer#1001 State (as of 2023-06-15):
{
customer_id: 1001,
name: 'Alice Chen',
email: 'alice@company.com',
tier: 'GOLD',
registration_date: '2020-03-15',
total_purchases: 15420.50
}
This is the current state. When any attribute changes, the state changes.
State Changes:
States change through UPDATE operations:
-- State transition: GOLD → PLATINUM
UPDATE Customer SET tier = 'PLATINUM' WHERE customer_id = 1001;
-- New state includes tier: 'PLATINUM'
The instance identity remains constant; only state changes.
Valid States:
Constraints define which states are valid:
-- Valid state
{customer_id: 1001, name: 'Alice', email: 'alice@co.com', tier: 'GOLD'}
-- Invalid state (violates NOT NULL on name)
{customer_id: 1001, name: NULL, email: 'alice@co.com', tier: 'GOLD'}
-- Invalid state (violates CHECK on tier)
{customer_id: 1001, name: 'Alice', email: 'alice@co.com', tier: 'DIAMOND'}
The DBMS prevents transitions to invalid states by rejecting violating INSERTs and UPDATEs.
| Characteristic | Description | Example |
|---|---|---|
| Atomic Value | Single indivisible value for simple attributes | name = 'Alice Chen' |
| NULL Value | Absence of value for optional attributes | middle_name = NULL |
| Constrained Value | Value within defined domain/range | tier IN ('BRONZE', 'SILVER', 'GOLD') |
| Derived Value | Computed from other attributes | age = CURRENT_DATE - birth_date |
| Default Value | Automatically assigned if not specified | created_at = CURRENT_TIMESTAMP |
| Immutable Value | Set once, never changed | customer_id = 1001 (primary key) |
| Mutable Value | Can be changed during instance lifetime | email = 'newemail@co.com' |
Standard databases store only current state. To track historical states (what was the customer's tier last month?), additional design is needed: audit tables, temporal tables, event sourcing, or change data capture. Historical tracking requires explicit architectural decisions.
Entity instances appear in different forms across the modeling and implementation stack. Understanding these representations helps connect conceptual understanding to practical implementation.
Conceptual Level (ER Model):
In ER diagrams, we typically show types, not instances. However, we can illustrate instances as specific examples:
[CUSTOMER] [ORDER]
Alice (1001) ──────→ Order 5001
│──────→ Order 5002
Bob (1042) ────────→ Order 5003
Such diagrams help validate cardinality and participation.
Logical Level (Relational Schema):
At the logical level, instances become tuples (rows):
Customer(customer_id, name, email, registration_date)
─────────────────────────────────────────────────────
(1001, 'Alice Chen', 'alice@co.com', '2020-03-15')
(1042, 'Bob Smith', 'bob@co.com', '2019-07-22')
Each tuple is one instance. The schema (first row) is the type.
Physical Level (Storage):
At the physical level, instances are stored in database pages as records:
Page 42:
[Record 1: {1001, 'Alice Chen', 'alice@co.com', ...}]
[Record 2: {1042, 'Bob Smith', 'bob@co.com', ...}]
[Free Space]
Indexes provide efficient access to instances by key.
Application Level (Objects):
In application code, instances often become objects:
const customer = await Customer.findById(1001);
// customer = { id: 1001, name: 'Alice Chen', email: 'alice@co.com', ... }
ORMs (Object-Relational Mappers) bridge database rows and application objects.
| Level | Instance Representation | Type Representation |
|---|---|---|
| Conceptual (ER) | Examples/Sample data | Entity rectangle |
| Logical (Relational) | Tuple/Row | Relation schema |
| Physical (Storage) | Record in page/block | Table metadata |
| Application (OOP) | Object instance | Class definition |
| API (JSON) | JSON object | JSON Schema |
| UI (Forms) | Form data | Form template |
A well-designed system maintains conceptual consistency across levels. The same entity instance (Customer#1001) should be recognizable whether you're looking at an ER diagram, a database row, an object in code, or a JSON payload from an API. Keys provide this continuity.
Entity instances must satisfy constraints defined by their entity type and by relationships. Validation ensures instances represent legitimate entities.
Types of Validation:
1. Attribute-Level Validation:
2. Entity-Level Validation:
3. Referential Validation:
4. Business Rule Validation:
Validation Timing:
Immediate (Synchronous):
Deferred (Within Transaction):
Application-Level:
Layered Defense:
Best practice is defense in depth:
[User Input]
↓ Application validation (user feedback)
[Application Layer]
↓ Business logic validation
[Service Layer]
↓ API validation
[Database Layer]
↓ Database constraints (final guarantee)
[Storage]
Even if application validation fails, database constraints provide final protection.
Never rely solely on application validation. Users can bypass UI validation; APIs can receive malformed requests. Database constraints are the final guarantee of integrity. Define constraints at the database level, then add application validation for user experience—not as replacement for database constraints.
We've explored entity instances—the concrete realizations of entity types that constitute the actual data in our databases. Instances bring the abstract world of types to life, existing at a point in time with specific attribute values and relationships.
What's next:
With our understanding of entities, entity sets, entity types, and entity instances complete, we'll turn to a critical practical topic: naming conventions. Proper naming of entities, attributes, and relationships is essential for creating maintainable, understandable data models that stand the test of time.
You now understand entity instances as the concrete data that populates your databases. Types define structure; instances are actual data. This completes our examination of the entity concept from multiple angles. Next, we'll explore naming conventions that make models clear and maintainable.