Skip to content
C

Domain


Domain

Definition

A domain is the set of all atomic (indivisible), legal values that an attribute is permitted to take. It defines both an underlying data type and, often, a further constraint restricting the allowed range or enumerated set of values. Domains give relations their "type safety" by bounding what each attribute may legitimately store.

Example

For Students(id, name, department, gpa):

  • domain(id) = positive integers
  • domain(name) = character strings of length ≤ 50
  • domain(department) = { CS, ECE, ME, EEE, CE, ... } (an enumerated set of valid department codes)
  • domain(gpa) = decimal values in the range [0.0, 10.0]

How this differs from Attribute

The domain is the pool of legal values (a type plus optional constraints); the attribute is the named role bound to that pool within a specific schema. Multiple attributes can draw from the same domain (e.g., "gpa" and "mingparequired" might both be decimal(0.0,10.0)) while remaining distinct, separately-named attributes.

Edge Cases

  • Two attributes sharing a domain are not automatically comparable or joinable in a meaningful sense — comparing "id" (student-id domain) with "course_credits" (an integer domain) is type-compatible but semantically nonsensical.
  • Atomicity assumption: the classical relational model requires domains to be atomic — no internal structure (e.g., no domain of "list of phone numbers" as a single value). This atomicity requirement is the basis for First Normal Form (1NF).
  • NULL is not a member of any domain. NULL represents the absence of a value, not a value drawn from the domain — this is precisely why NULL needs special-case handling in comparisons, aggregates, and constraints throughout the relational model.

Key Takeaways / Q&A

Q: Is 9.1 a legal value in the domain of "department"? A: No — 9.1 is a decimal number, not a member of the enumerated department-code domain; storing it there would violate domain integrity.

Q: Why must domains be atomic in the classical relational model? A: To guarantee First Normal Form and to keep relational-algebra operations (comparison, join, selection) well-defined over single, indivisible values.

Mock Test

  • Domain - Quick Test

    8 questions on Domain.

    8 questions · 8 min · Medium
    Start Mock Test