Database Management Systems

Schemas, Architecture & Data Independence

Prepared by: Dr. Mohsin F. Dar
Designation: Assistant Professor, School of Computer Science
Institution: UPES, Dehradun
Target Audience: MT-CSE-I Database Systems

Schemas, Instances, and States

šŸ“š Key Definitions

Schema: The logical structure and design of the database - it's like a blueprint that defines tables, columns, data types, and relationships.

Instance: The actual data stored in the database at any particular moment in time.

Database State: The collection of all instances of all relations in a database at a particular point in time.

šŸ” Additional Important Concepts

Schema Construct: A component of the schema or an object within the schema, e.g., STUDENT, COURSE.

Initial Database State: Refers to the database state when it is initially loaded into the system.

Valid State: A state that satisfies the structure and constraints of the database.

Alternative Terminology:

• Schema is also called intension

• State is also called extension

šŸ“Š Visual Comparison: Schema vs Database State

šŸ—ļø Database Schema

Database Schema Illustration

Structure and organization - remains stable

šŸ“Š Database State

Database State Illustration

Actual data content - changes frequently

-- Schema Definition (DDL)
CREATE TABLE Student (
    StudentID INT PRIMARY KEY,
    Name VARCHAR(50) NOT NULL,
    Age INT CHECK (Age > 0),
    Grade DECIMAL(3,2)
);
Quick Check: What changes more frequently - Schema or Instance?
Schema
Instance

Three-Schema Architecture

šŸ—ļø ANSI/SPARC Three-Schema Architecture

A framework that separates the user applications from the physical database through three levels of abstraction.

šŸ“± EXTERNAL LEVEL (View Level)

Purpose: Individual user views

Components: User-specific schemas, customized views

Example: Student Portal View, Faculty Dashboard

↓ Mapping ↓
🧠 CONCEPTUAL LEVEL (Logical Level)

Purpose: Community view of entire database

Components: All entities, relationships, constraints

Example: Complete university database schema

↓ Mapping ↓
šŸ’¾ INTERNAL LEVEL (Physical Level)

Purpose: Physical storage and access methods

Components: Storage structures, indexes, access paths

Example: B+ tree indexes, file organization

šŸŽÆ Real-World Example: University Database
-- External Schema (Student View)
CREATE VIEW StudentGrades AS 
SELECT Name, CourseName, Grade 
FROM Student S, Enrollment E, Course C 
WHERE S.StudentID = E.StudentID 
AND E.CourseID = C.CourseID;

-- Conceptual Schema (Complete Logical Design)
CREATE TABLE Student (...);
CREATE TABLE Course (...);
CREATE TABLE Enrollment (...);
-- All relationships and constraints

-- Internal Schema (Physical Implementation)
-- Index on StudentID for faster lookups
CREATE INDEX idx_student_id ON Student(StudentID);
-- Clustered storage for related records

Data Independence

šŸ”“ Freedom from Data Structure Changes

Data Independence is the ability to change the schema at one level without affecting the schema at the next higher level.

šŸŽÆ Logical Data Independence

Definition: Ability to change conceptual schema without affecting external schemas

Examples:

  • Adding new tables
  • Adding new attributes
  • Changing relationships

šŸ’¾ Physical Data Independence

Definition: Ability to change internal schema without affecting conceptual schema

Examples:

  • Changing storage structures
  • Adding/removing indexes
  • Changing file organization
Which type of data independence is easier to achieve?
Logical Independence
Physical Independence

Interactive Knowledge Check

1. What defines the structure of a database?
Instance
Schema
State
View
2. In Three-Schema Architecture, which level deals with storage details?
External Level
Conceptual Level
Internal Level
Application Level
3. Adding an index to improve query performance is an example of?
Logical Independence
Physical Independence
Schema Modification
View Update