Resources | Subject Notes | Computer Science | Lesson Plan
This section explores the fundamental concepts of database design and how Entity-Relationship (E-R) diagrams are used to visually represent and document these designs. E-R diagrams are crucial for planning and creating efficient and well-structured databases.
A database is an organized collection of data, typically stored and accessed electronically. Databases are used to store information persistently and allow for efficient retrieval, modification, and management of that information. Examples include customer databases, product databases, and library databases.
An entity is a real-world object, person, place, thing, or concept that we want to store information about in a database. Entities are represented by rectangles in an E-R diagram.
An attribute is a characteristic or property of an entity. Attributes describe the entity. They are represented by ovals connected to the entity rectangle.
A relationship represents an association between two or more entities. Relationships are represented by diamonds in an E-R diagram. Relationships have a cardinality that defines how many instances of one entity can be related to instances of another entity.
Cardinality specifies the number of instances of one entity that can be related to the number of instances of another entity. Common cardinalities include:
An E-R diagram is a visual representation of the entities, attributes, and relationships in a database. It provides a high-level overview of the database structure.
E-R diagrams use specific symbols to represent different components:
The process of creating an E-R diagram involves identifying the entities, their attributes, and the relationships between them. This is often done by analyzing the requirements of the database.
Consider a library database. The entities might include Book, Author, and Member. A Book has attributes like BookID, Title, and ISBN. An Author has attributes like AuthorID, Name, and Nationality. A Member has attributes like MemberID, Name, and Address. Relationships would show that a Book is written by an Author (one-to-many: one author can write many books) and a Member borrows a Book (many-to-many: one member can borrow many books, and one book can be borrowed by many members).
Once an E-R diagram is created, it can be used to design the database schema. This involves translating the entities into tables, the attributes into columns, and the relationships into foreign keys. The E-R diagram provides a clear blueprint for the database structure.