DBMS
DBMS
2. Domain Constraint
A domain constraint specifies that the value of each attribute (column) must be from a specific, predefined set of valid values — known as attribute's domain.
• Every attribute in a relation has a domain which defines the type of values (e.g., integer, string, date) it can take.
• If a value outside this domain is inserted, the domain constraint is violated.
Example:
Consider a relation:
STUDENT(RollNo INT, Name VARCHAR, Age INT)
• Domain of Age is integers from 0 to 120
• Inserting Age = 'abc' or Age = -5 violates the domain constraint.
Single-Level Example
• Data File: 30,000 records, 3000 blocks.
• Primary Index: 3000 index entries.
• Index File: 45 blocks (Ri = 15B, B = 1024 → bfri = 68)
• Binary search: log₂(45) = 7 accesses + 1 = 8 accesses total.
Multi-Level Example
• Same Index File (First-Level): 3000 entries → 45 blocks.
• Second-Level Index: 1 entry per 45 blocks → ~1 block (fits in memory).
• Access cost: log₂(1) + log₂(45) + 1 = 0 + 7 + 1 = 8 accesses.
• If first-level was larger (e.g., 100,000 entries), this advantage increases drastically.