Types of Attributes in DBMS
Any real-world object is considered to be an entity that has self-existence, and these entities in DBMS have their own characteristics and properties known as attributes in DBMS. Attributes give us additional information about entities and help us to study their relationship within the specified system. Attributes in an ER (Entity Relationship) model is always represented in an elliptical shape. There are different types of attributes in DBMS: Simple, Composite, Single Valued, Multi-Valued, Stored, Derived, Key, and Complex attributes.
Different Types Of Attributes in DBMS
DBMS consists of an ER (Entity Relationship) model, and we generally use it to describe data elements and study their relationships within the specified system. These data elements are also known as entities which are real-world objects with self-existence. We always represent entities in rectangle shapes in DBMS. These entities have their own properties and characteristics defined with the help of attributes. Basically, attributes provide additional information and describe the characteristics & properties of an entity in DBMS. An entity may contain any number of attributes while one of the attributes is considered to be a primary key attribute. An attribute can take its values from a set of possible values for each entity instance in an ER model in DBMS.
We always represent attributes in DBMS in an elliptical shape. We can refer to the above image where we have an ER model diagram, and the student represented in a rectangle shape is our entity object. Student entity has different attributes: Roll_No, Name, DOB, Phone_No, Age, Address, Country, State, City, and Street. Note that to uniquely identify the student entity, we may use the primary key as Roll_No as it is not repeated. Here, Phone_No is a multi-valued attribute represented by a co-centric elliptical shape, and similarly, we will study and learn more about these different types of attributes in detail as we move through the course of this article :)
In DBMS, there are various types of attributes available:
- Simple Attributes
- Composite Attributes
- Single Valued Attributes
- Multi-Valued Attributes
- Derived Attributes
- Complex Attributes (Rarely used attributes)
- Key Attributes
- Stored Attributes
Now, we will study all of these different types of attributes in DBMS in detail along with their diagrams and examples :)
Simple Attributes
Simple attributes in an ER model diagram are independent attributes that can't be classified further and also, can't be subdivided into any other component. These attributes are also known as atomic attributes.
Example Diagram:
As we can see in the above example, the Student is an entity represented by a rectangle, and it consists of attributes: Roll_no, class, and Age. Also, there is a point to be noted that we can't further subdivide the Roll_no attribute and even the other two attributes into sub-attributes. Hence, they are known as simple attributes of the Student entity.
Composite Attributes
Composite attributes have opposite functionality to of simple attributes as we can further subdivide composite attributes into different components or sub-parts that form simple attributes. In simple terms, composite attributes are composed of one or more simple attributes.
Example Diagram
As we can see in the above example, Address is a composite attribute represented by an elliptical shape, and it can be further subdivided into many simple attributes like Street, City, State, Country, Landmark, etc.
Single-Valued Attributes
Single-valued attributes are those attributes that consist of a single value for each entity instance and can't store more than one value. The value of these single-valued attributes always remains the same, just like the name of a person.
Example Diagram:
As we can see in the above example, Student is an entity instance, and it consists of attributes: Roll_no, Age, DOB, and Gender. These attributes can store only one value from a set of possible values. Each entity instance can have only one Roll_no, which is a unique, single DOB by which we can calculate age and also fixed gender. Also, we can't further subdivide these attributes, and hence, they are simple as well as single-valued attributes.
Multi-Valued Attributes
Multi-valued attributes have opposite functionality to that of single-valued attributes, and as the name suggests, multi-valued attributes can take up and store more than one value at a time for an entity instance from a set of possible values. These attributes are represented by co-centric elliptical shape, and we can also use curly braces { } to represent multi-valued attributes inside it.
Example Diagram:
As we can see in the above example, the Student entity has four attributes: Roll_no and Age are simple as well as single-valued attributes as discussed above but Mob_no and Email_id are represented by co-centric ellipse are multi-valued attributes. Each student in the real world can provide more than one email as well as a mobile contact number, and therefore, we need these attributes to be multi-valued so that they can store multiple values at a time for an entity instance.
Derived Attributes
Derived attributes in DBMS are those attributes whose values can be derived from the values of other attributes. They are always dependent upon other attributes for their value.
For example, As we were discussing above, DOB is a single-valued attribute and remains constant for an entity instance. From DOB, we can derive the Age attribute, which changes every year, and can easily calculate the age of a person from his/her date of birth value. Hence, the Age attribute here is derived attribute from the DOB single-valued attribute.
Example Diagram:
Derived attributes are always represented by dashed or dotted elliptical shapes.
Key Attributes
Key attributes are special types of attributes that act as the primary key for an entity and they can uniquely identify an entity from an entity set. The values that key attributes store must be unique and non-repeating.
Example Diagram:
As we can see in the above example, we can say that the Roll_no attribute of the Student entity is not only a simple and single-valued attribute but also, a key valued attribute as well. The Roll_no of a student will always be unique to identify the student. Also note that the Gender and Age of two or more persons can be the same and overlapping in nature and obviously, we can't identify a student on the basis of them. Hence, gender and age are not key-valued attributes.
Complex Attributes
Complex attributes are rarely used in DBMS. They are formed by the combination of multi-valued and composite attributes. These attributes always have many sub-sections in their values.
Example Diagram:
As we can see in the above example, Address_EmPhone (which represents Address, Email, and Phone number altogether) is a complex attribute. Email and Phone number are multi-valued attributes while Address is a composite attribute which is further subdivided as House number, Street, City & State. This combination of multi-valued and composite attributes altogether forms a complex attribute.
Stored Attributes
Values of stored attributes remain constant and fixed for an entity instance and also, and they help in deriving the derived attributes. For example, the Age attribute can be derived from the Date of Birth attribute, and also, the Date of birth attribute has a fixed and constant value throughout the life of an entity. Hence, the Date of Birth attribute is a stored attribute.
Example Diagram:
As we can see in the above image, there are different types of attributes in DBMS, well-slotted for each field for an entity instance.
Conclusion
-
Attributes in DBMS: Attributes in DBMS describe the characteristics of entity instances and their relationships within the system.
-
Variety of Attributes: DBMS encompasses various types of attributes, including simple, composite, single-valued, multi-valued, stored, derived, key, and complex attributes.
-
Representations: Attributes are typically represented in an elliptical shape within an Entity Relationship (ER) model.
-
Primary Key Attribute: Key attributes serve as primary keys, uniquely identifying entity instances within an entity set.
-
Derived and Stored Attributes: Derived attributes derive their values from other attributes, while stored attributes maintain constant values for entity instances.
-
Complexity and Relationships: Complex attributes combine multi-valued and composite attributes, reflecting the intricate nature of data relationships within a database system.