Lec-15: Types of Attributes in ER Model | Full Concept | DBMS in Hindi
Types of Attributes in Relational Databases
Introduction to Attributes
- The discussion begins with an overview of the types of attributes in relational databases, particularly focusing on their significance in entity-relationship models compared to relational models.
Single vs. Multi-Valued Attributes
- An attribute is defined as a characteristic or property of an entity, such as a student. Examples include name, roll number, and address.
- A single-valued attribute has only one value; for instance, a student's registration number is unique and cannot have multiple values.
- Registration numbers serve as identifiers for students, ensuring uniqueness even among those with similar names or addresses.
- In contrast, multi-valued attributes can hold more than one value. For example, a student may have multiple mobile numbers or addresses (permanent and correspondence).
- Multi-valued attributes are represented in ER models with double ellipses while single-valued attributes use single ellipses.
Simple vs. Composite Attributes
- Simple attributes cannot be divided further; age is cited as an example since it represents a singular value that cannot be broken down.
- Composite attributes consist of multiple components; for instance, a student's full name includes first name, middle name, and last name.
Stored vs. Derived Attributes
- Stored attributes have fixed values that cannot be derived from other data; date of birth is provided as an example.
- Derived attributes are calculated from other data points; age can be derived from the date of birth by subtracting it from the current date.
- The process of deriving age through calculation illustrates how systems automate this function on web pages when users input their date of birth.
Representation of Attributes
- There’s no specific representation for stored attributes but derived attributes are depicted using dotted ellipses in ER diagrams.
Understanding Key Attributes in Databases
Definition of Key Attributes
- A key attribute is defined as an attribute used to uniquely identify each row in a database table.
- The concept of uniqueness is crucial; for example, in a student database, attributes like names or addresses may not be unique, but the registration number is always unique.
Examples of Key and Non-Key Attributes
- In a student data context, while names and mobile numbers can repeat among students, the registration number remains unique across all entries.
- Different institutions may use various identifiers (e.g., roll numbers or SSN) as key attributes that ensure uniqueness.
Representation of Attributes
- Key attributes are represented with an underline in Entity-Relationship (ER) models, indicating their uniqueness. Non-key attributes do not have this representation and can be repeated.
- Non-key attributes may have values that are either unique or non-unique without any guarantee of repetition. This contrasts with key attributes which must always be unique.
Required vs Optional Attributes
- Required attributes are mandatory fields that must contain values; for instance, a student's name is typically required during admission processes. Optional attributes can be left blank initially but may need to be filled later on (e.g., address).
- The distinction between required and optional attributes does not strictly belong to ER models but is relevant in practical applications such as web forms where certain fields are marked as mandatory.
Complex Attributes Explained
- Complex attributes combine composite and multi-valued characteristics; for example, if a student has multiple residential addresses or phone numbers associated with those addresses, it illustrates complexity within the data structure.