An Attribute is a property or characteristic that describes an entity in a database. It provides specific information used to identify, categorize, and manage entities effectively. Without attributes, entities have no meaningful data.
For example:
Let's take the student as an entity. Students will have multiple attributes such as roll number, name, and class.
These attributes are used to describe the student in more detail.
Simple Attributes are indivisible properties that hold basic information about an entity, such as name, roll number, or age. They cannot be broken down further and are often used to build other types of attributes.
Let's understand this with the help of example:
Here in the below example, Student has roll_no, class, and name as attributes that cannot be divided into more sub-attributes.
These types of attributes are called simple attributes.
Simple attributes are mainly used to create all other types of attributes.
A composite attribute is formed by combining two or more simple attributes. It is used to represent complex data structures, like a full name made of first and last names.
Let's understand this with the help of example:
Here if we look at the below example, address is the attribute derived from the 3 simple attributes i.e. City, State, and Street.
To get the value of the address attribute, we have first to know those city, state, and street attributes.
This type of attribute is known as a composite attribute.
A single-valued attribute contains only one value per entity instance. Mostly these attributes are used to provide the unique identity to the multiple instances of attributes.
Let's understand this with the help of Example:
In the given example, we know that the DOB attribute will have only one value. So we can say that the DOB attribute is nothing but a single-valued attribute and it cannot have multiple attributes.
Here roll_no and name will also have mostly one value only.
We can say that all 3 attributes of the student are single-valued.
A multivalued attribute can have multiple values for one entity instance. Unlike single-valued attributes, it stores several values linked to the entity.
Let's Understand this with the help of Example:
In the given example, Student has an attribute named phone_no. One student can have multiple phone_no, so we can say that phone_no can have multiple values.
These types of attributes are known as multi-valued attributes.
Multi-valued attributes are used when more than 1 entries for one attribute need to be stored in the Database.
A derived attribute is an attribute calculated from other attributes in the database and is not physically stored. Its value is obtained using existing data within the same database.
Let's understand this with help of Example:
Here the student has multiple attributes including DOB and age. It is observed that age can be calculated with the help of the DOB attribute.
So age is a derived attribute that is derived from an attribute named DOB.
Stored attributes are physically stored in the database (unlike derived attributes). They can change (e.g., a studentβs address), but they are stored directly, not calculated.. It stores permanent information that remains fixed throughout the entityβs lifetime.
Let's understand this with the help of example
The student has 3 attributes as shown above. Her name and DOB will remain the same throughout his/her education. So the student has a fixed value attribute that will never change in the future.
A complex attribute is a combination of composite and multivalued attributes. It can contain multiple levels of sub-attributes. Complex attributes can have an unlimited number of sub-attributes.
Let's understand this with the help of Example:
Here for the student, we created an attribute named contact_info which further decomposed into phone_no + Address.
The address is a composite attribute which is further divided into simple attributes and phone_no is a multivalued attribute.
This indicates that the contact_info attribute is made from the multi-valued and composite attribute.
This type of attribute is known as the Complex Attribute.