Skip to content
C

Attributes


Attributes

Definition

Attributes are the properties or characteristics that describe an entity or a relationship. If an entity is the "noun," attributes are the descriptive details attached to it. Every entity set has a defined collection of attributes, and every entity (instance) has one value for each attribute, drawn from that attribute's domain (the set of permissible values).

Worked Example

The Student entity set has attributes: RollNo, Name, DateofBirth, Email, PhoneNumber, and CGPA. For one specific student entity, these attributes take concrete values: RollNo = "21CS045", Name = "Aditi Sharma", DateofBirth = "2003-07-14", and so on. The `Enrollment` relationship (linking Student and Course) itself can also carry attributes, such as Grade and EnrollmentDate — showing that attributes are not exclusive to entities.

Edge Cases

  • Attributes come in several flavors, each covered as its own topic in this chapter: simple vs. composite (6.6/6.7), single-valued vs. multi-valued (6.8/6.9), and stored vs. derived (6.10). "Attributes" as a general topic is the umbrella category — none of these subtypes are interchangeable with each other.
  • An attribute's domain constrains its valid values (e.g., CGPA must be a decimal between 0.0 and 10.0). Attempting to assign a value outside the domain is invalid, even before considering database-level constraints.
  • Not every attribute must have a value for every entity — a Phone_Number might be unknown for a newly registered student, represented as NULL. This is different from the attribute simply not existing.
  • Relationships, not just entities, can have attributes (e.g., Grade on Enrollment) — a common point of confusion for beginners who assume only entities carry data.

Key Takeaways / Interview Q&A

Q: Can an attribute belong to a relationship rather than an entity? A: Yes. Descriptive attributes like Grade or Enrollment_Date logically belong to the Enrollment relationship itself, not to Student or Course individually.

Q: What is a "domain" in the context of an attribute? A: The domain is the complete set of legal/permitted values an attribute can take — e.g., the domain of Gender might be {Male, Female, Other}, and the domain of CGPA might be decimals from 0.0 to 10.0.

Q: Are all attributes of an entity mandatory to have a value? A: No — some may be optional and hold NULL when unknown or not applicable, unless a business rule or key constraint makes them mandatory.

Mock Test

  • Attributes - Quick Test

    8 questions on Attributes.

    8 questions · 8 min · Medium
    Start Mock Test