Entity, Attribute, Relationship in DBMS
In a Database Management System (DBMS), especially when using the Entity-Relationship (ER) model, we break down real-world data into entities, describe their properties (attributes), and define how they are related. This helps in organizing and designing a meaningful database structure.
1. Entity
- An entity is a real-world object or concept that can be uniquely identified and stored in a database.
- Entities can be physical (like a student, car, or building) or conceptual (like a course, department, or salary).
- Each entity is represented by a row in a table.
Types of Entities:
Â
- Strong Entity: Has a primary key and exists independently.
Â
- Weak Entity: Does not have a primary key on its own and depends on another entity (usually has a foreign key).
2. Attribute
- An attribute is a property or characteristic of an entity.
- Attributes define data fields in a table and give more information about an entity.
- Each attribute maps to a column in a table.
Types of Attributes:
Â
- Simple (Atomic): Cannot be divided further (e.g., Age, RollNo).
Â
- Composite: Can be divided into subparts (e.g., FullName → FirstName, LastName).
Â
- Derived: Can be derived from other attributes (e.g., Age from Date of Birth).
Â
- Multivalued: Can hold multiple values (e.g., PhoneNumbers).
3. Relationship
- A relationship is an association between two or more entities.
- It describes how entities interact or are linked with one another.
- Represented by a diamond shape in ER diagrams.
Types of Relationships:
Â
- One-to-One (1:1): One entity of A is related to one entity of B.
Example: Each employee has one unique parking spot.
Â
- One-to-Many (1:N): One entity of A is related to many entities of B.
Example: One teacher teaches many students.
Â
- Many-to-Many (M:N): Many entities of A are related to many entities of B.
Example: Students enroll in many courses and each course has many students.
Summary Table
Concept | Description | Real-World Example |
---|---|---|
Entity | Object/concept with an independent existence | Student, Course, Department |
Attribute | Property or detail of an entity | RollNo, Name, Credits |
Relationship | Association between two or more entities | Student “enrolled in” Course |
Conclusion
Â
Understanding entities, attributes, and relationships is the foundation of designing ER diagrams and building normalized relational databases. These components ensure data is well-organized, efficient, and reflective of the real world.