"Topic: Data Abstraction-3 levels, Entity Relationship (ER) Model and Database Normalization"
Data Abstraction - 3 levels of Architecture in DBMS or Logical DBMS Architecture or 3 levels of Data Abstraction
Firstly,
What is Data Abstraction?
Data Abstraction = Data abstraction refers to the process of simplifying complex data structures or systems by focusing on the essential aspects and hiding unnecessary details. It involves representing data and its operations at a higher level of abstraction, making it easier to understand and work with.
The main purpose of this is," to Hide unnecessary details and provide an abstract view of the data for the end user".
So, now we have to know,
How many levels of abstraction are there to design the DBMS architecture effectively?
In the context of database management systems (DBMS), data abstraction is achieved through the use of different levels of abstraction.
In DBMS, data abstraction is performed in layers which means, there are three levels of abstraction/architecture in database management systems (DBMS). These provide a hierarchical structure that allows for effective design, management, and interaction with databases.
1) #Internal_Level (also known as Physical Level):
2) #Conceptual_Level (Logical Level):
3) #External_Level (View Level):
Example: Let's say we have a database table called "Employees" with the following columns: EmployeeID, FirstName, LastName, Email, and Salary.
At the physical level of abstraction, the data is stored in the database's underlying storage system, such as hard disks or solid-state drives. It involves how the data is physically organized and accessed, such as using file systems and disk blocks.
At the logical level of abstraction, we define the structure and relationships of the data. In our example, we create a logical schema for the "Employees" table, specifying the columns and their data types, primary key, and any constraints.
At the view level of abstraction, we define views that provide a customized and simplified representation of the data for specific users or applications. For example, we can create a view called "EmployeeDetails" that only includes the EmployeeID, FirstName, and LastName columns from the "Employees" table, hiding the Email and Salary columns. This view can be used by a reporting application to display employee details without exposing sensitive salary information.
Advantages of Data Abstraction:
Disadvantages of Data Abstraction:
Conclusion:
These three levels of abstraction provide a clear separation between the concerns of different users and enable efficient database management. They allow users to interact with the database at their respective levels of understanding and requirements, while ensuring data consistency, integrity, and security across the entire system.
Entity-relationship (ER) modeling:
In the context of entity-relationship (ER) modeling,
ER Model:
ER Diagram:
ER diagram symbols:
we use different notations to represent different elements of an ER diagram.
Components of ER model - In Detail:
The 3 main components of the ER model include:
1) #Entity: An entity is a real-world object or concept that exists independently and can be uniquely identified. For example, in a school database, students, teachers, and courses are entities.
2) #Attribute: An attribute is a property or characteristic of an entity. An attribute is represented by ellipses in an ER diagram. For example, a student entity may have attributes such as name, roll number, age, address and gender.
Different types of attributes:
There are 4 types of attributes are there:
A) Key attribute:
B) Composite attribute:
C) Multivalued attribute:
Recommended by LinkedIn
D) Derived attribute:
3) #Relationship: A relationship defines the association between two or more entities. For example, a student entity may have a relationship with a course entity to represent the fact that the student is enrolled in that course.
Entity set:
For example: A students studies a course, here both student and course are entities.
Relationship set:
For example: If each student can enroll in multiple courses, but each course can only be taken by one student at a time, then the relationship set between the "student" entity and the "course" entity can be called the "enroll in" relationship set.
Relationship Degree:
Relationship degree refers to the number of entities involved in a relationship. There are three types of relationship degrees: unary, binary, and ternary.
Example: A company has employees, and each employee reports to a supervisor. The supervisor of an employee is also an employee of the company. In this case, the relationship degree is unary because the employee is related to another employee (the supervisor).
Example: A customer purchases a product from a store. In this case, the two entities involved are the customer and the product.
Example: A school has teachers, students, and classes. A teacher teaches a class, and a class has students enrolled in it. In this case, the three entities involved are the teacher, the class, and the student.
Types of Relationships - Mapping cardinalities
1) #One_to_One_Relationship ((1:1) Mapping Cardinality):
This relationship is formed when a single element of an entity is associated with a single element of another entity.
For example, in a database for a school, a student has only one student ID, and a student ID is assigned to only one student. This is a one-to-one relationship.
2) #One_to_Many_Relationship ((1: N) Mapping Cardinality)):
This relationship is formed when a single element of an entity is associated with more than one element of another entity.
For example, in a database for a school, a teacher teaches many courses, but a course can only be taught by one teacher. This is a one-to-many relationship.
3) #Many_to_One_Relationship ((N:1) Mapping Cardinality):
This relationship is formed when more than one element of an entity is related to a single element of another entity.
For example, in a school database, many students can be associated with a single teacher. In this case, the "student" entity has a many-to-one relationship with the "teacher" entity, as many students can be related to a single teacher.
4) #Many_to_Many_Relationship ((N:M) Mapping Cardinality):
This relationship is formed when more than one element of an entity is associated with more than one element of another entity.
For example, a student course registration system where a student can register for multiple courses and a course can have multiple students enrolled in it. This represents a many-to-many relationship.
Database Normalization:
Database normalization is a process that is used to manage and organize a database into tables and columns to reduce data redundancy, unnecessary anomalies and improve data integrity. The normalization process involves breaking down large tables into smaller ones and establishing relationships between them to ensure that each piece of data is stored only once.
The main benefits of database normalization include:
However, there are also some potential downsides to database normalization, including increased complexity and slower query performance in some cases. It is important to balance the benefits and drawbacks of normalization when designing a database to ensure that it meets the specific needs of the application or organization.
Anomalies and types of anomalies:
In the context of database design, an anomaly is an unexpected or unintended issue that can occur in a database due to inefficient or incorrect normalization. Anomalies can cause inconsistencies in the data, lead to data redundancy, and make it difficult to perform updates, deletions, or insertions.
There are four types of anomalies that can occur in a database:
Normalization is the process of organizing data in a database to reduce or eliminate data redundancy and prevent anomalies. The goal of normalization is to create a database that is efficient, easy to maintain, and avoids data inconsistencies.