#ER_Diagram

Опубликовано: 17 Октябрь 2024
на канале: Tech Educators
563
16

#ER_Diagram #TypesofAttributes Types of Attributes | Attributes Representation in ER Diagram
An entity set is a set of entities of the same type (e.g., all persons having an account at a bank). Entity sets need not be disjoint. For example, the entity set employee (all employees of a bank) and the entity set customer (all customers of the bank) may have members in common.
A relationship set is a set of relationships of the same type. Formally it is a mathematical relation on (possibly non-distinct) sets. If are entity sets, then a relationship set R is a subset of. where is a relationship. For example, consider the two entity sets customer and account.
1) Attribute:
A real-world property of an entity type is called an attribute. This is the characteristics of an entity. It is represented by an oval or ellipse in E-R diagram. Each attribute can take only a set of permitted values. This is called the domain of that attribute. For example, we define the roll_no of the ‘Student’ by a numeric value. So, the permitted values are only integers and hence, ‘integer’ is the domain of attribute ‘roll_no’. Each attribute is represented by a separate column in a relational table.

For example, The entity ‘Student’ has properties like Name, Address, Roll_no, Mobile_no, Age, DOB, Class, Section, etc. So, when we make an E-R diagram then Name, Address, Roll_no, Mobile_no, Age, DOB, Section and Class are represented as the attributes of the entity type ‘Student’.
There are following types of attributes:
a) Simple Attribute & Composite Attribute
b) Single Valued Attribute & Multi-valued Attribute
c) Stored Attribute & Derived Attribute
d) Key Attribute & Non-key Attribute

a) Simple Attribute & Composite Attribute:
This division is made on the basis that if the attribute can be further divided or not into more attributes. If it cannot be further divided it is a simple attribute and if can be further divided it is a composite attribute.
Simple Attribute:
A simple attribute contains an atomic value which cannot be further divided. It is simply represented by an oval. A simple attribute is directly connected to the entity type. While making the E-R diagram, we directly connect the oval with the rectangle.
For example, Roll_no of Student, Age of Student.
Composite Attribute:
A Composite attribute can be further divided into other attributes. We represent this in E-R diagram by connecting an oval with oval i.e the composite attribute is also represented by oval and the further divided attribute all also represented by ovals. When we convert this E-R diagram to the relational table then we don't have any column of the composite attribute. We have column only for the attribute which came after we further divided the composite attribute.
For example, Name of a student can be further divided into first name, middle name and last name. The composite attribute name is also represented by oval as well as the other attributes are also represented by oval and we connect the all the further divided attributes with the composite attribute. In the table, we will have three columns i.e. First_name, Middle_name, and Last_name. There is no such column called "Name".
b) Single Valued Attribute & Multi-valued Attribute
This division is made on the basis of how many values can be taken by the attribute. If the attribute can take more than one value, it is a multi-valued attribute. If the attribute takes only one value it is a single-valued attribute.
Single-valued Attribute
This attribute has only one value. It is represented by a simple oval. Some simple attribute can also be a single-valued attribute. For example, the Section of ‘Student’ is a simple attribute as it can’t be further divided. Also, it is a single-valued attribute because a student can't study in more than one section.
For example, Section of a Student.
Multivalued Attribute:
This attribute has more than one value. It is represented by a double oval. Some Composite keys can also be a multivalued attribute. For example, the address attribute of a student can further be divided into ‘Locality’, ‘Town’ and ‘PIN’. So, we call it a composite attribute. Also, the address of a student can have more than one value. A Student can have more than one Address i.e Permanent Address and Temporary Address. So, it can also be called a multivalued attribute.
For example, A student can have more than one e-mail address.
c) Stored Attribute & Derived Attribute
Stored Attribute
The value of this attribute should be provided by the user. This attribute is stored and can be used for finding the value of other attributes. It cannot be derived from any other attribute. It is also represented by an oval. For Example, The Date of Birth of ‘Student’ has to be provided by the student.
Example: Date of Birth(DOB)
Derived Attribute:
The value of this attribute is derived from some other attributes.
For example, The value of age attribute is derived from the DOB(date of birth) attribute.
Example: Age