Skip to main content

Difference between Entity and Attribute Vijay Sinha The Crazy Programmer

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

Comments

Popular posts from this blog

Difference between Web Designer and Web Developer Neeraj Mishra The Crazy Programmer

Have you ever wondered about the distinctions between web developers’ and web designers’ duties and obligations? You’re not alone! Many people have trouble distinguishing between these two. Although they collaborate to publish new websites on the internet, web developers and web designers play very different roles. To put these job possibilities into perspective, consider the construction of a house. To create a vision for the house, including the visual components, the space planning and layout, the materials, and the overall appearance and sense of the space, you need an architect. That said, to translate an idea into a building, you need construction professionals to take those architectural drawings and put them into practice. Image Source In a similar vein, web development and design work together to create websites. Let’s examine the major responsibilities and distinctions between web developers and web designers. Let’s get going, shall we? What Does a Web Designer Do?

A guide to data integration tools

CData Software is a leader in data access and connectivity solutions. It specializes in the development of data drivers and data access technologies for real-time access to online or on-premise applications, databases and web APIs. The company is focused on bringing data connectivity capabilities natively into tools organizations already use. It also features ETL/ELT solutions, enterprise connectors, and data visualization. Matillion ’s data transformation software empowers customers to extract data from a wide number of sources, load it into their chosen cloud data warehouse (CDW) and transform that data from its siloed source state, into analytics-ready insights – prepared for advanced analytics, machine learning, and artificial intelligence use cases. Only Matillion is purpose-built for Snowflake, Amazon Redshift, Google BigQuery, and Microsoft Azure, enabling businesses to achieve new levels of simplicity, speed, scale, and savings. Trusted by companies of all sizes to meet

2022: The year of hybrid work

Remote work was once considered a luxury to many, but in 2020, it became a necessity for a large portion of the workforce, as the scary and unknown COVID-19 virus sickened and even took the lives of so many people around the world.  Some workers were able to thrive in a remote setting, while others felt isolated and struggled to keep up a balance between their work and home lives. Last year saw the availability of life-saving vaccines, so companies were able to start having the conversation about what to do next. Should they keep everyone remote? Should they go back to working in the office full time? Or should they do something in between? Enter hybrid work, which offers a mix of the two. A Fall 2021 study conducted by Google revealed that over 75% of survey respondents expect hybrid work to become a standard practice within their organization within the next three years.  Thus, two years after the world abruptly shifted to widespread adoption of remote work, we are declaring 20