Entities, Entity Sets, and Attributes

24
0

Introduction

Designing a database begins with identifying what information it needs to represent. A college database, for example, might store information about students, courses, and teachers, along with details such as their names, identifiers, and contact information.

The Entity–Relationship (ER) model organizes these requirements using entities, entity sets, and attributes. These concepts help us identify the objects a database represents, group similar objects, and describe their properties before creating tables.

Entities and Entity Sets

An entity is a distinguishable real-world object or concept about which a database stores information. It may be a person, a physical object, an event, or an abstract concept.

For example, a particular student, a specific library book copy, and an individual course can each be represented as an entity.

Consider the following student data:

StudentID

Name

DateOfBirth

S101

Asha

12 April 2005

S102

Ravi

3 November 2004

S103

Meera

19 July 2005

The student identified by S101 is one entity. The student identified by S102 is another. Even if two students have the same name, they remain separate entities.

An entity set is a collection of entities of the same type at a particular time. The students represented in the table belong to the STUDENT entity set. Adding a new student changes the membership of this set.

Entity and Entity Set

Entity and Entity Set

Entity Type and Entity Set

An entity type defines the common structure of similar entities, including their attributes. An entity set contains the actual entities represented at a given time.

For example, the STUDENT entity type defines attributes such as StudentID, Name, and DateOfBirth. The students Asha, Ravi, and Meera are members of its current entity set.

Concept

What it represents

Student database example

Entity

One distinguishable object

The student identified by S101

Entity type

The definition shared by similar entities

STUDENT with its defined attributes

Entity set

A collection of entities of that type

All students currently represented

An entity type describes the structure; the membership of its entity set can change as information is added or removed.

Attributes and Their Types

An attribute describes an entity. For a student, Name is an attribute and Asha is its value. Each attribute has a domain, which defines its permitted values. For example, valid dates for DateOfBirth.

Simple Attribute

A simple attribute has no smaller components within the model. For example, Gender is treated as one indivisible attribute.

Symbol: A single oval.

Composite Attribute

A composite attribute contains smaller components. For example, Address can be divided into Street, City, and PostalCode.

Symbol: An oval connected to its component ovals.

Single-Valued Attribute

A single-valued attribute holds at most one value for each entity at a given time. For example, a student has one DateOfBirth.

Symbol: A single oval, as used for a simple attribute.

Multivalued Attribute

A multivalued attribute can hold several values for one entity. For example, PhoneNumber may contain multiple contact numbers for a student.

Symbol: A double oval.

Stored Attribute

A stored attribute has a value recorded directly in the database. For example, DateOfBirth is stored in the database, while Age is a derived attribute because it is calculated from DateOfBirth rather than stored directly.

Symbol: A single oval, as used for a simple attribute.

Derived Attribute

A derived attribute is calculated from other information. For example, Age is calculated using DateOfBirth and a reference date.

Symbol: A dashed oval.

Key Attribute

A key attribute uniquely identifies an entity within an entity set. For example, StudentID distinguishes students even when they have the same name.

Symbol: An oval with the attribute name underlined.

Optional Attribute

An optional attribute may have no value for some entities. For example, MiddleName may be absent for a student.

Symbol: An ordinary oval. Optionality is documented separately.

Types of Attributes

Types of Attributes

Summary

An entity is a distinguishable object, an entity set groups similar entities, and attributes describe their properties. Attributes can be simple, composite, single-valued, multivalued, stored, or derived. Key attributes identify entities uniquely, while optional attributes may have no value.

CS Core

Read Similar Blogs

Comments0