Attributes-Entities   «Prev  Next»

Lesson 11

Entities and Attributes: Database Design Summary

An entity type defines what a database describes; attributes define the facts recorded about it. Individual occurrences are entity instances, and their recorded facts are attribute values. Identifiers distinguish instances, domains define permitted values, and constraints enforce declared rules. Together, these concepts turn business requirements into a relational design that can store and connect facts consistently.

This module progressed from an Employee diagram to customer and employee records, then examined keys, domains, repeating facts, and integrity rules. The important result is a repeatable design process: define the meaning, decide what one record represents, select its identifier, describe its attributes, resolve collections, and state the rules that protect the structure.

From Entity Types to Tables and Values

The introduction to entities and attributes established the vocabulary. Employee is an entity type; a particular employee is an instance. FirstName is an attribute; Alex is a possible value. EmployeeID is also an attribute, with an identifying role. It is not a separate category of information outside the entity's attributes.

In Chen notation, a rectangle represents an entity type, ovals represent attributes, and underlining marks an identifier. Lines attaching those attributes to Employee do not show relationships between different entity types. Read a diagram according to its stated notation rather than assuming every connecting line means the same thing.

The conceptual-model lesson connected these ideas to relational tables. In a simple mapping, an entity type becomes a table, simple attributes become columns, and each instance is represented by a row. Relationships, composite attributes, and repeating facts can require additional structures, so the mapping is a starting point rather than a universal one-table-per-business-word rule.

Keep the model separate from its recorded data
ConceptExampleDesign question
Entity typeEmployeeWhich employees are within the system's scope?
Entity instanceEmployee 11672Which particular employee is represented?
AttributeCityDoes this mean the current residential city or something else?
Attribute valueSan DiegoWhat city is recorded for this instance?
IdentifierEmployeeIDHow can the same employee be referenced after descriptive facts change?

Conceptual design establishes business meaning. Logical design organizes relations, keys, and constraints. Physical design selects implementation details such as indexes and storage choices for a particular DBMS. Deciding that an employee needs an identifier comes before choosing an integer type or a generation mechanism.

Identify Instances and Define What One Row Means

The customer identifier lesson showed why names and addresses cannot be assumed to identify people. Two customers may share a surname or city while remaining distinct instances. A descriptive value changing does not normally create a new customer identity.

The employee-instance lesson added an essential question: what does one row represent? In its current Employee table, one row represents one employee identity. An address-history table could contain several rows for that employee, each describing a different period. A joined query can also repeat an employee identifier without introducing additional employees.

State that level of detail before choosing a key. A customer, an order, and an order line are different things to identify. CustomerID alone cannot identify every order because one customer may place several orders. Similarly, a date describing an enrollment belongs with the enrollment, not automatically with the person who enrolled.

The two identifier guidelines recommend values independent of mutable business meaning and free of unnecessary restrictions on future instances. An office code embedded in an employee identifier becomes troublesome when the employee moves. A customer identifier requiring a particular national identity number can exclude legitimate customers.

Those guidelines do not mean identifiers are infinite, unvalidated, or always random. Define their scope, capacity, allocation, and lifecycle. A candidate key must be unique and minimal: no component can be removed without losing uniqueness. Stability is a separate design consideration. Selecting a surrogate primary key also does not remove the need to enforce other genuine business uniqueness rules.

Preserve identifier representation deliberately. The customer code 0081 was text in the lesson because its leading zeros were meaningful. An identifier that looks numeric is not necessarily a quantity. Nor does an opaque identifier provide authorization: applications must still check whether a caller may access the referenced record.

Define Domains Before Choosing Convenient Types

The attribute-domain lesson distinguished three things: a domain, a data type, and a stored value. A percentage domain might permit 0 through 100; DECIMAL supplies a numeric representation; 15.00 is one recorded value. Values absent from today's data can still belong to the domain.

Document meaning, units, permitted values, and missing-information policy. Two decimal columns can represent unrelated concepts, such as temperature and discount percentage. A phone number needs text and a formatting policy, not arithmetic. A date should record a defined event, such as BirthDate or OrderDate, rather than an unexplained Date field.

Optional information also needs an explicit meaning. Unknown is different from zero, an empty string, or a convenient invented date. Define whether the absence is permitted and whether the application needs to distinguish unknown, not applicable, and not yet collected. A default should express a truthful assumption, not conceal missing data.

Resolve Multivalued Attributes by Meaning

The lessons on recognizing multivalued attributes, choosing distinct roles or related records, and creating a new entity form one decision sequence. First identify the repeating fact, then decide how its occurrences should be represented.

In the conventional first normal form treatment used here, each attribute position holds one value from its intended domain, without repeating groups. A list of child names combined with a separate list of birth dates hides individual occurrences and their pairings. Arbitrary Child1, Child2, and Child3 columns impose slots instead of explaining the facts.

Composite and multivalued are different ideas. An address can have components such as city and postal code; a customer can have several addresses. It may therefore be both composite and multivalued. Splitting a value is useful when those components need separate meaning, validation, or use, not simply because a string contains punctuation.

Distinct roles can justify separate attributes. BillingPhone and ShippingPhone can each describe one current number under clearly defined requirements. Phone1 and Phone2 merely name positions. If numbers repeat independently, require their own details, or need history, use related records instead. A small collection size alone does not establish distinct roles.

Worked Review: Customers and Their Phone Numbers

Assume a customer may have zero or more recorded contact numbers. Each contact record belongs to one customer. These shortened phone values are illustrative teaching data.

Before: a collection packed into a customer field
CustomerIDCustomerNamePhoneNumbers
1001John Doe555-1234, 555-5678
1002Jane Smith555-9999

Keep customer facts in Customers and represent each contact occurrence in CustomerPhones. In this model, a PhoneID identifies a contact record, not a telephone device or a person.

Customers: one row per customer
CustomerIDCustomerName
1001John Doe
1002Jane Smith
CustomerPhones: one row per recorded contact number
PhoneIDCustomerIDPhoneNumber
11001555-1234
21001555-5678
31002555-9999

CustomerID repeats in CustomerPhones as a reference to the customer, while PhoneID remains unique. A new number adds a row rather than a column. A customer without a recorded number needs no placeholder contact row. Decide separately whether repeated customer-number pairs are prohibited and how numbers are standardized for comparison. Do not assume a phone number is globally unique to one customer.

The employee-child example applied the same pattern while keeping each child's name and birth date together. If a child can be associated with several employees, use an association table instead of forcing a single owner or duplicating the child. Requirements determine the relationship.

When converting existing lists, preserve the source and verify pairings, formats, roles, and per-owner counts. Do not infer a missing birth date or a billing role from list position. Resolving repeating facts does not prove that every higher normal form is satisfied, and it does not guarantee faster execution for every query.

Arrays and JSON remain legitimate tools for intentional collection or document designs. The relevant question is whether the application needs independently identified members with their own relationships and rules. The related-table pattern makes those requirements explicit in these examples.

Turn Business Rules into Enforced Constraints

The constraints lesson completed the design process by asking what the database must reject. Match each rule to its scope: a value, several attributes in one row, uniqueness across rows, or references between tables.

For PostgreSQL examples, CHECK accepts true or unknown, so a range check alone does not require a value. Defaults supply omitted values rather than validating supplied ones. Consult the PostgreSQL 18 constraint documentation for implementation details.

A mandatory customer reference on each contact record does not require every customer to have a contact record. Deletion, minimum participation, and historical retention need their own policies. Likewise, valid stored values do not prove real-world truth: an existing CustomerID can still be the wrong customer for a transaction.

Review Your Design Before Moving On

  1. Define the population: Explain what each entity type includes and excludes.
  2. State the row meaning: Distinguish an identity, an event, an association, and a historical version.
  3. Choose identifiers: Check uniqueness, minimality, stability, capacity, and allocation scope.
  4. Define attributes: Record their meanings, units, domains, and missing-value policies.
  5. Inspect repetition: Separate genuine roles from arbitrary numbered slots and independently repeating occurrences.
  6. Describe relationships: State which side can have many occurrences and whether participation is optional.
  7. Enforce rules: Identify database constraints and any additional application or procedural enforcement.
  8. Test counterexamples: Try shared names, absent values, extra occurrences, changing facts, and deletion of referenced records.

Record these decisions in a data dictionary alongside the ER diagram. A diagram communicates structure; definitions and examples explain the rules behind it. Review both with people who understand the business before treating the model as settled.

Check Your Understanding

Two employees share a name and city. Are they one instance? No. Descriptive values may repeat; identifiers distinguish the modeled identities.

A customer supplies a fourth phone number. What should change? Under the related-record model, add another CustomerPhones row. Do not add Phone4 to Customers.

Does a generated key prevent duplicate real-world customers? No. It distinguishes rows. Deciding whether two records represent the same customer requires additional rules and a review process.

Does an allowed birth date prove it is correct? No. Constraints protect stated conditions, while source verification establishes factual accuracy.

Entities and Attributes Glossary

Entity type and entity instance
A defined category and one particular occurrence within that category.
Attribute and value
A defined property and a particular recorded value of that property.
Candidate, primary, and alternate keys
Minimal identifiers; the selected primary identifier; and the remaining candidate identifiers.
Domain
The permitted values for an attribute with their intended meaning, supported by explicit representation and validation rules.
Single-valued and multivalued attributes
Properties allowing at most one value or several occurrences per instance. Required-value rules are a separate question.
Composite attribute
An attribute with meaningful components, such as an address with a city and postal code.
Associative entity
An entity representing an association, potentially with its own descriptive facts.
Base table
A table whose data is maintained directly, as distinct from a view defined by a query; the term does not prescribe disk storage.
Constraint
An enforced condition restricting the states that the database accepts.

Continue to entity-relationship diagrams to develop the connections between entity types, including cardinality and participation. Bring the identifiers, domains, and row meanings from this module into that work.

Relational Database Design Implementation

Entities and Attributes Quiz

Use the quiz to check your understanding before moving to the next module. Return to the linked lessons above for any distinctions that remain unclear.

Entities and Attributes - Quiz

SEMrush Software 11 SEMrush Banner 11