ScholarQuill logoScholarQuillUniversity Notes
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
Study Tools
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
Contact
ScholarQuill logo
My Semester
Explore Notes
Past Papers12 New
Video CoursesNew
Search
Settings
GPA/CGPA Calculator
Schedule & To-Do
Student Portal
Contact
ScholarQuill logoScholarQuillUniversity Notes
Study PortalCC-215Entity Relationship Di…
Ctrl + K
Login
Explore
Search
Semester
Papers
CGPA
    CC-215

    Database Systems

    Progress0 / 34 done
    Topics34
    1Basic Database Concepts2Database Approach vs File Based System3Database Architecture4Three Level Schema Architecture5Data Independence6Relational Data Model7Attributes8Schemas9Tuples10Domains11Relation Instances12Keys of Relations13Integrity Constraints14Relational Algebra15Selection in Relational Algebra16Projection in Relational Algebra17Cartesian Product in Relational Algebra18Types of Joins19Normalization20Functional Dependencies21Normal Forms22Entity-Relationship Model23Entity Sets24Attributes in Entity-Relationship Model25Relationship in Entity-Relationship Model26Entity-Relationship Diagrams27Structured Query Language (SQL)28Joins in SQL29Sub-Queries in SQL30Grouping and Aggregation in SQL31Concurrency Control32Database Backup and Recovery33Indexes34NoSQL Systems
    6 min read
    Topic 26 of 34
    Topic Study Note Illustration
    26

    Entity-Relationship Diagrams

    Entity-Relationship Diagrams (ER Diagrams) are a visual representation of the Entity-Relationship Model , which is used for modeling the logical structure of databases. ER diagrams help to...

    Entity-Relationship Diagrams (ER Diagrams)

    Entity-Relationship Diagrams (ER Diagrams) are a visual representation of the Entity-Relationship Model, which is used for modeling the logical structure of databases. ER diagrams help to depict the entities within a system, their attributes, and the relationships between them. They are an essential tool in database design as they allow for the clear visualization of data structures, providing a blueprint for creating and organizing a database.


    Key Components of an ER Diagram

    1. Entities

      • Entities represent real-world objects or concepts that have distinct existence within the database system. Entities are typically represented as rectangles in ER diagrams.
      • Example: In a university system, Student, Course, and Professor are all entities.
    2. Attributes

      • Attributes define the properties or characteristics of an entity or relationship. They are typically represented as ovals connected to their respective entity (or relationship) sets.
      • Types of Attributes:
        • Simple (Atomic) Attribute: Cannot be subdivided further.
        • Composite Attribute: Can be divided into smaller sub-attributes.
        • Derived Attribute: Can be calculated from other attributes.
        • Multi-valued Attribute: Can have multiple values.
      • Example: The entity Student might have attributes like StudentID, Name, DateOfBirth.
    3. Relationships

      • Relationships represent how entities are associated with one another. They are depicted as diamonds in an ER diagram.
      • Relationships can be unary, binary, or ternary, depending on the number of entities they connect.
      • Example: A relationship between Student and Course might be labeled EnrollsIn, representing which students are enrolled in which courses.
    4. Primary Keys

      • The primary key of an entity is an attribute (or set of attributes) that uniquely identifies each instance of an entity.
      • Example: The StudentID attribute in the Student entity could be a primary key.
    5. Cardinality and Participation Constraints

      • Cardinality defines the number of instances of one entity that can be associated with an instance of another entity.
        • One-to-One (1:1): One instance of an entity is related to one instance of another entity.
        • One-to-Many (1:N): One instance of an entity is related to many instances of another entity.
        • Many-to-Many (M:N): Many instances of one entity are related to many instances of another entity.
      • Participation Constraints describe whether every entity must participate in a relationship (total participation) or if some entities can exist without being involved in the relationship (partial participation).

    Types of Relationships in ER Diagrams

    1. Unary (One-to-One) Relationship:

      • A unary relationship exists when an entity is related to itself.
      • Example: An Employee might supervise another Employee. In this case, the relationship Supervises is a unary relationship.
      • Diagram: A single rectangle is connected to itself via a relationship diamond.
    2. Binary (One-to-Many or Many-to-Many) Relationship:

      • One-to-Many (1:N): An entity in the first set can relate to multiple entities in the second set, but an entity in the second set can relate to only one entity in the first set.
        • Example: A Department has many Employees, but each Employee belongs to only one Department.
      • Many-to-Many (M:N): An entity in the first set can relate to multiple entities in the second set, and vice versa.
        • Example: A Student can enroll in many Courses, and each Course can have many Students.
      • Diagram: A binary relationship is shown by a diamond connecting two rectangles.
    3. Ternary Relationship:

      • A ternary relationship involves three different entity sets. These are less common and are used when a relationship cannot be expressed using binary relationships alone.
      • Example: A Project involves multiple Employees and Departments. An Employee works on a Project in a Department.
      • Diagram: A ternary relationship is represented by a diamond connected to three rectangles.

    Example ER Diagram for a University Database

    Let’s consider an example ER diagram for a university system:

    • Entities:

      • Student (with attributes StudentID, Name, Email).
      • Course (with attributes CourseID, CourseName, Credits).
      • Professor (with attributes ProfessorID, Name, Office).
    • Relationships:

      • EnrollsIn (between Student and Course: many-to-many). This relationship tracks which students are enrolled in which courses.
      • Teaches (between Professor and Course: one-to-many). This relationship specifies which professor teaches which course.

    The ER diagram for this system would be represented as follows:

    • Entities (Student, Course, and Professor) as rectangles.
    • Attributes connected to entities using ovals (e.g., StudentID, CourseName).
    • EnrollsIn as a many-to-many relationship (between Student and Course) represented as a diamond.
    • Teaches as a one-to-many relationship (from Professor to Course) represented as a diamond.

    ER Diagram Symbols

    • Rectangle: Represents an entity.
    • Oval: Represents an attribute of an entity or relationship.
    • Diamond: Represents a relationship.
    • Double Rectangle: Represents a weak entity.
    • Double Oval: Represents a multi-valued attribute.
    • Dashed Oval: Represents a derived attribute.
    • Underlined Oval: Represents a primary key attribute.

    Example ER Diagram Representation

    Consider the following textual representation for a Student-Course-Enrollment system:

    • Entities:

      • Student: StudentID, Name, DOB
      • Course: CourseID, CourseName, Credits
      • Professor: ProfessorID, Name, Office
    • Relationships:

      • EnrollsIn: Many-to-many between Student and Course
      • Teaches: One-to-many from Professor to Course

    Diagram Example:

    1. Student (Rectangle)
      • StudentID, Name, DOB (attributes)
    2. Course (Rectangle)
      • CourseID, CourseName, Credits (attributes)
    3. Professor (Rectangle)
      • ProfessorID, Name, Office (attributes)
    4. EnrollsIn (Diamond): Connects Student and Course with a many-to-many relationship.
    5. Teaches (Diamond): Connects Professor and Course with a one-to-many relationship (each professor teaches multiple courses).

    Advantages of ER Diagrams

    1. Clear Visualization: ER diagrams provide a graphical representation of the database structure, which helps in understanding how data is stored, linked, and accessed.
    2. Database Design: They help in designing the database schema by identifying the entities, their attributes, and the relationships between them.
    3. Communication Tool: ER diagrams are useful in communicating the database design to non-technical stakeholders.
    4. Helps in Normalization: By visually representing relationships, ER diagrams assist in identifying redundancy and improving database normalization.

    Conclusion

    Entity-Relationship Diagrams (ER Diagrams) are essential tools in the design and planning of relational databases. They provide a clear, structured, and intuitive way to model and represent data entities, their attributes, and relationships, making them an invaluable resource for database developers and system architects. By understanding the basic components and symbols of ER diagrams, you can effectively design and communicate a well-structured database system.

    ← Previous topic 25
    Relationship in Entity-Relationship Model
    Next topic 27 →
    Structured Query Language (SQL)

    Past Papers

    Open this section to view and download past papers

    Click on Show Past Papers to load available exam papers.

    Reading Progress
    0%
    6mremaining
    1.1kwords
    Intermediatelevel
    On This Page

    No headings found

    Study Toolkit

    Subject Portal

    Database Systems