Data Independence in a Relational Database

Can someone explain how data independence is provided in a relational database? What does it say that nothing will change for the user if the database structure changes?

For example, I have an R relation (and I created an application that uses this relation), and the database administrator decides to decompose R into R1 and R2. How is end-user application immutability ensured?

+6
source share
4 answers

I asked myself the same question during my database class.

According to Codd 12 rules, there are two types of data independence:

  • The independence of physical data requires that changes at the physical level (e.g., data structures) do not affect applications that consume the database. For example, suppose you decide to stop using the hash index in your table, and decide to use the B-Tree index instead: your application that queries the table should not change at all.
  • The independence of logical data indicates that changes at the logical level (tables, columns, rows) will not affect applications accessing the database. As you already noticed, this function is more difficult to implement this physical independence, but there are still cases where this function works. For example, if you add tables, columns, or rows to your current schema, queries that are already running are not affected at all.
+3
source

Your question is not very clearly worded. I do not see the relationship between “data independence” and “application immutability”.

Own relational structure decomposes data into entities and relationships. The idea is that when a value changes, it changes only in one place. These are arguments in favor of various "normal forms" of data.

Most user applications do not want to see data in a normalized form. They want to see data in denormalized form, often with a large number of fields collected on the same line. Similarly, an update can include several fields in different entities, but for the user this is just one thing.

A relational database can support a data structure and allows you to combine data for different points of view. This has nothing to do with your second point. Application independence (I think this is a better word than "fatigue") depends on how the application is developed. A well-designed application has a well-designed application programming interface (also known as an API).

It seems that many database developers believe that the structure of the physical data is pretty good, like an API. However, this is often a poor design decision. Often, the best design decision is for all database operations to be performed using stored procedures, views, and user-defined functions. In other words, do not directly update the table. Create a stored procedure called "usp_table_update" that takes fields and updates the table.

With this structure, you can simultaneously change the basic structure of the database and support applications for users.

+1
source

that says nothing will change for the user if the database structure changes?

Well, database structures can change for many reasons. At a high level, I see two possibilities:

  • Performance / internal database reasons
  • Changed business rules / world outside the application.

@ 1: in this case, the database administrator decided to change some structure for performance or ... In this case, an additional level, for example, using stored procedures, views, etc., can help to “hide” the change to the program / user. Or a good data layer on the application side may be useful.

@ 2: if the outside world changes or your business rules change, there is NOTHING you can do at the database level that can distract him from the user. For example, a company that has always used only one currency in the database suddenly becomes international: in this case, your database must be adopted to support several currencies, and it will require major changes in the database for the user as well.

+1
source

For example, I have an R relation (and a created application that uses this relation), and the database administrator wants to decompose R into R1 and R2. How does the application stay consistent for the end user?

The administrator must create a view that will represent R1 and R2 as the original R

0
source

Source: https://habr.com/ru/post/917236/


All Articles