DIGITAL ELECTRONIC

In this article, we will have a look at the difference between Entity and Attribute, which form the core principles of the Entity-Relationship Model in Database Management System. We will look at the description of each in detail with examples and compare them for a clear idea.

Entity

An Entity is defined as any object which has a real-time existence. Moreover, an object is only considered as an Entity if it is easily identifiable among all other objects. In the context of DBMS an entity typically represents data in an RDBMS. It is an object about which we store or retrieve data from the database. Now, the entities that share the same set of properties coalesce into an Entity Set.

We represent an entity set as a relation or a table in Relational Database Management System. So, Each row in a table represents an entity and the table itself represents an entity set. Therefore, to maintain integrity and avoid ambiguity, it is essential that all entities (rows) are unique and must not be replicas of each other.

Entity Types

There are in general two types of entities:

  • Strong Entity: A Strong Entity is an entity that does not depend on another entity. In the context of RDBMS, a Strong Entity contains the Primary Key of the Table. In ER Model we represent a Strong Entity via a Rectangular box.

  • Weak Entity: A Weak Entity is one that always depends on another entity or parent entity. Hence, it has no Primary Key to uniquely identify it in the table. A doubly rectangular box usually represents a Weak Entity in ER Model.

Now, let us understand the above-discussed points with some examples.

Suppose we have a table Student which contains the following records:

STUDENT

_ID

ROLL

_NO

STUDENT

_NAME

ADMISSION

_YEAR

CONTACT

_NO

DATE

_OF_BIRTH

101 1 Sean Wright 2017 9867435573 1999/10/20
102 2 Ken Wilson 2018 3546587556 2000/11/19
103 3 Robert Harris 2018 6476585648 2000/03/07

Explanation:

Here each record in the Student Table represents a Student Object or Entity which exists in real-time. All the records together represent an Entity Set i.e Student Table. So, we see there are 3 entities in the above table. We see for the Student Entities with names ‘Ken’ and ‘Robert’ the ADMISSION_YEAR is the same but they are uniquely identifiable because of their STUDENT_ID and ROLL_NO. Hence, this makes the Student Table a Strong Entity Set.

Now, a Weak Entity is dependent on another entity. So in databases, we represent weak entities that reference other tables or parent tables. In simpler terms, a weak entity has a key that refers to the primary key of another table to exist. Such keys are called Foreign Key.

Attribute

An attribute describes the characteristics or properties of an entity. Like all entities combine to form an Entity Set, similarly a fixed set of attributes combining define an entity type. For each entity, certain properties describe them and even help to uniquely identify the entities. For Example, In the above Student Table, each column or value like the STUDENT_ID, ROLL_NO, STUDENT_NAME, etc are the attributes that define each Student Entity. Each attribute in a table accepts a set of values over a certain domain. In an entity, each attribute is allowed to have only one value which could be a number, text, date, etc. (defined in respective SQL Database Server )In simpler terms, every column header in a table is an Attribute.

Attribute Types

Hence, there are different types of attributes that define an entity:

  • Simple Attribute: This attribute cannot be divided any further into its subtypes. These attributes can contain Null values. Ex: In the above table, STUDENT_ID and ROLL_NO are simple attributes.
  • Composite Attribute: Composite Attributes are a combination of more than one attribute or simple attributes. Ex: In the Student Table the STUDENT_NAME Column can be subdivided consisting – FIRST_NAME, MIDDLE_NAME, LAST_NAME that can collectively form a name of Student. Similarly, there can be an Address Column for a Composite Attribute having City, Street, and PinCode Columns.
  • Single Valued Attribute: These attributes allow only one or a single value. These attributes are different from Simple Attributes and usually form the key or Primary Key which uniquely identifies an entity. For an entity, there cannot be multiple values for this column or attribute. For Ex: STUDENT_ID and ROLL_NO are unique and Single Valued attributes in Student Table.
  • Multi-Valued Attribute: These attributes can contain more than one value at a time. It can be a composite attribute. Ex: The CONTACT_NO Column in Student Table has only one value for each entity, but it can be Multi-Valued as a student can have more than one Contact Number.
  • Derived Attribute: The derived attribute are those attributes that may or may not exist in the physical database. Its value gets derived from other attributes, or we can say that it depends on other database attributes for the data. Ex: In the Student Table we have Column DATE_OF_BIRTH through which we can derive an Attribute AGE by getting the current date. So AGE can be an example of a Derived Attribute. distinguish

Difference between Entity and Attribute

Now, let’s summarize the key differences between an Entity and an Attribute.

Criteria Specification Entity Attribute
Definition It is a distinguishable object having a real-time existence. It is the property that defines the elementary structure of an entity type.
ER Model Representation In ER Model we represent an entity in a Rectangular Box. In ER Model we represent an Attribute in an Oval Bounded Region.
Table Representation Each row or record in a table is treated as an entity. Here, each column header defines an attribute.
Types Entities are generally of two types: Strong Entity and Weak Entity. Attributes are generally of 5 types: Simple, Composite, Single-Valued, Multi-Valued, Derived.
Use A group of entities defines an Entity set, represented in the database using tables. A group of attributes identifies an entity and usually forms the Key in the table.
Functionality Entities represent the main objects of the RDBMS. Attributes represent the characteristics or standards to define an entity.

So, that’s all about the article we had a detailed look at each topic and summarized the key differences between them.

You can leave your suggestions/doubts in the comment section below.

The post Difference between Entity and Attribute appeared first on The Crazy Programmer.



from The Crazy Programmer https://ift.tt/3tnt8Vn

Post a Comment

[blogger]

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget