We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Extending View Updatability by a Novel Theory

00:00

Formal Metadata

Title
Extending View Updatability by a Novel Theory
Subtitle
Prototype Implementation on PostgreSQL
Title of Series
Number of Parts
19
Author
License
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Although PostgreSQL supports automatically-updatable, the conditions are restrictive, and complex views are not automatically updatable. To update these views, you still need to define specific triggers or rules for every views. However, a recent study has proposed a novel approach extending view-updatability for generally defined views. In order to test the feasibility of the theory, I'm developing an implementation of the algorithm as the proof of concept. This talk will introduce the overview of the theory, and explain how the prototype is implemented and how it works. Since PostgreSQL 9.3, automatically-updatable views has been supported. Thanks to the feature, you can update simple views without creating INSTEAD OF triggers or INSTEAD rules. However, the conditions are restrictive, and complex views, such as the ones including JOIN, are not automatically updatable. To update these views, you still need to define specific triggers or rules for every views. It would be nice if we could relax the prerequision for the automatically-updatable views. In fact, updatability of complex views is a hard problem, and has been studied for a long time. In a recent study, a novel approach extending view-updatability for generally defined views has been proposed. In this approach, view-updatability is based on guessing user's update intention by algorithm called "Pro Forma Guessing of Update Intention". If user's update intention can be guessed uniquely by this algorithm, views are updatable as the guessed intention, even if the view has JOIN, UNION, and so on. If we could have this in the PostgreSQL's automatically-updatable views, it would bring great benefit to users. In order to test the feasibility of the theory, I'm developing an implementation of the algorithm as the proof of concept. The prototype is developed as an extension of PostgreSQL. This also uses INSTEAD OF trigger, but you don't need to define specific triggers for your views, because the extension provides the trigger function for general defined views. This talk will introduce the overview of the theory, and explain how the prototype is implemented and how it works.
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Computer animation
Transcript: English(auto-generated)
Yuu Nagata from Celery Oasis in Japan.
This presentation title is Extending View Updatability by a novel theory prototype implementation on PostgresQL. As this shows, I would like to introduce a novel theory to extend view updatability of RDBMS and
talk about the prototype implementation of this theory. This is a joint work with Dosto Masunaga. He is author of the paper of this theory.
This work is based on his idea, which I call a novel theory here. I will talk about the current status of his implementation on PostgresQL.
I would appreciate if you hold your questions till the end of presentation, please. Okay, this is an outline of this talk.
Firstly, I'll introduce a problem that we are trying to resolve. View Updatability problem. In this part, I'll explain what View Updatability problem is and how it is handled in PostgresQL and SQL standard.
Then I'll talk about theory to resolve this problem. In this part, I'll summarize the problem and introduce our new theory using the intention-based approach we call this.
I'll explain the basic idea to resolve the problem and algorithm called pro forma guessing. Next, I'll talk about prototype implementation of the algorithm, which we are developing on PostgresQL.
I'll also talk about a new feature of Postgres 10 used in this implementation. At the end of this part, I'll show you some examples of demonstration about this implementation.
Finally, I'll summarize the talk and finish. Before I introduce View Updatability problem, I'd like to start with what is the view? Originally, views were first introduced by Dr. Cote, the investor of the relation data model, in 1974.
And now, as you know, almost RDB-MS, including PostgresQL, support views. A view can be regarded as a virtual relation.
Sorry, a virtual relation based on the result set of select queries. Any data overview is not contained in the database, and only the view definition is contained.
There are a few purposes of the view support. The first is to simplify complex queries that are used repeatedly in applications.
Thanks to this view support, users don't need to write long SQL queries many times. It also provides logical data independence. So if the relation schema in the database is changed,
applications that access the relation via a view may not have to rewrite the SQL code. View is also used for security purposes by hiding some information from some users.
This is a simple example of view. Well, EMP is a relation representing employees, the field is employee number, employee name, departmental number, and salary.
And K41 EMP and FUWA EMP, these are views. This is a view of employee, the departmental number is K41, and this view is employee, the food salary is lower than 30.
This relation EMP is the base relation of these views.
This table data is contained in the database. So it can be said, it is a real relation, real relation, yes. And these views, this views data itself is not contained database,
and only view definition is in the database. So these are called to be virtual relations.
So what is view update program? A view is regarded as a relation virtually, virtually, but it's regarded as a relation.
So users maybe have a motivation to handle views as a regular relation, as same as possible. That is, it would be good if user can access the views at the same manner of relations.
Actually, read queries, that is, select statements, are always acceptable to view. If user issues select query to views, it is modified, it is related to the query, to the base relation, it is always okay.
However, as you know, update queries, that is, delete, insert, update statement, these are not always acceptable. So views are not always updatable.
So one question is, what kind of views are updatable? And if one view is updatable, request, appropriate request to the views have to be translated to
request, appropriate to these base relations. So second question is, how to translate appropriate request on views into appropriate request on base relations?
We call this problem view appropriate problem. Here is an example of not updatable view. R and S is the base relations. Each have two columns.
And this view, B, is a natural drawing view of R and S, from R and S. Request to delete A, B dash, C from this view is issued.
There are three translation alternatives. T1 is delete A, B dash from R. T2 is delete B dash C from S. And T3 is executing both T1 and T2.
However, we can't determine which translation is the answer.
Because each of them is realize this request. So we can determine which is the answer. So this is called, we call this translation ambiguity.
And in this view and in this appropriate request, translation ambiguity cannot be resolved. So we can say this view is not updatable.
By the way, we can say that the view update program is already resolved partially because, as you know, PostgreSQL support automatically updatable view since 9.3.
Thanks to this feature, affiliate query to simple views are automatically updatable. The conditions for automatically updatable view here, as described in PostgreSQL official document.
First, the view must have exactly one entry in its from list, which must be a table or another updatable view. And second, the view definition must not contain with distinct group by having limit or first clause at the top level.
Third, the view definition must not contain set operations. Set operations, that is, you know, intersect or accept. Finally, the view select list must not contain any aggregation window function or set returning functions. And as shown here, this is very restrictive, so limited.
So, for example, any view contain join cannot be updatable. With regard to the SQL standard,
the condition of PostgreSQL automatically updatable view is basically according to SQL 92. Also, a few condition are relaxed. After the SQL 92, view update ability is largely extended at SQL 1999.
And in this specification, views including join and immune-all view are updatable under some conditions.
And some condition and Oracle DB supports it partially. However, it is still restrictive. Here, someone may say, it's no problem.
You can do anything using instead of a polygon. And it will resolve the problem perfectly. Yes. It is true that users can create instead of polygon on complex views
and do any actions you like in the polygon functions. If this polygon function comparts the attempt query and it will create actions on other tables, this will work well.
However, in this matter, basically you have to define specific triggers for each view. And although you can define any action using instead of trigger, the best way to convert the attempt query appropriately is not clear.
Instead, we would like to propose more general manners to extend view update ability. So, now I'll talk about the theory to resolve the view update problem.
This is a novel theory proposed last year by Dr. Masunaga. And this is called an intention-based approach.
In this figure, first let me summarize the problem using the figure and the equation. It's not difficult. In this figure, v is, notation v is a view definition. And s-tau is state of base relation at time tau.
So when s-tau is base relation and using view definition, we can get the state of the relation, data in virtual relation at time tau.
And now, if a plate request for view, u, is provided, we can get u, v, s-tau, u, v, s-tau. This is desired result of this update,
this desired state. Next, we can consider some t. This is a translation of a plate request. Using this translation,
a plate request for view is translated to a plate request on base relations. So, current base relations and translated a plate request. Using them, we can get updated base relation,
state of updated base relation. And again, we use view definition. We can get v, t, u, s-tau, right time of this equation.
This is the result of the view station after applying this translated request to base relations.
And then, if this equation is obtained, left terms equals right terms, this view is, we can say this view is updatable
using this translation t. This equal means there is no side effect that is desired result, and actual result is the same.
And we have to find this translation uniquely, so only one translation should be there. If there are similar translation obtaining this equation,
we cannot determine which is the answer. This is ambiguity. To resolve this problem, traditionally, there are three approaches.
Syntax-based or functional approach, semantics-based approach, and interaction-based approach. Then, syntax-based approach and semantics-based approach tried to resolve the problem using view definition and uploaded request logically.
And on the other hand, interaction-based approach tried to solve the problem using interaction with user and systems. So, this theory has been studied,
but view approach problem is not yet fully resolved. So, this is an old problem, but not resolved. Then we can say this problem is an old and new problem.
Now, we have proposed a new novel theory. This is an intentional-based theory.
In this theory, the problem is resolved by testing the user's intention of the update using an algorithm called view applicability based on pro-forma guessing of the update's intention.
The basic idea is that completing each translation candidate temporarily so that we can guess user's update's intention uniquely.
So, traditional approach uses only view definition and update request information, but it uses also the data in database, the current data in database.
So, in this approach, view applicability depends on data in the current database relation. This figure shows overview of the algorithm.
This algorithm is called view applicability based on pro-forma guessing of update's intention. We create a temporarily materialized view from the base relation and view definition. Using this information, we can temporarily materialize the view.
And using this temporarily materialized view and update request to this view,
we can get desired result of the update request. And then, in addition, we can generate translation alternatives of update request
to base relation from a plate request to the view. There are several alternatives. Using one of the alternatives, we can calculate a result of a translation alternative
using base relation and view definition and one of alternatives. Finally, we can compare desired result and result of a translation alternative and comparing this, we can guessing which one is answer.
So, we can only want translation to realize the result to obtain desired result.
We can say that translation is answer and this view is updatable. Here is an example of pro-forma guessing of update's intention.
There is a national join view of from relation R and S. And if delete ABC and ABC dash from this view is requested, these are three translation alternatives.
Delete AB from R, delete BC and BC dash from S, and executing both D and two. From these alternatives, only T1 realize a desired result without side effect. So, T1 is a user's update intention
and this view is updatable. Next example is that using same views and relation, when delete AB dash C from V is requested,
there are also three translation alternatives. Delete AB dash from R, delete B dash C from S, and executing both. However, all of T1, T2, and T3 realize a desired result,
this request. So, we cannot determine which is answer. We cannot realize, we cannot resolve translation ambiguity. We cannot guess the appropriate intention.
This view is not updatable in this data, and with this data, and with this request.
So far, we have explained only join view, but our theory can handle updatability of a generally defined view. In this algorithm, a view is defined recursively using best relation and predefined views.
And thus, this recursive structure is expressed as view definition tree. For example, consider this view. This view is join of EMP and DPT,
and selection with here, and projection with select. So, we can just view like this.
Okay, we can check updativity using this scanning history recursively. So, we can check updatability of views generally defined with, generally defined view.
So, next, we talk about implementation of prototype. So, there we consider two prototype implement, this prototype is implemented as a proof of concept,
and the purpose is to test feasibility of this theory. In the current version, this prototype is developed as an extension of PostgresQL. So, I don't touch PostgresQL code,
but maybe in future, we should touch core code. We consider two approaches, rule-based approach and trigger-based approach. Rule-based approach, in rule-based approach,
we can implement this using rule system in PostgresQL. As you know, view support of PostgresQL is realized by rule systems. And this is rewriting query to another query.
So, maybe it might be natural to implement our algorithm in rule systems. In rule systems, but applet request
is provided as a query tree, that internal structure of PostgresQL. This is very informative, but complex, so it is difficult to handle this in our algorithm in the current version.
In addition, if we implement the algorithm on rule systems, we need to modify PostgresQL's core code largely. So, we decided to use the other approach.
Other approach is trigger-based approach. In this approach, we can implement the algorithm in trigger functions. And applet request is provided as a list of tuples,
tuples stores. Maybe in future, we have to use this approach, but now we decide to start with the trigger-based approach. But there was one problem.
Instead of the triggers. In PostgresQL, statement-level instead of trigger is not supported, and only low-level instead of trigger is supported. But we needed to process multiple tuples at the same time to translate request.
So we cannot use low-level instead of trigger. So, we decided to use statement-level after trigger instead of triggers. This gets possible using Postgres 10's new feature.
This is transition table. Transition table, this is a new feature of PostQL 10. This is a copy of the list node of that part, and as it shows, transition table is a table
to record change nodes available after trigger. The transition table is such a table that contains access from the server-side language,
so we can use this from trigger functions. The contents is a before or after image for a role affected by the statement which, via the trigger, can be accessed
as a tuples towards in after trigger functions. We use tuples in these tuples towards as a request for views.
So, this is the overview of the implementation. This is three triggers, before trigger, instead of trigger, after trigger. In before trigger, the view definition tree is built,
and instead of trigger, it's doing nothing, basically, but it is necessary to suppress autoappositable views. The main function is after trigger. In this function, extracting the request
for the view from transition table and check the view updateability and update the base relation, if possible. In before triggers, we build a view definition tree. View definition tree is converted from query tree.
This query tree is available by getViewQuery function. This is an API of root system of PostgreSQL. As a requirement of this view definition tree,
we need to convert any sub-trees of this tree to a scaled query of view definition. This is because to check the view updatedly recursively, any sub-tree needs to be temporarily materialized.
Here, I said materialized. In fact, simply just creating a temporary table because it has to be updated.
In after triggers, update queries or update requests for views are extracted from transition tables. This is an example of an update request
for this relation and this views, natural join views. Delete from view first as c equals c dash is expressed as delete a, b, c dash, a dash, b, c dash,
that's a list of tuples format. Also, update b set c equal d first c equal c dash is writing this tuple to this tuples. In the case of insert settlement,
it's simple, just inserting a list of tuples. List of tuples are extracted from the tuples to us. This is tg old table and tg new table.
This is a member of trigger structure. This is available in after trigger function. To check view of the updateability,
we work down the view definition tree from the top recursively to down. And this, during this work, if we find a join node, join view node, we use pro forma guessing algorithm to check view updateability.
In this process, the sovereignty of the join node, this is arranged box area, and the children nodes that are green box areas are temporarily materialized, just create as temporary tables.
And in pro forma guessing algorithm, firstly, the applet request are divided for base relations.
For example, insert a b dash d a b dash e into b is invited into a b dash into r and insert b dash d b dash e into s. And using this request, alternatives of translation is generated.
These alternatives are determined logically, it can be computed logically. In this example, we can generate ten alternatives and check if only one of these alternatives
can realize the desired result. We can say the join view is updatable and the translation is the answer. This is an example of how it works.
For example, these are two relations, base one and base two, and this is a natural join view named b. Then, issuing insert query into b
and in default, it occurs echeverly, of course. In our implementations, in extensions,
we create a function, add view ext this, add trigger function to the view. After executing this function, we can insert query to view b. For example, instead of value one, two, three, one, two, four,
we can insert two tuples to view, these blue tuples. Actually, two tuples are inserted to base two. However, when trying to insert two, two, two, this is not applicable based on pro forma guessing.
Another example. Then, issuing delete from one, three, we can delete two tuples from view.
These blue tuples are deleted from base two. But when removing condition is c equal four, this is not applicable.
In update example, we can issue this update query. We can put it to tuples of green area, but some update query is not issued
because based on pro forma guessing. We show another example, another demonstration.
This is EMP relation and DPT relation.
This is join of these relations. This is a view definition.
Just a simple join.
And then we try delete from this view here, dno equal k four one. We can then issue delete to views.
We get error. It's a default error. We add view extension to this view
and issuing same delete query. This is a debug message. We can delete two tuples.
We can delete two tuples from view. And we can delete two tuples from adjust relations, employee relations from here.
Reset. This is the initial state. Next, we try to delete k eight one.
But we get error. We cannot do it because deleting k eight one load,
this tuple, we cannot determine we should delete this tuple. We should delete this tuple. We cannot determine which should be deleted.
So we get errors.
In conclusion, I have introduced view applet program and we introduce a novel theory
called the intention-based approach and algorithms called pro forma guessing of applet intention. Using this algorithm, we can, using this algorithm, join views applet in certain cases,
although they are not applet in the traditional approach. And we show current implementation, prototype implementation with the algorithm. Using trigger-based approach and using transition table.
This is a new feature of Postgres 10. As a future France, we should handle the limitation of performance issue of this implementation and theories. We have many limitations and we have serious performance issues.
And the purpose of the prototype information is test feasibility of the theory. So we should test using this prototype in many cases,
in many relations, in many join cases, in many views cases, and give feedback to the theory to elaborate on it and again, elaborate the implementation again and again.
So in this process, maybe we might need to investigate the rule-based approach instead of the trigger-based approach. That's all. Thank you. Any questions?
A link to the slide?
Currently, there is no public input. Only papers.