Schema Diagram

A schema diagram is a visual representation of a database schema. It shows tables, attributes, primary keys, foreign keys, and relationships between tables.

1. What is a Schema Diagram?

A schema diagram illustrates the logical structure of a database. It helps users understand how tables are connected and how data flows.

2. Components of Schema Diagram

3. Representation of a Table

STUDENT
---------------------
RollNo (PK)
Name
CourseID (FK)

4. Schema Diagram Example

STUDENT
---------------------
RollNo (PK)
Name
CourseID (FK)
        |
        |
        β–Ό
COURSE
---------------------
CourseID (PK)
CourseName

Here, CourseID in STUDENT is a foreign key that references CourseID in COURSE.

5. Relationship Types in Schema Diagram

1:M β†’ COURSE ─── STUDENT
M:N β†’ STUDENT ─── COURSE (using ENROLL table)

6. Schema Diagram for Many-to-Many Relationship

STUDENT               ENROLL                COURSE
---------             -----------           --------
RollNo (PK)  ←──┐     RollNo (FK)     β”Œβ”€β”€β†’  CourseID (PK)
Name               CourseID (FK)      |      CourseName
                   (PK: RollNo, CourseID)

7. Advantages of Schema Diagram

8. ER Diagram vs Schema Diagram

ER Diagram                     Schema Diagram
----------------------------   -----------------------------
Conceptual design              Logical design
Entities & relationships       Tables & keys
High-level                     Implementation-level

Practice Questions

  1. What is a schema diagram?
  2. List components of schema diagram.
  3. Draw schema diagram for Student–Course system.
  4. Differentiate ER diagram and schema diagram.
  5. How is M:N relationship represented in schema diagram?

Practice Task

Draw schema diagrams for: βœ” Library management system βœ” Hospital database βœ” College database