Entity in DBMS (Database Management System)

1. What is an Entity?

An entity in a Database Management System (DBMS) represents a real-world object that has a distinct identity. It can be anything that exists physically or logically and can be stored in a database.

Example:

  • A Student in a university database.
  • A Car in a vehicle registration system.
  • A Book in a library management system.

2. Types of Entities

1. Strong Entity

  • An entity that can exist independently in the database.
  • It has a primary key that uniquely identifies each record.

Example:

  • Student (Student_ID, Name, Age)Student_ID is the primary key.

Representation:

  • Represented as a rectangle in the ER diagram.

2. Weak Entity

  • An entity that cannot exist independently and depends on a strong entity.
  • It does not have a primary key, but it has a partial key.
  • It is connected to a strong entity through a relationship (with total participation).

Example:

  • Dependent (Dependent_Name, Age, Employee_ID) → Employee_ID is a foreign key.

Representation:

  • Represented as a double rectangle in the ER diagram.

3. Entity Set

  • A collection of similar entities in the database.
  • Example: All students in a university form a Student Entity Set.

Notation:

  • Entity sets are represented by rectangles in an Entity-Relationship (ER) diagram.

4. Attributes of an Entity

Each entity has attributes that define its characteristics.

Types of Attributes:

  1. Simple (Atomic) Attribute: Cannot be divided further.
    • Example: Student_Name, Age.
  2. Composite Attribute: Can be broken into smaller sub-attributes.
    • Example: Name (First Name, Last Name).
  3. Derived Attribute: Derived from other attributes.
    • Example: Age (derived from Date of Birth).
  4. Multivalued Attribute: Can have multiple values.
    • Example: Phone Numbers.
  5. Key Attribute: Uniquely identifies an entity.
    • Example: Student_ID.

5. Relationship Between Entities

Entities are connected through relationships in the database.

Types of Relationships:

  1. One-to-One (1:1): Each entity in Set A is related to one entity in Set B.
    • Example: A Person has one Passport.
  2. One-to-Many (1:M): One entity in Set A is related to many entities in Set B.
    • Example: A Teacher teaches many Students.
  3. Many-to-Many (M:M): Many entities in Set A are related to many entities in Set B.
    • Example: Students enroll in multiple Courses.

6. Entity vs. Table

FeatureEntityTable
DefinitionA real-world object with attributes.A structured format to store entity data.
RepresentationER Diagram (Rectangle).Rows & Columns in a database.
ExampleStudent entity with Student_ID, Name, Age.Students table storing multiple records.

7. Example ER Diagram

Scenario: University Database

  • Entities:
    • Student (Student_ID, Name, Age)
    • Course (Course_ID, Course_Name)
  • Relationship:
    • Student Enrolls in Course (Many-to-Many)

8. Conclusion

  • An entity is a real-world object stored in a database.
  • Strong entities exist independently, while weak entities depend on others.
  • Entities have attributes, and they form entity sets.
  • Relationships define how entities are connected.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *