Data Independence in DBMS: Physical & Logical with Examples

โšก Smart Summary

Data Independence is a property of DBMS that lets the schema at one level change without forcing a change at the next higher level. It comes in two forms, physical and logical, and keeps data separated from the programs that use it.

  • ๐Ÿงฉ Core Idea: A change at one schema level is absorbed by mappings, so higher levels and application programs stay untouched.
  • ๐Ÿ’พ Physical Independence: Storage devices, file organization, and indexes can change without affecting the conceptual schema.
  • ๐Ÿ—‚๏ธ Logical Independence: Entities and attributes can be added or altered without rewriting external views or programs.
  • ๐Ÿ›๏ธ Three Levels: Physical, conceptual, and external schemas provide the layers that independence separates.
  • โš–๏ธ Relative Difficulty: Physical independence is easy to achieve; logical independence is harder because programs depend on logical structure.
  • ๐Ÿ”— Mappings: Conceptual-internal and external-conceptual mappings are what make each kind of independence possible.
  • โœ… Benefit: Lower maintenance cost, better security, and developers focused on design rather than storage.

Data Independence in DBMS

What is Data Independence in DBMS?

Data Independence is defined as a property of DBMS that helps you change the database schema at one level of a database system without requiring a change to the schema at the next higher level. Data independence helps you keep data separated from all the programs that make use of it.

You can use this stored data for computing and presentation. In many systems, data independence is an essential function for the components of the system.

Types of Data Independence

In DBMS there are two types of data independence:

  1. Physical data independence.
  2. Logical data independence.

Both types rest on the layered design of a database, so it helps to review those levels first.

Levels of a Database

Before we learn about data independence, a refresher on database levels is important. The database has three levels, as shown in the diagram below:

  1. Physical / Internal
  2. Conceptual
  3. External
Levels of DBMS architecture diagram
Levels of DBMS Architecture Diagram

These are the same layers described in detail under DBMS schemas. Consider an example of a university database. At the different levels, the implementation looks like this:

Type of Schema Implementation
External Schema

View 1: Course_info(cid:int, cname:string)

View 2: student_info(id:int, name:string)

Conceptual Schema
Students(id: int, name: string, login: string, age: integer)
Courses(id: int, cname: string, credits: integer)
Enrolled(id: int, grade: string)
Physical Schema
  • Relations stored as unordered files.
  • Index on the first column of Students.

Physical Data Independence

Physical data independence helps you separate the conceptual level from the internal or physical level. It allows you to provide a logical description of the database without the need to specify physical structures. Compared to logical independence, it is easy to achieve physical data independence.

With physical independence, you can change the physical storage structures or devices without any effect on the conceptual schema. Any change made is absorbed by the mapping between the conceptual and internal levels. Physical data independence is achieved by the presence of the internal level of the database and the transformation from the conceptual level to the internal level.

Examples of Changes Under Physical Data Independence

Because of physical independence, none of the changes below will affect the conceptual layer:

  • Using a new storage device such as a hard drive or magnetic tape.
  • Modifying the file organization technique in the database.
  • Switching to different data structures.
  • Changing the access method.
  • Modifying indexes.
  • Changes to compression techniques or hashing algorithms.
  • Changing the location of the database, for example from the C drive to the D drive.

Logical Data Independence

Logical data independence is the ability to change the conceptual schema without changing:

  1. External views.
  2. External APIs or programs.

Any change made is absorbed by the mapping between the external and conceptual levels. Compared to physical data independence, it is challenging to achieve logical data independence.

Examples of Changes Under Logical Data Independence

Because of logical independence, none of the changes below will affect the external layer:

  1. Adding, modifying, or deleting a new attribute, entity, or relationship is possible without a rewrite of existing application programs.
  2. Merging two records into one.
  3. Breaking an existing record into two or more records.

Difference Between Physical and Logical Data Independence

Logical Data Independence Physical Data Independence
Mainly concerned with the structure or changing the data definition. Mainly concerned with the storage of the data.
Difficult, as the retrieval of data mainly depends on the logical structure. Easy to retrieve.
Compared to physical independence, it is difficult to achieve. Compared to logical independence, it is easy to achieve.
You need to make changes in the application program if new fields are added or deleted. A change at the physical level usually does not need a change at the application program level.
Modification at the logical level is significant whenever the logical structures of the database are changed. Modifications at the internal level may or may not be needed to improve performance.
Concerned with the conceptual schema. Concerned with the internal schema.
Example: add, modify, or delete a new attribute. Example: change in compression techniques, hashing algorithms, storage devices, etc.

Importance of Data Independence

  • Helps you improve the quality of the data.
  • Makes database system maintenance more affordable.
  • Enforces standards and improves database security.
  • You do not need to alter data structures in application programs.
  • Permits developers to focus on the general structure of the database rather than the internal implementation.
  • Reduces database inconsistency substantially.
  • Lets you make modifications at the physical level to improve system performance.

FAQs

Application programs and views depend on the logical structure, so changing entities or attributes can ripple into them. Physical storage sits below the conceptual schema, so its changes stay hidden.

The mappings between levels. Physical independence relies on the conceptual-internal mapping, and logical independence relies on the external-conceptual mapping, so each change is absorbed rather than propagated.

No. Adding or dropping an index is a physical change absorbed by physical data independence. Queries return the same results, only faster or slower, and no application code needs to change.

Because storage can change freely, an AI tuning tool can migrate data to columnar storage or add indexes to speed model training, all without altering the queries the applications already use.

Physical. Relocating files from one drive to another changes only the internal level. Thanks to physical data independence, the conceptual schema and every application view remain unaffected.

Summarize this post with: