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.
- Represents tables and relationships
- Shows primary and foreign keys
- Helps in database design and maintenance
2. Components of Schema Diagram
- Tables (Relations)
- Attributes (Columns)
- Primary Keys (PK)
- Foreign Keys (FK)
- Relationships
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
- One-to-One (1:1)
- One-to-Many (1:M)
- Many-to-Many (M:N)
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
- Easy visualization of database structure
- Helps in identifying relationships
- Improves database documentation
- Useful for developers and DBAs
8. ER Diagram vs Schema Diagram
ER Diagram Schema Diagram ---------------------------- ----------------------------- Conceptual design Logical design Entities & relationships Tables & keys High-level Implementation-level
Practice Questions
- What is a schema diagram?
- List components of schema diagram.
- Draw schema diagram for StudentβCourse system.
- Differentiate ER diagram and schema diagram.
- How is M:N relationship represented in schema diagram?
Practice Task
Draw schema diagrams for:
β Library management system
β Hospital database
β College database