Attributes:
An attribute is a property or characteristic that describes an entity in a database.
- Each entity type has a set of attributes that provide specific information about the entity.
Example: For the entity type “Student,” attributes could be “Student ID,” “Name,” “Date of Birth,” and “Course.”
Types of Attributes:
Attributes can be categorized into several types based on their characteristics and the type of data they represent:
- Atomic (Simple) vs. Composite attributes
- Single-Valued vs. Multi-Valued attributes
- Derived vs. Stored attributes
- Key Attributes
- Null Attributes
1.) Atomic (Simple) vs. Composite attributes
An attribute that cannot be divided into smaller independent attribute is called as atomic attribute.
- These attributes contain single, straightforward values.
- They represent the smallest unit of information and are not composed of sub-attributes.
Example:
- “Age” is a simple attribute because it’s a single value that can’t be broken down into smaller components.
- “Gender” is another simple attribute that represents a singular value.
An attribute that can be divided into smaller independent attribute is know as composite attribute.
Example:
- “Full Name” is a composite attribute, which can be divided into “First Name” and “Last Name.”
- “Address” is another composite attribute that can be broken down into “Street,” “City,” “State,” and “Zip Code.”
2.) Single-Valued vs. Multi-Valued attributes
An attribute that holds only single value for an entity is known as single valued attribute.
Example:
- “Age” is a single-valued.
- “Date of Birth” is another example of a single-valued attribute, as each person has exactly one date of birth.
An attribute that holds multiple values for a single entity is known as multi valued attribute.
Example:
- “Phone Numbers” is a multi-valued attribute, as a person may have multiple phone numbers (e.g., home phone, work phone, and mobile phone).
- “Email Addresses” is another example, where a person can have multiple email addresses.
3.) Derived vs. Stored attributes
An attribute that can be derived from another attribute is known as Derived Attribute.
- The value of a derived attribute is not stored in the database.
- It saves storage space and ensures consistency by deriving data from existing attributes.
Example:
- “Age” is a derived attribute that can be calculated from the “Date of Birth.”
An attribute that cannot be derived from another attribute is known as Stored Attribute.
- The values of stored attributes are directly stored in the database tables.
Example:
- “Date of Birth” is a stored attribute, as the actual value is stored in the database and used to derive the “Age.”
- “Salary” is another stored attribute.
4.) Key Attributes
An attribute that has unique value of each entity is known as key attribute.
- These attributes hold unique values for each entity, making it possible to identify each entity uniquely.
Example:
- “Student ID” is a key attribute, as it uniquely identifies each student.
- “Employee ID” is a key attribute in the employee database, ensuring each employee has a unique ID.
5.) Null Attributes
An attribute that do not hold any value for an entity is known as null attribute.
Example:
- “Middle Name” can be a null attribute if a person doesn’t have a middle name.
- “Spouse Name” can also be a null attribute for individuals who are unmarried.