Attributes:
Entities are represented by means of their properties, called attributes. All attributes have values. For example, the student entity may have name, class and age as attributes.
There exists a domain or range of values that can be assigned to attributes. For example, a student’s name cannot be a numeric value. It has to be a alphabetic. A Student’s age cannot be negative, etc.
Types of Attributes:
1. Simple Attribute:
Simple Attributes are atomic values, which cannot be divided further. For example, a student’s phone number is an atomic value of 10 digits.
2. Composite Attribute:
Composite Attributes are made of more than one Simple Attribute. For example, a student’s complete name may have first_name and last_name. is an atomic value of 10 digits.
3. Single-Valued Attribute:
It is defined as an attribute that holds a single value for a single entity. The majority of the Attributes are single-valued for a particular entity. For example, the attribute Roll_No. is a single-valued attribute.
4. Multi-Valued Attribute:
It is defined as an attribute that holds multiple values for a single entity. For example, for a ‘student’ entity, if one of the attributes is ‘Hobby’ then ‘Hobby’ can have multiple values like reading, dancing, singing and so on.
5. Derived Attribute:
Derived attributes are attributes that do not exist in the physical database, but their values are calculated or inferred from other attributes present in the database. For example, the average_salary in a department should not be stored directly in the database; instead, it can be derived from individual salary values. Another example is age, which can be derived from the date_of_birth attribute.
Domain of Attributes:
A domain is akin to a datatype and is system-defined. It represents a simple set of values such as integer or character that can be associated with attributes in a database. Each attribute is linked to a set of values known as the domain of that attribute. For instance, the domain for the attribute “age” might be defined as the range 1-100, and for the attribute “Day,” it could consist of the values (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday).
In this context, a domain serves as a constraint, limiting the acceptable data values for a relational attribute. Domains can be categorized as atomic or non-atomic based on whether they represent indivisible or composite values.
1. Atomic Domain:
An atomic domain is like a basic building block where the elements cannot be further divided. Think of it as an indivisible unit. For instance, the set of integers is an atomic domain because each integer is considered as a whole and cannot be broken down into smaller parts.
2. Non-Atomic Domain:
On the other hand, a non-atomic domain involves sets that can be broken down into smaller elements. For example, the set of sets of integers is a non-atomic domain. In this case, each set within the larger set is made up of individual integers, making it non-atomic as it involves more than just basic, indivisible units.