0
0
DbmsConceptBeginner · 3 min read

3 Levels of Data Abstraction in DBMS Explained Simply

The 3 levels of data abstraction in a DBMS are Physical Level, Logical Level, and View Level. These levels hide the complexity of data storage, structure, and user-specific views respectively, making data management easier and more efficient.
⚙️

How It Works

Data abstraction in a database means hiding the complex details of how data is stored and organized from users. Imagine a library: the physical level is like the actual shelves and books, the logical level is like the catalog system that organizes books by topics, and the view level is like a reader's personalized list of favorite books.

The Physical Level deals with how data is actually saved on disks or storage devices. Users don't see this level because it involves technical details like file formats and indexing.

The Logical Level defines what data is stored and the relationships between data. It shows the structure of the entire database without worrying about how it is physically stored.

The View Level is what users interact with. It shows only the data relevant to a particular user or application, hiding unnecessary details.

💻

Example

This simple Python example simulates the 3 levels of data abstraction using dictionaries and functions to show how data can be hidden or shown at different levels.

python
class Database:
    def __init__(self):
        # Physical level: raw data storage
        self._physical_data = {
            'users': [
                {'id': 1, 'name': 'Alice', 'password': 'secret123'},
                {'id': 2, 'name': 'Bob', 'password': 'pass456'}
            ]
        }

    def logical_level(self):
        # Logical level: structure and relationships
        return {'users': [{'id': u['id'], 'name': u['name']} for u in self._physical_data['users']]}

    def view_level(self, user_id):
        # View level: user-specific data
        users = self.logical_level()['users']
        for user in users:
            if user['id'] == user_id:
                return user
        return None

# Usage
db = Database()
print('Physical Level Data:', db._physical_data)
print('Logical Level Data:', db.logical_level())
print('View Level Data for user 1:', db.view_level(1))
Output
Physical Level Data: {'users': [{'id': 1, 'name': 'Alice', 'password': 'secret123'}, {'id': 2, 'name': 'Bob', 'password': 'pass456'}]} Logical Level Data: {'users': [{'id': 1, 'name': 'Alice'}, {'id': 2, 'name': 'Bob'}]} View Level Data for user 1: {'id': 1, 'name': 'Alice'}
🎯

When to Use

Data abstraction is used in database systems to simplify data management and improve security. The physical level is managed by database administrators to optimize storage and performance.

The logical level is useful for developers and analysts to understand the data structure without worrying about storage details.

The view level is important for end users and applications to access only the data they need, protecting sensitive information and reducing complexity.

For example, a bank employee might see only customer account details relevant to their role (view level), while the database system manages how this data is stored on servers (physical level).

Key Points

  • Physical Level: How data is stored physically on hardware.
  • Logical Level: What data is stored and how it is related.
  • View Level: What data users see and interact with.
  • Abstraction hides complexity and improves security.
  • Each level serves different users and purposes in a DBMS.

Key Takeaways

Data abstraction in DBMS has three levels: physical, logical, and view.
Physical level hides storage details from users.
Logical level defines the database structure and relationships.
View level shows user-specific data views for simplicity and security.
Each level helps different users work efficiently with data.