Schema in DBMS: Definition, Types, and Examples

What is a Schema?

A schema in a Database Management System (DBMS) defines the logical structure of a database, including its tables, relationships, constraints, views, indexes, and permissions. It acts as a blueprint that dictates how data is organized and how different entities interact.

Key Characteristics of a Schema

Logical structure – Defines how data is stored and related.
Includes constraints – Specifies rules (e.g., primary keys, foreign keys).
Does not store data – Acts as a framework for data storage.
Can be modified – Using ALTER SCHEMA or ALTER TABLE.


Types of Database Schemas

A DBMS schema can be divided into different levels based on the ANSI-SPARC three-tier architecture:

  1. Physical Schema (Internal Level) – Storage details
  2. Logical Schema (Conceptual Level) – Data structure & relationships
  3. View Schema (External Level) – User-specific views

1. Physical Schema (Internal Schema)

🔹 Definition: Describes how data is physically stored on hardware (disks, SSDs).
🔹 Includes: File organization, indexing methods, access paths.
🔹 Users: Database administrators (DBAs) & system engineers.

💡 Example:

  • Data is stored in B-trees, hash indexes, or tablespaces.
  • Indexing is used to speed up retrieval.

2. Logical Schema (Conceptual Schema)

🔹 Definition: Defines the structure of the database (tables, attributes, relationships).
🔹 Includes:

  • Tables & fields (Employee(id, name, department))
  • Relationships (One-to-Many between Employee & Department)
  • Constraints (Primary key, foreign key, NOT NULL)
    🔹 Users: Database developers, architects.

Defines the Employee table structure with a foreign key linking it to the Department table.

3. View Schema (External Schema)

🔹 Definition: Defines how different users see the database.
🔹 Includes:

  • User permissions (HR sees salaries, but employees don’t).
  • Custom views for business intelligence and reporting.
    🔹 Users: End-users, business analysts, security teams.
  • Creates a custom view that only shows salary details for a specific department.

Other Types of Schemas in DBMS

Schema TypeDescriptionExample
Star SchemaA single fact table connected to multiple dimension tablesData warehouses, OLAP
Snowflake SchemaA normalized version of a star schemaComplex analytics
Fact ConstellationMultiple fact tables sharing common dimension tablesLarge-scale BI applications
ER Model SchemaUses Entity-Relationship diagrams to model relationshipsDatabase design phase

Comparison Table: Physical vs. Logical vs. View Schema

FeaturePhysical SchemaLogical SchemaView Schema
FocusHow data is storedData structure & relationshipsUser-specific views
IncludesFiles, indexes, partitionsTables, relationships, constraintsCustom reports, security filters
UsersDBAs, System EngineersDevelopers, ArchitectsEnd-users, Analysts

Schema Modification (ALTER SCHEMA Commands)

Modify Table Structure (Logical Schema Change)

Conclusion

  • The Physical Schema handles storage details.
  • The Logical Schema defines tables, relationships, and constraints.
  • The View Schema provides user-specific data access.
  • Different schemas like Star, Snowflake, and Fact Constellation are used in data warehouses.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *