<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
		<id>http://d2.reldb.org/index.php?feed=atom&amp;namespace=0&amp;title=Special%3ANewPages</id>
		<title>D Wiki - New pages [en-gb]</title>
		<link rel="self" type="application/atom+xml" href="http://d2.reldb.org/index.php?feed=atom&amp;namespace=0&amp;title=Special%3ANewPages"/>
		<link rel="alternate" type="text/html" href="http://d2.reldb.org/index.php/Special:NewPages"/>
		<updated>2026-05-06T15:09:24Z</updated>
		<subtitle>From D Wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://d2.reldb.org/index.php/PhilipTutorial</id>
		<title>PhilipTutorial</title>
		<link rel="alternate" type="text/html" href="http://d2.reldb.org/index.php/PhilipTutorial"/>
				<updated>2017-09-24T14:29:59Z</updated>
		
		<summary type="html">&lt;p&gt;Dandl: Initial creation from TTM post&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a verbatim copy of text posted by Philip to the TTM mailing list, lightly edited for continuity and formatting.&lt;br /&gt;
&lt;br /&gt;
Hopefully Philip will improve it, but (of course) he may just delete it. Over to Philip.&lt;br /&gt;
&lt;br /&gt;
== PREAMBLE ==&lt;br /&gt;
&lt;br /&gt;
Below is an edited message that quoted others with some RM semantics, my &amp;#039;tutorial&amp;#039; &amp;amp; my &amp;#039;quiz&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
I have sent many messages about RM query meanings. The recent intro/tutorial/quiz that this is from is not intended &lt;br /&gt;
to be an ideal presentation. &lt;br /&gt;
If one bumped up against not understanding something in reading an example or not knowing something in answering the quiz, &lt;br /&gt;
presumably one would ask a question or point out a contradiction.&lt;br /&gt;
&lt;br /&gt;
== INTRODUCTION ==&lt;br /&gt;
&lt;br /&gt;
Each relvar name has a dba-given predicate and each operator has a Codd-given transformation on predicates. &lt;br /&gt;
Each query subexpression (relation or wff) has a predicate built from its mentioned relvar names and operators. &lt;br /&gt;
This is in fact how we actually know what queries mean.&lt;br /&gt;
&lt;br /&gt;
Every relvar has a predicate (parameterized statement about the &lt;br /&gt;
world), with attributes the free variables. Every relation operator &lt;br /&gt;
has a corresponding predicate transform, eg JOIN/AND. So every &lt;br /&gt;
relation expression has a corresponding predicate, and vice versa. The &lt;br /&gt;
design of the relation operators is such that IF the relvars&amp;#039; values are their predicates&amp;#039;&lt;br /&gt;
extensions THEN an expression&amp;#039;s value is its predicate&amp;#039;s extension. &lt;br /&gt;
The value of a relvar after an assignment is the value of the query &lt;br /&gt;
evaluated before the assignment. Which means the extension of the &lt;br /&gt;
relvar predicate in the new state is the extension of the expression predicate in the old state.&lt;br /&gt;
When I say that is all you need to know, THAT IS ALL YOU NEED TO KNOW.&lt;br /&gt;
&lt;br /&gt;
The predicate of a relation expression that is a name of a relation &lt;br /&gt;
variable or constant is its predicate. The predicate of a relation &lt;br /&gt;
expression that is a JOIN is the AND of the predicates its operands; &lt;br /&gt;
of a UNION is the OR; of a MINUS is the AND NOT; of a RESTRICT X=Y or &lt;br /&gt;
of an ADD X AS Y is the AND X=Y; and of a PROJECTALLBUT X is the &lt;br /&gt;
EXISTS X.&lt;br /&gt;
&lt;br /&gt;
RE: delete-through-restrict - logical basis&lt;br /&gt;
&lt;br /&gt;
 query    wff    predicate:&lt;br /&gt;
 n     n(x,y)     &amp;#039;x likes y&amp;#039;&lt;br /&gt;
 m     m(z)     &amp;#039;i like z&amp;#039;&lt;br /&gt;
 n where y=3     n(x,y) and y=3    &amp;#039;x likes y and y=3&amp;#039;&lt;br /&gt;
 (n where y=3){allbut y}    exists y [n(x,y) and y=3]    &amp;#039;x likes 3&amp;#039;&lt;br /&gt;
 (n where y=3){allbut y}    n(x, 3)    &amp;#039;x likes 3&amp;#039;&lt;br /&gt;
 m rename z to x     m(x)     &amp;#039;i like x&amp;#039;&lt;br /&gt;
 (n where y=3) join (m rename z to x)     n(x, y) and y=3 and m(x)&lt;br /&gt;
      &amp;#039;x likes y and y=3 and i like x&amp;#039; ie  &amp;#039;x likes 3 and y=3 and i like x&amp;#039;&lt;br /&gt;
 (n where y=3){allbut y} join (m rename z to x)    n(x, 3) and m(x)&lt;br /&gt;
      &amp;#039;x likes 3 and i like x&amp;#039;&lt;br /&gt;
&lt;br /&gt;
----------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
The value of every subexpression is the extension of its predicate.&lt;br /&gt;
I append (a) an excerpt tracing and justifying an illustrating example and (b) a self-quiz excerpt.&lt;br /&gt;
&lt;br /&gt;
== TUTORIAL ==&lt;br /&gt;
&lt;br /&gt;
Here is how a relational database works.&lt;br /&gt;
&lt;br /&gt;
 type T={a, b}&lt;br /&gt;
 relvar r RELATION{X T} &amp;quot;i like X&amp;quot;&lt;br /&gt;
 Relvar predicate for relvar r is &amp;quot;i like X&amp;quot;.&lt;br /&gt;
 r:=RELATION{TUPLE{X a}} // i like a and i don&amp;#039;t like b.&lt;br /&gt;
 Relvar r value, relvar r (and database) proposition is &amp;quot;i like a and i don&amp;#039;t like b&amp;quot;.&lt;br /&gt;
 r:=RELATION{TUPLE{X a},TUPLE{X b}} // now i like a and i like b.&lt;br /&gt;
 Relvar r value, relvar r (and database) proposition is &amp;quot;i like a and i like b&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
hmm... if i assume that a relvar holds those tuples that make its predicate true&lt;br /&gt;
(in which case, for each present tuple, that tuple put into the &lt;br /&gt;
predicate is true, and in which case, for each absent tuple, that &lt;br /&gt;
tuple put into the predicate is false) then a certain conjunction mapped from its tuples is true.&lt;br /&gt;
&lt;br /&gt;
Namely:&lt;br /&gt;
      (AND for t in r of the predicate of r applied to t)&lt;br /&gt;
   AND (AND for t not in r of NOT(the predicate of r applied to t)) &lt;br /&gt;
or if you prefer:&lt;br /&gt;
      (FORALL t in r : the predicate of r applied to t)&lt;br /&gt;
   AND (FORALL t not in r : NOT (the predicate of r applied to t))&lt;br /&gt;
&lt;br /&gt;
So if i assume that a relvar value is the extension of its predicate then it seems to state what i expect!&lt;br /&gt;
&lt;br /&gt;
Namely that if a tuple is in a relvar then it asserts the relvar &lt;br /&gt;
predicate applied to it and that if a tuple is not in a relvar then it &lt;br /&gt;
asserts the negation of the relvar predicate applied to it. &lt;br /&gt;
(Informally, present tuples are true and absent tuples are false.)&lt;br /&gt;
&lt;br /&gt;
 print r // RELATION{TUPLE{X a},TUPLE{X b}}&lt;br /&gt;
&lt;br /&gt;
hmm... this is the extension of the predicate of r.&lt;br /&gt;
&lt;br /&gt;
hmm... a query expression that is a relvar name seems to be the &lt;br /&gt;
extension of a predicate that is the relvar&amp;#039;s predicate.&lt;br /&gt;
&lt;br /&gt;
 print RELATION{TUPLE{X b}} // RELATION{TUPLE{X b}} &lt;br /&gt;
 &lt;br /&gt;
hmm... this is the extension of X=b.&lt;br /&gt;
&lt;br /&gt;
hmm... a relation expression RELATION{TUPLE{A1 v1, ...}, ...} seems &lt;br /&gt;
to be the extension of a predicate (A1=v1 AND ...) OR ....&lt;br /&gt;
&lt;br /&gt;
Or if it&amp;#039;s clearer: (A1=v11 AND A2=v12 AND...) OR (A1=v21 AND A2=v22 &lt;br /&gt;
AND...) OR .... Ie the disjunction of the conjunction of the equalites &lt;br /&gt;
of attributes names and values.&lt;br /&gt;
&lt;br /&gt;
 print r PROJECT ALL BUT X // RELATION{TUPLE{}}&lt;br /&gt;
&lt;br /&gt;
hmm... relation expression e PROJECT ALL BUT A seems to be the &lt;br /&gt;
extension of (EXISTS A: the predicate of e).&lt;br /&gt;
&lt;br /&gt;
 print r UNION RELATION{TUPLE{X b}} // RELATION{TUPLE{X a},TUPLE{X b}} &lt;br /&gt;
&lt;br /&gt;
hmm... relation expression e UNION f seems to be the extension of &lt;br /&gt;
(the predicate of e OR the predicate of f).&lt;br /&gt;
&lt;br /&gt;
 print (r UNION RELATION{TUPLE{X b}}) MINUS RELATION{TUPLE{X a}} // RELATION{TUPLE{X b}} &lt;br /&gt;
&lt;br /&gt;
hmm... relation expression (e UNION f) MINUS g &lt;br /&gt;
seems to be the extension of ((the predicate of e OR the predicate of &lt;br /&gt;
f) AND NOT the predicate of g) &lt;br /&gt;
&lt;br /&gt;
hmm... relation expression e MINUS f &lt;br /&gt;
seems to be the extension of (the predicate of e AND NOT the &lt;br /&gt;
predicate of f).&lt;br /&gt;
&lt;br /&gt;
hmm... every relation seems to be the extension of a certain &lt;br /&gt;
transformation of its arguments&amp;#039; predicates.&lt;br /&gt;
&lt;br /&gt;
hmm... seems that a query expression that is a relvar name has as &lt;br /&gt;
value the extension of the relvar predicate and that a query &lt;br /&gt;
expression that is a literal has as value the extension of the &lt;br /&gt;
disjunction-conjunction-equality from its tuples and that a query &lt;br /&gt;
expression that is an operator call has as value the extension of a &lt;br /&gt;
certain transformation of its arguments&amp;#039; predicates, and that &lt;br /&gt;
(consequently) an arbitrary query expression has as value the &lt;br /&gt;
extension of a thus-built predicate.&lt;br /&gt;
&lt;br /&gt;
So if i assume that a query expression predicate is thus-built then &lt;br /&gt;
the query is the extension of its predicate!&lt;br /&gt;
And so the query tuples are the ones that make a certain predicate true!&lt;br /&gt;
&lt;br /&gt;
Namely the thus-built query expression predicate.&lt;br /&gt;
And so a certain conjunction mapped from its tuples is true!&lt;br /&gt;
&lt;br /&gt;
Namely the same proposition as expressed twice above, but for the &lt;br /&gt;
query instead of the relvar:&lt;br /&gt;
      (AND for t in value of query of the predicate of query applied to t)&lt;br /&gt;
   AND (AND for t not in value of query of NOT(the predicate of query applied to t)) &lt;br /&gt;
or if you prefer:&lt;br /&gt;
      (FORALL t in value of query : the predicate of query applied to t)&lt;br /&gt;
   AND (FORALL t not in value of query : NOT (the predicate of query applied to t))&lt;br /&gt;
&lt;br /&gt;
So if i assume that a query value is the extension of its predicate &lt;br /&gt;
then it seems to state what i expect&lt;br /&gt;
&lt;br /&gt;
Namely that if a tuple is in a query then it asserts the query &lt;br /&gt;
predicate applied to it and that if a tuple is not in a query then it &lt;br /&gt;
asserts the negation of the query predicate applied to it. &lt;br /&gt;
(Informally, present tuples are true and absent tuples are false.) &lt;br /&gt;
(Note that if missing tuples are not false, then you can&amp;#039;t use &lt;br /&gt;
MINUS/NOTMATCHING.)&lt;br /&gt;
&lt;br /&gt;
b. QUIZ&lt;br /&gt;
&lt;br /&gt;
* What are the names of your relation variables and constants?&lt;br /&gt;
* What is the characteristic predicate (parameterized statement about the world) for each?&lt;br /&gt;
* What is the formal wff for each? Why?&lt;br /&gt;
* What are the attributes for each? Why?&lt;br /&gt;
* What is your (example) query relation expression?&lt;br /&gt;
* What is the characteristic predicate of its result? Why?&lt;br /&gt;
* What are the (example) values of your relation variables?&lt;br /&gt;
* What statement does each make about the world? Why?&lt;br /&gt;
* What statement does the database make about the world? Why?&lt;br /&gt;
* What is the value of your query relation expression? Why?&lt;br /&gt;
* What statement does this value make about the world in the context of this query relation expression? Why?&lt;br /&gt;
* What statement does a query result make about the world regardless of its query relation expression? Why?&lt;br /&gt;
&lt;br /&gt;
The most important things to understand are that:&lt;br /&gt;
&lt;br /&gt;
# each relation expression corresponds to a certain wff and &lt;br /&gt;
# equivalent relation expressions correspond to equivalent wffs &lt;br /&gt;
&lt;br /&gt;
The relational algebra is just another syntax for FOPL.&lt;/div&gt;</summary>
		<author><name>Dandl</name></author>	</entry>

	<entry>
		<id>http://d2.reldb.org/index.php/Update_through_views:_a_not-quite-so_seminal_paper_-_asking_too_much,_and_orthogonal_base_relations</id>
		<title>Update through views: a not-quite-so seminal paper - asking too much, and orthogonal base relations</title>
		<link rel="alternate" type="text/html" href="http://d2.reldb.org/index.php/Update_through_views:_a_not-quite-so_seminal_paper_-_asking_too_much,_and_orthogonal_base_relations"/>
				<updated>2017-02-12T08:51:27Z</updated>
		
		<summary type="html">&lt;p&gt;AntC: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Another much-cited paper on updating through views, of the same vintage as Dayal &amp;amp; Bernstein or Codd&amp;#039;s 12 rules, is Bancilhon &amp;amp; Spyratos 1981, which introduced the &amp;quot;constant complement&amp;quot; approach (and which anticipates Date&amp;#039;s Principle of Interchangeability).&lt;br /&gt;
&lt;br /&gt;
B&amp;amp;S aim to give a more precise specification for D&amp;amp;B&amp;#039;s &amp;#039;&amp;#039;unique&amp;#039;&amp;#039;, avoiding &amp;#039;&amp;#039;extraneous updates&amp;#039;&amp;#039;. They don&amp;#039;t offer an opinion on how few views are updatable-through, compared to D&amp;amp;B&amp;#039;s &amp;quot;very few situations&amp;quot; conclusion. But it isn&amp;#039;t difficult to see their restrictions are more stringent.&lt;br /&gt;
&lt;br /&gt;
I think their approach rests on an unstated assumption that is unrealistic. I&amp;#039;m going to draw out my reasons, to discuss the implications for independent update of relations (base or views). First I&amp;#039;ll outline their approach.&lt;br /&gt;
&lt;br /&gt;
== What is a &amp;quot;View complement&amp;quot;? ==&lt;br /&gt;
&lt;br /&gt;
Given base relations and a view defined over them, the &amp;#039;&amp;#039;view complement&amp;#039;&amp;#039; is &amp;quot;The information [in the bases] not visible within the view&amp;quot;, as B&amp;amp;S put it.&lt;br /&gt;
&lt;br /&gt;
* Take view &amp;#039;&amp;#039;V&amp;#039;&amp;#039; defined over base relations &amp;#039;&amp;#039;B1, B2, ..., Bn&amp;#039;&amp;#039;.&lt;br /&gt;
: (If &amp;#039;&amp;#039;V&amp;#039;&amp;#039; is defined over relvars that are themselves views, substitute in the view definitions (recursively) until there are all bases.)&lt;br /&gt;
* Interchange the schema for an information equivalent one in which:&lt;br /&gt;
** There is a base &amp;#039;&amp;#039;BV&amp;#039;&amp;#039; with same heading as &amp;#039;&amp;#039;V&amp;#039;&amp;#039;.&lt;br /&gt;
** There are views &amp;#039;&amp;#039;VB1, VB2, ..., VBn&amp;#039;&amp;#039; with the same headings as the based-ons respectively, and to be defined over &amp;#039;&amp;#039;BV&amp;#039;&amp;#039; and ....&lt;br /&gt;
** There are bases &amp;#039;&amp;#039;BBm, BBm+1, ..., BBm+o&amp;#039;&amp;#039; (not necessarily corresponding to &amp;#039;&amp;#039;B1, B2, ...&amp;#039;&amp;#039;).&lt;br /&gt;
** View &amp;#039;&amp;#039;V&amp;#039; &amp;#039;&amp;#039; is defined over &amp;#039;&amp;#039;VB1, VB2, ...VBn&amp;#039;&amp;#039; exactly as was &amp;#039;&amp;#039;V&amp;#039;&amp;#039; over the original bases.&lt;br /&gt;
* The content for these alternative relvars (i.e. their internal predicate) is to be:&lt;br /&gt;
** Base &amp;#039;&amp;#039;BV&amp;#039;&amp;#039; is to have the same content as would view &amp;#039;&amp;#039;V&amp;#039;&amp;#039;.&lt;br /&gt;
** View &amp;#039;&amp;#039;VB1, VB2, ..., VBn&amp;#039;&amp;#039; are to have the same content as would &amp;#039;&amp;#039;B1, B2, ..., Bn&amp;#039;&amp;#039; respectively.&lt;br /&gt;
** Bases &amp;#039;&amp;#039;BBm, BBm+1, ..., BBm+o&amp;#039;&amp;#039; are to have &amp;#039;just enough&amp;#039; content to combine with the content of &amp;#039;&amp;#039;BV&amp;#039;&amp;#039; and supply the content for views &amp;#039;&amp;#039;VB1, VB2, ..., VBn&amp;#039;&amp;#039;.&lt;br /&gt;
** So &amp;#039;&amp;#039;V&amp;#039; &amp;#039;&amp;#039; always yields the same content as &amp;#039;&amp;#039;BV&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The idea is that &amp;#039;&amp;#039;BBm, BBm+1, ..., BBm+o&amp;#039;&amp;#039; represent the original base relations &amp;#039;&amp;#039;B1, B2, ..., Bn&amp;#039;&amp;#039; &amp;lt;u&amp;gt;minus&amp;lt;/u&amp;gt; the view &amp;#039;&amp;#039;V&amp;#039;&amp;#039; -- i.e. the &amp;#039;&amp;#039;complement&amp;#039;&amp;#039; of the view. For example:&lt;br /&gt;
* If &amp;#039;&amp;#039;V&amp;#039;&amp;#039; is a restriction over a single base, its complement could be a base with the same heading, containing the tuples excluded from the view (i.e. disjoint internal predicate).&lt;br /&gt;
* If &amp;#039;&amp;#039;V&amp;#039;&amp;#039; is a projection over a single base, its complement could be a base with the projected-out attributes, plus a key to join back.&lt;br /&gt;
: To be information equivalent/a lossless decomposition would need declaring an EQD between the two projections.&lt;br /&gt;
* If &amp;#039;&amp;#039;V&amp;#039;&amp;#039; is a join, its complement could be two bases with the headings of the original bases, containing respectively the tuples not MATCHING.&lt;br /&gt;
&lt;br /&gt;
In general there will be many ways to choose the schema and internal predicates for &amp;#039;&amp;#039;BBm, BBm+1, ..., BBm+o&amp;#039;&amp;#039;. The schema designer has a free hand to decompose or combine the original bases.&lt;br /&gt;
&lt;br /&gt;
=== Constant complement ===&lt;br /&gt;
&lt;br /&gt;
The ideal choice of complement is one in which the view-as-base &amp;#039;&amp;#039;BV&amp;#039;&amp;#039; can be freely updated without requiring update to any other bases; and from which update bases-as-views &amp;#039;&amp;#039;VB1, VB2, ..., VBn&amp;#039;&amp;#039; are correctly generated, such that &amp;#039;&amp;#039;V&amp;#039; &amp;#039;&amp;#039; yields the same as &amp;#039;&amp;#039;BV&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
* With the restriction view, since its complement has a disjunctive internal predicate, tuples can be freely updated into the view-as-base. (An attempt to modify an existing tuple to values that would exclude it from the restriction is disallowed, because that would violate the view-as-base&amp;#039;s internal predicate.)&lt;br /&gt;
&lt;br /&gt;
* With the projection view-as-base, it is possible to modify the non-key attributes; but not insert (because tuples would need to be inserted to the complement, to be able to join); and (arguably) not delete, because the &amp;#039;information equivalence&amp;#039; requirement imposes an EQD on the keys.&lt;br /&gt;
&lt;br /&gt;
* With the join view-as-base, opportunities for update are even more limited. (Only modify the non-common attributes; not INSERT because that might need &amp;#039;moving&amp;#039; a tuple from the complement to the join-as-base; not DELETE because that might need &amp;#039;moving&amp;#039; a tuple to the complement.)&lt;br /&gt;
&lt;br /&gt;
It is notable that the example initial base schema B&amp;amp;S work with (two base relations each of two attributes) has an unusually large number of integrity constraints, including bi-directional Functional Dependencies, and an EQD such that the two relations are a lossless decomposition.&lt;br /&gt;
&lt;br /&gt;
B&amp;amp;S tighten the screw further [Secion 3]:&lt;br /&gt;
&amp;lt;blockquote&amp;gt; User requirements impose two constraints on this set [of &amp;#039;&amp;#039;translatable&amp;#039;&amp;#039; updates], namely,&lt;br /&gt;
(i) If the user is allowed two updates &amp;#039;&amp;#039;u&amp;#039;&amp;#039; and &amp;#039;&amp;#039;v&amp;#039;&amp;#039;, then he must be allowed the composite update &amp;#039;&amp;#039;uv&amp;#039;&amp;#039;.&amp;lt;br/&amp;gt;&lt;br /&gt;
(ii) The user must have the means to cancel, if he wishes, the effect of every update that he is allowed to the view.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Re (i) they don&amp;#039;t appear to consider that applying &amp;#039;&amp;#039;u&amp;#039;&amp;#039; might make &amp;#039;&amp;#039;v&amp;#039;&amp;#039; invalid (or &amp;#039;&amp;#039;v.v.&amp;#039;&amp;#039;).&lt;br /&gt;
Re (ii), it is not clear which User(s) stated this requirement, or why.&lt;br /&gt;
&lt;br /&gt;
== The invalid assumption: that base relvars are independently updatable ==&lt;br /&gt;
&lt;br /&gt;
Behind the hold-the-complement-constant approach is an assumption that if a view can be updated independently, as if it was a base, it is first-class. On the grounds updates to each base are independent (and are therefore first-class), because they hold all other bases constant.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;The problem of finding independent views is extremely important in database theory.&amp;quot; pronounce B&amp;amp;S [section 6], with no citation (beyond their own technical work).&lt;br /&gt;
&lt;br /&gt;
To put it plainly: updates to base are not necessarily independent. And B&amp;amp;S need look no further than their own initial schema. Updates are not independent because of inter-relational constraints. B&amp;amp;S&amp;#039;s should look at how &amp;#039;tight&amp;#039; are the constraints in their schema (two base relations), and consider that neither base relation could form a constant complement of the other.&lt;br /&gt;
&lt;br /&gt;
Independence of update of base relations is indeed an important criterion for schema design: Normalisation is to remove redundancy/avoid update anomalies. Note, though, that if a normalised schema is to be information-equivalent to its un-normalised predecessor, each decomposition must add inter-relational constraints to ensure lossless re-composition.&lt;br /&gt;
&lt;br /&gt;
Inter-relational constraints are the norm with mature schema designs. Therefore an ideal of independent update is unachievable for base relations. It is an entirely pointless criterion for update through views.&lt;br /&gt;
&lt;br /&gt;
== Orthogonal Design and updating base relations ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;Orthogonal Design&amp;#039; (Principle Of, introduced as part of Date &amp;amp; McGoveran&amp;#039;s 1994 treatment of updating through views) of a schema is claimed to be essential to translating updates through a view to updates to base. Definitions vary for what POOD means precisely, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;quot;Loosely, the principle that no two relvars in a given database should  have overlapping meanings.&amp;quot; says Date in his Relational DB Dictionary (2008 Extended Edition). And Date goes on to give a precise extensional definition.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;  The  semantic  orthogonality  property  holds in a  database design (a  particular schema)  if and only  if, ignoring  multi-relation constraints,  there  is no &amp;quot;overlap&amp;quot;  or redundancy  between the intended membership of any  two relations in the schema.  If this is  true, then we  can  add (or remove) tuples to  (from)  one  without  that operation in and of itself  implying  tuples need to be added (or removed)  to the  other  for  database  consistency,  except as required by  some  multi-relation constraint  (e.g.,  a  foreign key).  This notion is  analogous to having  orthogonal axes in a coordinate  system:  The  variables such axes represent are independent  –  we  can  alter the  value  on one  such  variable without altering  any  of the  others. &amp;quot; says McGoveran in his draft Chapter on Updating Relations (2015).&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As we have seen, normalising a design (so that &amp;quot;we can add (or remove) tuples to (from) [a relation] without that operation in and of itself implying [other] tuples need to be added (or removed) to &amp;quot; that same relation &amp;quot;for database consistency&amp;quot;) entails defining multi-relation constraints to preserve information equivalence. So allowing an exception for inter-relational (multi-relation) constraints makes POOD a dead letter.&lt;br /&gt;
&lt;br /&gt;
Behind B&amp;amp;S&amp;#039;s advocacy for constant complement is the presumption that base relations are first-class because &amp;quot;we  can  alter the  value  on one  such [relation] without altering  any  of the  others&amp;quot;. This in fact does not apply for base relations (because of muti-relation constraints). Neither is it reasonable to expect it to apply for update through views, &amp;#039;&amp;#039;a fortiori&amp;#039;&amp;#039; because their content is redundant necessarily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To compare updates to a base relvar subject to a multi-relation constraint with update through a view:&lt;br /&gt;
&lt;br /&gt;
* Consider an INSERT to a base relation that is the dependent in an INclusion Dependency.&lt;br /&gt;
: That INSERT might fail because there is no matching tuple in the defining base relation.&lt;br /&gt;
: Violation of the IND can only be detected at run time.&lt;br /&gt;
: Does this mean the base relation is not updatable-to?&lt;br /&gt;
&lt;br /&gt;
* Then consider an INSERT through a view defined using MATCHING.&lt;br /&gt;
: If that&amp;#039;s translated to an INSERT to the MATCHING&amp;#039;s left operand, it might fail because there is no matching tuple in the right operand.&lt;br /&gt;
:: (That is, fail because the inserted tuple would therefore not appear in the resulting value for the view -- violating &amp;#039;&amp;#039;no side effects&amp;#039;&amp;#039;/The Assignment Principle.)&lt;br /&gt;
: So (arguably) violation of The Assignment Principle can only be detected at run time.&lt;br /&gt;
: Does this mean the MATCHING view is not updatable-through?&lt;br /&gt;
&lt;br /&gt;
[in progress]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Bancilhon and Spyratos 1981 &amp;quot;Update Semantics of Relational Views&amp;quot;&lt;br /&gt;
: http://pages.cs.wisc.edu/~jhuang/qual/update-semantics-of-views.pdf&lt;br /&gt;
&lt;br /&gt;
* David McGoveran Chapter draft March 2015 &amp;quot;Can  All  Relations Be Updated? &amp;quot;/&amp;quot;Updating Relations&amp;quot;&lt;br /&gt;
: http://www.alternativetech.com/publications/Logic%20for%20DB%20Folks%20Series%20XX%20-%20Updating%20Relations.pdf&lt;br /&gt;
&lt;br /&gt;
* Chris Date 2008 &amp;quot;The Relational Database Dictionary, Extended Edition&amp;quot;&lt;br /&gt;
: http://www.apress.com/book/view/1430210419&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See also [[Update through views: a possible approach#References]]&lt;/div&gt;</summary>
		<author><name>AntC</name></author>	</entry>

	<entry>
		<id>http://d2.reldb.org/index.php/Update_through_views:_a_seminal_paper_-_appreciation,_commentary,_critique</id>
		<title>Update through views: a seminal paper - appreciation, commentary, critique</title>
		<link rel="alternate" type="text/html" href="http://d2.reldb.org/index.php/Update_through_views:_a_seminal_paper_-_appreciation,_commentary,_critique"/>
				<updated>2017-02-09T05:25:22Z</updated>
		
		<summary type="html">&lt;p&gt;AntC: /* no side effects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;My gold standard for expressing principles to do with updating-through-views is Dayal &amp;amp; Bernstein 1978 &amp;quot;On the Updatability of Relational Views&amp;quot;, section &amp;quot;Correctness Criteria for View Updates&amp;quot;. That&amp;#039;s not to say I entirely agree with them, but I&amp;#039;m impressed that they have expressed their approach in one sentence of ~50 words, plus 4 paragraphs to explain each key term. The surprise is how soon this was published after Codd&amp;#039;s papers elaborating the RM.&lt;br /&gt;
&lt;br /&gt;
Contrast that [http://computing.derby.ac.uk/c/codds-twelve-rules/ Codd&amp;#039;s 12 Rules], including the prescription for update-through-view, and definition for &amp;quot;theoretically updatable&amp;quot; was published in 1985. Codd says &amp;quot;Although I have defined each rule in earlier papers, I believe this to be the first occurrence of all twelve of them together.&amp;quot;, and cites a paper &amp;quot;conceived in 1981&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Another influential paper of the same vintage, Bancilhon &amp;amp; Spyratos 1981, introduced the &amp;quot;constant complement&amp;quot; approach (which anticipates Date&amp;#039;s Principle of Interchangeability).&lt;br /&gt;
&lt;br /&gt;
== Correctness Criteria for View Updates ==&lt;br /&gt;
&lt;br /&gt;
The model sentence:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Given a semantically consistent schema extension &amp;#039;&amp;#039;&amp;#039;$*&amp;#039;&amp;#039;&amp;#039;, we say that an update operation &amp;#039;&amp;#039;&amp;#039;u&amp;#039;&amp;#039;&amp;#039; on view extension &amp;#039;&amp;#039;&amp;#039;V*&amp;#039;&amp;#039;&amp;#039; is &amp;#039;&amp;#039;translatable&amp;#039;&amp;#039; if there is a &amp;#039;&amp;#039;unique&amp;#039;&amp;#039; set of updates &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039; on &amp;#039;&amp;#039;&amp;#039;$*&amp;#039;&amp;#039;&amp;#039; producing the desired update on &amp;#039;&amp;#039;&amp;#039;V*&amp;#039;&amp;#039;&amp;#039;, such that there are &amp;#039;&amp;#039;no extraneous updates&amp;#039;&amp;#039; in &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039;, &amp;#039;&amp;#039;no side effects&amp;#039;&amp;#039; on &amp;#039;&amp;#039;&amp;#039;V*&amp;#039;&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;preserves semantic consistency&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Explanations:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
An update is &amp;#039;&amp;#039;extraneous&amp;#039;&amp;#039; in &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039; if &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039; produces the same effect on the view extension with or without the extraneous update.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
The set of updates &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039; has &amp;#039;&amp;#039;no side effects&amp;#039;&amp;#039; if &amp;#039;&amp;#039;only&amp;#039;&amp;#039; the desired update is performed on the view. &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
A set of update operations on a semantically consistent schema extension &amp;#039;&amp;#039;preserves semantic consistency&amp;#039;&amp;#039; if the resulting schema extension is also semantically consistent.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
The &amp;#039;&amp;#039;uniqueness&amp;#039;&amp;#039; criterion is controversial and requires some justification. This criterion says that the inverse mapping (of the view definition) from view extensions to schema extensions must be a function. &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
They add:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
There is another uncomfortable dimension to the issue of translatability. In our examples, we translated a view insertion only into &amp;#039;&amp;#039;insertions&amp;#039;&amp;#039; on the base relations. Should we permit an insertion to map to deletions and replacements as well? &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Their conclusion I find elusive (and it appears only at the end of the abstract, rather than in the Conclusion section):&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
In summary, our theorems show that there are very few situations in which view updates are possible--even fewer, in fact, than intuition might suggest. &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
How few are &amp;quot;very few&amp;quot;? Compared to what? How few &amp;quot;might intuition suggest&amp;quot;? Was the prevailing opinion at the time that all or nearly all updates through views were possible?&lt;br /&gt;
&lt;br /&gt;
== Commentary, Critique ==&lt;br /&gt;
&lt;br /&gt;
Taking the requirements in sequence presented.&lt;br /&gt;
&lt;br /&gt;
=== &amp;#039;&amp;#039;no extraneous updates&amp;#039;&amp;#039; ===&lt;br /&gt;
&lt;br /&gt;
In other words (and to put it positively), each &amp;quot;update&amp;quot; in &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039; must be necessary to achieving the required effect on the extension. (But this doesn&amp;#039;t say what an &amp;quot;update&amp;quot; is. Presumably any tuple inserted, deleted or replaced. The only example given is a tuple insert into base where a value is to be concocted for an attribute projected out of the view. D&amp;amp;B regard such a value as arbitrary, because any other valid value would do as well. Curiously, they instead propose inserting NULL -- as if that&amp;#039;s not arbitrary!) So both tuples and attribute values can be &amp;#039;&amp;#039;extraneous&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
=== &amp;#039;&amp;#039;no side effects&amp;#039;&amp;#039; ===&lt;br /&gt;
&lt;br /&gt;
That is, the effect on the view must be exactly what was requested in the update. This is &amp;quot;no side effects&amp;quot; in the sense &amp;quot;A secondary, typically undesirable effect&amp;quot; [Oxford online dictionary]. This would be an uncontroversial criterion were it not that:&lt;br /&gt;
* Date &amp;amp; McGoveran&amp;#039;s 1994 treatment did not require it. &lt;br /&gt;
: (And Date had to correct that by giving a grand title &amp;quot;Assignment Principle&amp;quot;.)&lt;br /&gt;
* SQL makes it optional (WITH CHECK OPTION defined on the view) -- that is, with the CHECK opted off, it is possible (for example) to &amp;#039;successfully&amp;#039; insert tuples that do not subsequently appear in the view. (&amp;#039;Successfully&amp;#039; in the sense there is no error message, and the tuples are inserted into base.)&lt;br /&gt;
: This is a strange sort of non-optional OPTION: for some views opting off prevents any attempts at certain updates through the view -- even for tuples that could validly appear.&lt;br /&gt;
&lt;br /&gt;
=== &amp;#039;&amp;#039;preserves semantic consistency&amp;#039;&amp;#039; ===&lt;br /&gt;
&lt;br /&gt;
I.e. all constraints must hold; Date&amp;#039;s &amp;quot;Golden Rule&amp;quot;. Again uncontroversial. D&amp;amp;B consider only key/Functional Dependencies, not Foreign Key constraints/INclusion Dependencies, nor more exotic constraints. &amp;quot;Since keys are syntactic constructs, they will give us a compile-time check on update translatabililty.&amp;quot; [Section 5.] And their detailed workings do not take any opportunity to consider at run-time the content of the base relations.&lt;br /&gt;
&lt;br /&gt;
=== &amp;#039;&amp;#039;uniqueness&amp;#039;&amp;#039; ===&lt;br /&gt;
&lt;br /&gt;
D&amp;amp;B admit up front this is controversial. The three sentences immediately following the explanation above:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
The alternative, of course, is that there are several distinct sets of schema updates that will alter the view extension as desired. The problem in the latter case is how to choose which set to apply. An arbitrary choice seems unacceptable. &lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
I agree &amp;quot;an arbitrary choice seems unacceptable&amp;quot; -- this is the same thinking as rejecting &amp;#039;&amp;#039;extraneous&amp;#039;&amp;#039; updates.&lt;br /&gt;
&lt;br /&gt;
As to &amp;quot;how to choose&amp;quot;, I think D&amp;amp;B have simply made an error in logic (their &amp;quot;of course&amp;quot; does not follow). For there to be a unique such &amp;quot;set of schema updates&amp;quot;, yes it would be sufficient for there to be an inverse mapping from view to schema (base) -- that&amp;#039;s an ideal; but it is &amp;lt;u&amp;gt;not necessary&amp;lt;/u&amp;gt;. To be &amp;#039;&amp;#039;unique&amp;#039;&amp;#039;, all that&amp;#039;s needed is there be one set of non-&amp;#039;&amp;#039;extraneous&amp;#039;&amp;#039; schema updates that wil alter the view extension as desired. That is, one set that alters the view extension as desired &amp;lt;u&amp;gt;for this particular update request&amp;lt;/u&amp;gt; (delete, insert, etc). The inverse mapping criterion amounts to not only achieving this particular request, but also being able to reverse that request, returning both the view and base to &amp;#039;&amp;#039;status quo ante&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
=== map &amp;#039;&amp;#039;insertions only into insertions&amp;#039;&amp;#039; ===&lt;br /&gt;
&lt;br /&gt;
From later in the explanation:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Some additional semantics are required. We have chosen to map view updates of one type (insertions, deletions, replacements) to schema updates &amp;#039;&amp;#039;of the same type&amp;#039;&amp;#039;. Theoretically, this choice is arbitrary. Intuitively, though, it makes good sense ...&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I cannot see it makes sense in all cases: the only way to ensure insert-through-MINUS is to insert into the minuend, but &amp;lt;u&amp;gt;delete&amp;lt;/u&amp;gt; from the subtrahend -- otherwise the insertion will not appear in the result, i.e. a &amp;#039;&amp;#039;side effect&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The examples D&amp;amp;B consider here (such as replacing a tuple for a requested insert, in order to preserve semantic consistency) all fail on other of their criteria -- especially causing &amp;#039;&amp;#039;side effects&amp;#039;&amp;#039;, or risking causing &amp;#039;&amp;#039;side effects&amp;#039;&amp;#039; depending on other content of the base schema.&lt;br /&gt;
&lt;br /&gt;
Furthermore since they&amp;#039;re concluding &amp;quot;there are very few situations in which view updates are possible&amp;quot;, there is no requirement for &amp;quot;some additional semantics&amp;quot;. &amp;#039;Back off&amp;#039; the semantic requirements, and more views will be updatable-through.&lt;br /&gt;
&lt;br /&gt;
== The paper&amp;#039;s contribution to [[Update through views: a possible approach]] ==&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;preserves semantic consistency&amp;#039;&amp;#039; (&amp;quot;Golden Rule&amp;quot;) and &amp;#039;&amp;#039;no side effects&amp;#039;&amp;#039; (&amp;quot;Assignment Principle&amp;quot;) are my prescription 1 and 2.&lt;br /&gt;
&lt;br /&gt;
D&amp;amp;B&amp;#039;s aim for &amp;quot;compile time check on update translatability&amp;quot; is another implicit criterion/restraint on algorithms. It appears as my prescription 3.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;no extraneous updates&amp;#039;&amp;#039; and &amp;#039;&amp;#039;unique&amp;#039;&amp;#039; set of updates are my prescription 4 (necessary and sufficient/&amp;#039;&amp;#039;essential&amp;#039;&amp;#039; tuples and attribute values) -- which is more explicit about what constitutes a &amp;quot;set of updates&amp;quot; and what it is for something in that set to be &amp;#039;&amp;#039;extraneous&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
Can I express the prescriptions as succinctly as D&amp;amp;B&amp;#039;s criteria?&lt;br /&gt;
&lt;br /&gt;
Given a semantically consistent schema extension &amp;#039;&amp;#039;&amp;#039;$*&amp;#039;&amp;#039;&amp;#039;, we say that an update operation &amp;#039;&amp;#039;&amp;#039;u&amp;#039;&amp;#039;&amp;#039; on view extension &amp;#039;&amp;#039;&amp;#039;V*&amp;#039;&amp;#039;&amp;#039; is &amp;#039;&amp;#039;translatable&amp;#039;&amp;#039; if there is a set of tuple inserts, deletes and replacements &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039; on &amp;#039;&amp;#039;&amp;#039;$*&amp;#039;&amp;#039;&amp;#039;, together &amp;#039;&amp;#039;sufficient&amp;#039;&amp;#039; to produce the desired update on &amp;#039;&amp;#039;&amp;#039;V*&amp;#039;&amp;#039;&amp;#039;, such that each tuple operation is &amp;#039;&amp;#039;necessary&amp;#039;&amp;#039; in &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039;, the &amp;#039;&amp;#039;precise effect&amp;#039;&amp;#039; on &amp;#039;&amp;#039;&amp;#039;V*&amp;#039;&amp;#039;&amp;#039; is as requested, &amp;#039;&amp;#039;&amp;#039;U&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;preserves semantic consistency&amp;#039;&amp;#039;, and the &amp;#039;&amp;#039;translation is statically determinable&amp;#039;&amp;#039; purely from the form of the update request, the schema and view definition and the semantic integrity constraints.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
Dayal and Bernstein 1978 &amp;quot;On the Updatability of Relational Views”&lt;br /&gt;
https://pdfs.semanticscholar.org/39f4/853a35a913c714c5f3956dbefd02916447c4.pdf&lt;br /&gt;
&lt;br /&gt;
See also [[Update through views: a possible approach#References]]&lt;/div&gt;</summary>
		<author><name>AntC</name></author>	</entry>

	<entry>
		<id>http://d2.reldb.org/index.php/Update_through_views:_rewrites</id>
		<title>Update through views: rewrites</title>
		<link rel="alternate" type="text/html" href="http://d2.reldb.org/index.php/Update_through_views:_rewrites"/>
				<updated>2017-02-07T10:31:45Z</updated>
		
		<summary type="html">&lt;p&gt;AntC: /* Semantics: effect of update operations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[todo: currently includes all examples from discussions; add more rewrites for full coverage; precisely specify the rewrite rules and qualifying conditions]&lt;br /&gt;
&lt;br /&gt;
== Preliminaries/general approach ==&lt;br /&gt;
&lt;br /&gt;
Assume a variant of &amp;#039;&amp;#039;&amp;#039;Tutorial D&amp;#039;&amp;#039;&amp;#039; in which targets for update can be relational expressions, not merely relvar names. Then a view name (virtual relvar) is to be a shorthand for its defining expression. We&amp;#039;re already doing that in read contexts. Do so also  in update target contexts.&lt;br /&gt;
&lt;br /&gt;
I.e. if there&amp;#039;s a virtual defined in the form&lt;br /&gt;
* VAR &amp;#039;&amp;#039;V&amp;#039;&amp;#039; VIRTUAL (&amp;#039;&amp;#039;R&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;p&amp;#039;&amp;#039;)&lt;br /&gt;
: as a target for update&lt;br /&gt;
* UPDATE &amp;#039;&amp;#039;V&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;q&amp;#039;&amp;#039; : &amp;#039;&amp;#039;assigns&amp;#039;&amp;#039;;&lt;br /&gt;
expand to the syntax for update &amp;#039;targets&amp;#039; as relational expressions:&lt;br /&gt;
* UPDATE (&amp;#039;&amp;#039;R&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;p&amp;#039;&amp;#039;) WHERE &amp;#039;&amp;#039;q&amp;#039;&amp;#039; : &amp;#039;&amp;#039;assigns&amp;#039;&amp;#039;;&lt;br /&gt;
: Is only a smidgeon away from:&lt;br /&gt;
* UPDATE &amp;#039;&amp;#039;R&amp;#039;&amp;#039; WHERE (&amp;#039;&amp;#039;p&amp;#039;&amp;#039; AND &amp;#039;&amp;#039;q&amp;#039;&amp;#039;) : &amp;#039;&amp;#039;assigns&amp;#039;&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
So that is now targetting a base variable.&lt;br /&gt;
&lt;br /&gt;
A virtual&amp;#039;s defining expression might itself refer to virtuals. Recursively substitute their defining expressions, until the target expression consists only of base relvar names, literals/constants and relational operators.&lt;br /&gt;
&lt;br /&gt;
Where a given base relvar appears more than once in the target expression, refactor the expression (if possible) so that it appears only once. For example:&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40%; &amp;quot; | (&amp;#039;&amp;#039;R&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;p&amp;#039;&amp;#039;) UNION (&amp;#039;&amp;#039;R&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;q&amp;#039;&amp;#039;)   || ==&amp;gt; &amp;#039;&amp;#039;R&amp;#039;&amp;#039; WHERE (&amp;#039;&amp;#039;p&amp;#039;&amp;#039; OR &amp;#039;&amp;#039;q&amp;#039;&amp;#039;)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;R&amp;#039;&amp;#039; MINUS (&amp;#039;&amp;#039;R&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;q&amp;#039;&amp;#039;)  || ==&amp;gt; &amp;#039;&amp;#039;R&amp;#039;&amp;#039; WHERE NOT &amp;#039;&amp;#039;q&amp;#039;&amp;#039;&lt;br /&gt;
|}&lt;br /&gt;
: That is, refactor using the equational equivalences used typically for optimising query plans. These must be information-preserving.&lt;br /&gt;
: If a multiply-occuring base relvar cannot be refactored to a single occurence, that is of itself survivable, but it might have the effect that some &amp;#039;&amp;#039;relexpr&amp;#039;&amp;#039; is not updatable-through, whereas a suitably refactored expression would be.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If there&amp;#039;s an IND between two relations &amp;#039;&amp;#039;R1, R2&amp;#039;&amp;#039;, it doesn&amp;#039;t seem a big stretch to put them together as target in a single update statement, rather than two. (That is, put them together as a shorthand for the Multiple Assignment. Figuring out the separate updates is something a dbms could do mechanically; why impose that load on the programmer?)&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 40%; &amp;quot; | INSERT (&amp;#039;&amp;#039;R1&amp;#039;&amp;#039; JOIN &amp;#039;&amp;#039;R2&amp;#039;&amp;#039;) &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;   || ==&amp;gt; INSERT &amp;#039;&amp;#039;R1&amp;#039;&amp;#039; (&amp;#039;&amp;#039;v&amp;#039;&amp;#039; {attribs of &amp;#039;&amp;#039;R1&amp;#039;&amp;#039;}&amp;#039;&amp;#039;&amp;#039;,&amp;#039;&amp;#039;&amp;#039; INSERT &amp;#039;&amp;#039;R2&amp;#039;&amp;#039; (&amp;#039;&amp;#039;v&amp;#039;&amp;#039; {attribs of &amp;#039;&amp;#039;R2&amp;#039;&amp;#039;});&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In various examples I&amp;#039;ve identified the sort of criteria that can be considered:&lt;br /&gt;
*	keys and cardinality of joins&lt;br /&gt;
*	constraints (particularly INDs)&lt;br /&gt;
*	projections that make attributes &amp;#039;inaccessible&amp;#039; from the view&lt;br /&gt;
*	the form of the update request, Prescription 2.&lt;br /&gt;
	(for example DELETE ... WHERE ... could succeed whereas DELETE ... v might not.)&lt;br /&gt;
*	in general anything that can be examined at compile time, Prescription 3.&lt;br /&gt;
&lt;br /&gt;
== Semantics: effect of update operations ==&lt;br /&gt;
&lt;br /&gt;
For definiteness, this is the specified effect for the update operations (Prescription 2), in style of RM Prescription 21&lt;br /&gt;
&amp;lt;blockquote&amp;gt;After  assignment  of  v  to  V  (the  “target variable”),  the  equality  comparison  V  =  v  shall  evaluate  to  TRUE.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: These are entirely standard; stated here to show equivalences of update operations.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
! style=&amp;quot;width: 35%; &amp;quot; | Operation (see [[#Notation]]) !! After update this equation shall hold true (where &amp;#039;&amp;#039;re&amp;#039; &amp;#039;&amp;#039; is the &amp;#039;after&amp;#039; value)&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
|  INSERT &amp;#039;&amp;#039;re&amp;#039;&amp;#039;  &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;    ||  &amp;#039;&amp;#039;re&amp;#039; &amp;#039;&amp;#039; == &amp;#039;&amp;#039;re&amp;#039;&amp;#039; UNION &amp;#039;&amp;#039;v&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
| DELETE &amp;quot;re&amp;quot;  &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;   ||  &amp;#039;&amp;#039;re&amp;#039; &amp;#039;&amp;#039; == &amp;#039;&amp;#039;re&amp;#039;&amp;#039; MINUS&amp;#039;&amp;#039; &amp;#039;&amp;#039;v&amp;#039;&amp;#039;&lt;br /&gt;
|-&lt;br /&gt;
| DELETE &amp;quot;re&amp;quot; WHERE &amp;#039;&amp;#039;p&amp;#039;&amp;#039;;  || &amp;#039;&amp;#039;re&amp;#039; &amp;#039;&amp;#039; == &amp;#039;&amp;#039;re&amp;#039;&amp;#039; MINUS (&amp;#039;&amp;#039;re&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;p&amp;#039;&amp;#039;)&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| UPDATE &amp;#039;&amp;#039;re&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;p&amp;#039;&amp;#039; : &amp;#039;&amp;#039;assigns&amp;#039;&amp;#039;;  || &amp;#039;&amp;#039;re&amp;#039; &amp;#039;&amp;#039; == (&amp;#039;&amp;#039;re&amp;#039;&amp;#039; MINUS (&amp;#039;&amp;#039;re&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;p&amp;#039;&amp;#039;)) UNION &amp;#039;&amp;#039;Upd&amp;#039;&amp;#039;((&amp;#039;&amp;#039;re&amp;#039;&amp;#039; WHERE &amp;#039;&amp;#039;p&amp;#039;&amp;#039;), &amp;#039;&amp;#039;assigns&amp;#039;&amp;#039;)&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;re&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;:=&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;  // assignment   || &amp;#039;&amp;#039;re&amp;#039; &amp;#039;&amp;#039; == &amp;#039;&amp;#039;v&amp;#039;&amp;#039;,  == (&amp;#039;&amp;#039;re&amp;#039;&amp;#039; MINUS (&amp;#039;&amp;#039;re&amp;#039;&amp;#039; MINUS &amp;#039;&amp;#039;v&amp;#039;&amp;#039;)) UNION (&amp;#039;&amp;#039;v&amp;#039;&amp;#039; MINUS &amp;#039;&amp;#039;re&amp;#039;&amp;#039;)&lt;br /&gt;
|}       &lt;br /&gt;
&lt;br /&gt;
The rewrites may take advantage of the following equivalences, especially so that some operation be supported which would not otherwise be updatable-through.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
! style=&amp;quot;width: 40%; &amp;quot; | Operation         !! ==&amp;gt; equivalent operation&lt;br /&gt;
|-&lt;br /&gt;
| INSERT &amp;#039;&amp;#039;re&amp;#039;&amp;#039;  &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;    || ==&amp;gt; &amp;#039;&amp;#039;re&amp;#039;&amp;#039; := &amp;#039;&amp;#039;re&amp;#039;&amp;#039; UNION &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;&lt;br /&gt;
|-&lt;br /&gt;
| DELETE &amp;#039;&amp;#039;re&amp;#039;&amp;#039;  &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;   || ==&amp;gt;  &amp;#039;&amp;#039;re&amp;#039;&amp;#039; := &amp;#039;&amp;#039;re&amp;#039;&amp;#039; MINUS &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;&lt;br /&gt;
|-&lt;br /&gt;
| DELETE &amp;#039;&amp;#039;re&amp;#039;&amp;#039;  &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;   || ==&amp;gt; DELETE &amp;#039;&amp;#039;re&amp;#039;&amp;#039; WHERE (rel{tup{*}} MATCHING &amp;#039;&amp;#039;v&amp;#039;&amp;#039;);&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;re&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;:=&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;v&amp;#039;&amp;#039;;          || ==&amp;gt; DELETE &amp;#039;&amp;#039;re&amp;#039;&amp;#039; (&amp;#039;&amp;#039;re&amp;#039;&amp;#039; MINUS &amp;#039;&amp;#039;v&amp;#039;&amp;#039;) &amp;#039;&amp;#039;&amp;#039;,&amp;#039;&amp;#039;&amp;#039; INSERT &amp;#039;&amp;#039;re&amp;#039;&amp;#039; (&amp;#039;&amp;#039;v&amp;#039;&amp;#039; MINUS &amp;#039;&amp;#039;re&amp;#039;&amp;#039;);&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
: In particular, &amp;#039;&amp;#039;&amp;#039;:=&amp;#039;&amp;#039;&amp;#039; assignment is only supported on condition that both DELETE and INSERT are supported, so usually is rewritten as such.&lt;br /&gt;
&lt;br /&gt;
== Sub-terms that are not updatable-through ==&lt;br /&gt;
&lt;br /&gt;
Where a sub-term is a literal/constant, it is not updatable-through. (In effect it is subject to a constraint that it always be that value, so falls under Prescription 2 &amp;quot;Golden Rule&amp;quot;.) Rewrites can take advantage of that constraint to disambiguate rewrites. For example&lt;br /&gt;
&lt;br /&gt;
[to do]&lt;br /&gt;
&lt;br /&gt;
== Notation ==&lt;br /&gt;
{|&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| style=&amp;quot;width: 25%; &amp;quot; | &amp;#039;&amp;#039;relexpr, re, re&amp;#039;, re1, re2, ...&amp;#039;&amp;#039;  || relational expressions&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;R, R&amp;#039;, R1, R2, ...&amp;#039;&amp;#039;     || relvar names (i.e. bases)&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;p, q, p1, q1, ...&amp;#039;&amp;#039;   || predicate expressions (booleans) for WHERE clauses&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;assigns&amp;#039;&amp;#039;    || attribute assignment lists in UPDATE or EXTEND&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;Upd&amp;#039;&amp;#039;(&amp;#039;&amp;#039;relexpr&amp;#039;&amp;#039;, &amp;#039;&amp;#039;assigns&amp;#039;&amp;#039;)   || a function that applies &amp;#039;&amp;#039;assigns&amp;#039;&amp;#039; to the relation value of &amp;#039;&amp;#039;relexpr&amp;#039;&amp;#039;, yielding a relation value&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| ==&amp;gt; || rewrite rule: transform the left operation to the right&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;lt;==&amp;gt;   || two-way rewrite: transform in either direction&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| rel{tup{*}} || a singleton relation formed from the &amp;#039;current&amp;#039; tuple of some enclosing relation expression&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;relop&amp;#039;&amp;#039;   || an arbitrary relational operator (infix), including projection considered as an operator&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;relexpr&amp;#039;&amp;#039; {attribs of &amp;#039;&amp;#039;re2&amp;#039;&amp;#039;}   || a projection of &amp;#039;&amp;#039;relexpr&amp;#039;&amp;#039; on the attributes of &amp;#039;&amp;#039;re2&amp;#039;&amp;#039;&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;&amp;quot;&lt;br /&gt;
| &amp;#039;&amp;#039;upd1&amp;#039;&amp;#039; &amp;#039;&amp;#039;&amp;#039;,&amp;#039;&amp;#039;&amp;#039; &amp;#039;&amp;#039;upd2&amp;#039;&amp;#039;;   || Note the &amp;#039;&amp;#039;&amp;#039;,&amp;#039;&amp;#039;&amp;#039; comma, not semicolon separating two update statements. This is standard &amp;#039;&amp;#039;&amp;#039;Tutorial D&amp;#039;&amp;#039;&amp;#039; Multiple Update (aka Multiple Assignment). Typically the rewrites for a target with more than one base relvar will be set of Multiple Updates (separated by commas), one for each relvar. The rewrites will &amp;#039;walk&amp;#039; down the target&amp;#039;s expression tree, generating an update for each sub-term until it gets to the base relvars.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== JOINs ==&lt;br /&gt;
A)	INSERT through 1:many JOIN with IND&lt;br /&gt;
	Supported for update.&lt;br /&gt;
*	INSERT (R1 JOIN R2) v ;&lt;br /&gt;
:	==&amp;gt; INSERT R1 (v{attribs of R1}), INSERT R2 (v{attribs of R2});&lt;br /&gt;
&lt;br /&gt;
B)	INSERT through 1:many JOIN without IND&lt;br /&gt;
	Not supported: an INSERT on the 1 side could MATCH tuples already in the many side,&lt;br /&gt;
	that would thereby &amp;#039;appear&amp;#039; in the result; so breaking Assignment Principle.&lt;br /&gt;
&lt;br /&gt;
C)	DELETE through 1:many JOIN (with or without IND)&lt;br /&gt;
	Supported: delete from the many side only.&lt;br /&gt;
*	DELETE (R1 JOIN R2) v;           // R2 is the many side&lt;br /&gt;
:	==&amp;gt; DELETE R2 ( (R2 MATCHING R1) MATCHING v);&lt;br /&gt;
	Deleting from the 1 side might &amp;#039;unMATCH&amp;#039; non-targetted tuples on the many side,&lt;br /&gt;
	that would thereby &amp;#039;disappear&amp;#039; from the result.&lt;br /&gt;
	If no such tuples, we might DELETE the 1 side, but that&amp;#039;s not essential.&lt;br /&gt;
&lt;br /&gt;
D)	DELETE through 1:1 JOIN with two-way IND (i.e. EQD)&lt;br /&gt;
	Supported: delete from both sides.&lt;br /&gt;
*	DELETE (R1 JOIN R2) v; &lt;br /&gt;
: ==&amp;gt; DELETE R1 ( (R1 MATCHING R2) MATCHING v),     // Multiple Update&lt;br /&gt;
:: DELETE R2 ( (R2 MATCHING R1) MATCHING v);&lt;br /&gt;
&lt;br /&gt;
E)	DELETE through 1:1 JOIN with a single IND&lt;br /&gt;
	Supported: delete from the dependent (subset) side only.&lt;br /&gt;
*	DELETE (R1 JOIN R2) v;           // R2 is the subset side&lt;br /&gt;
:	==&amp;gt; DELETE R2 ( (R2 MATCHING R1) MATCHING v);&lt;br /&gt;
&lt;br /&gt;
F)	DELETE through 1:1 join without IND&lt;br /&gt;
	Not supported: could be achieved by deleting from either side only or both.&lt;br /&gt;
	Then neither tuple DELETE is essential.&lt;br /&gt;
&lt;br /&gt;
: Assign through 1:many JOIN with IND&lt;br /&gt;
*	(R1 JOIN R2) := v;&lt;br /&gt;
	==&amp;gt; DELETE (R1 JOIN R2) ((R1 JOIN R2) MINUS v), INSERT (R1 JOIN R2) (v MINUS (R1 JOIN R2));&lt;br /&gt;
&lt;br /&gt;
== Restrictions ==&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;Appendix A&amp;#039;&amp;#039;&amp;#039; approach is that Restrictions are Joins. And yet joins that arise from restrictions are typically not joins of bases. Examples:&lt;br /&gt;
&lt;br /&gt;
* (R WHERE X = 1) &amp;lt;==&amp;gt; R JOIN REL{TUP{X 1}}&lt;br /&gt;
: REL{TUP{X 1}} is not a base. In fact it&amp;#039;s a constant, so not updatable at all.&lt;br /&gt;
&lt;br /&gt;
* (R WHERE X &amp;gt; Y) &amp;lt;==&amp;gt; R JOIN REL{{{x, y} | x IN dom(X), y IN dom(Y), x &amp;gt; y}}&lt;br /&gt;
: That REL{ } is not a base. I&amp;#039;ve defined it using set builder notation. In fact it&amp;#039;s a constant, so not updatable at all.&lt;br /&gt;
&lt;br /&gt;
* In case of (R WHERE &amp;lt;subselect on R2&amp;gt;) we need to consider more carefully. Typically R2 has attributes that don&amp;#039;t appear in R, so any update would amount to update-through-projection. Which is a different kettle of fish to update-through-join.&lt;br /&gt;
&lt;br /&gt;
So we need update-through-restriction, which is usually regarded as non-controversial:&lt;br /&gt;
* INSERT (R WHERE p) v; ==&amp;gt; INSERT R (v WHERE p);&lt;br /&gt;
* DELETE (R WHERE p) v; ==&amp;gt; DELETE R (v WHERE p);&lt;br /&gt;
* DELETE (R WHERE p) WHERE q; ==&amp;gt; DELETE R WHERE (p AND q)&lt;br /&gt;
* Therefore assign(:=) is supported, being a combo of DELETE, INSERT.&lt;br /&gt;
* UPDATE also supported, being a combo of DELETE, INSERT.&lt;br /&gt;
: A tad tricky because the updated tuples might fail the restriction.&lt;br /&gt;
: And that attempt should be rejected as failing prescription 2 &amp;quot;Assignment P&amp;quot;. aka SQL&amp;#039;s WITH CHECK OPTION, approximately.&lt;br /&gt;
: Assume I have a function Upd(rel, assigns) that applies assigns to rel:&lt;br /&gt;
: UPDATE (R WHERE p) WHERE q : assigns; ==&amp;gt;&lt;br /&gt;
: IF IS_EMPTY(Upd(R WHERE (p AND q), assigns) WHERE NOT p)&lt;br /&gt;
: THEN UPDATE R WHERE (p AND q) : assigns ; &lt;br /&gt;
: ELSE Fail ; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Projections ==&lt;br /&gt;
&lt;br /&gt;
Projections are awkward for updating through. Push projections towards the leaves as far as possible, for example:&lt;br /&gt;
* For [NOT] MATCHING, which needs a projection and JOIN&lt;br /&gt;
: &amp;#039;&amp;#039;&amp;#039;Appendix A&amp;#039;&amp;#039;&amp;#039; gives: &amp;#039;&amp;#039;re1&amp;#039;&amp;#039; MATCHING &amp;#039;&amp;#039;re2&amp;#039;&amp;#039; ==&amp;gt; (&amp;#039;&amp;#039;re1&amp;#039;&amp;#039; JOIN &amp;#039;&amp;#039;re2&amp;#039;&amp;#039;) { attribs of &amp;#039;&amp;#039;re1&amp;#039;&amp;#039; }&lt;br /&gt;
: Instead: &amp;#039;&amp;#039;re1&amp;#039;&amp;#039; MATCHING &amp;#039;&amp;#039;re2&amp;#039;&amp;#039; ==&amp;gt; &amp;#039;&amp;#039;re1&amp;#039;&amp;#039; JOIN (&amp;#039;&amp;#039;re2&amp;#039;&amp;#039; { attribs in common } )&lt;br /&gt;
&lt;br /&gt;
* For projections that are really implementing RENAME, change to RENAME&lt;br /&gt;
: (EXTEND &amp;#039;&amp;#039;re&amp;#039;&amp;#039; : { B := A }) {ALL BUT A} ==&amp;gt; (&amp;#039;&amp;#039;re&amp;#039;&amp;#039; RENAME A AS B) &lt;br /&gt;
&lt;br /&gt;
* For no-op projections (i.e. is projecting all attributes), all updates are supported.&lt;br /&gt;
: Rewrite &amp;#039;&amp;#039;updop&amp;#039;&amp;#039; (&amp;#039;&amp;#039;re&amp;#039;&amp;#039;{ ... }) ...; ==&amp;gt; &amp;#039;&amp;#039;updop&amp;#039;&amp;#039; &amp;#039;&amp;#039;re&amp;#039;&amp;#039; ...;&lt;br /&gt;
&lt;br /&gt;
G)	DELETE through projection&lt;br /&gt;
	Supported (whether or not the projection is key-preserving.)&lt;br /&gt;
	DELETE (R{ ... }) WHERE p; ==&amp;gt; DELETE R WHERE p;&lt;br /&gt;
	DELETE (R{ ... }) v; ==&amp;gt; DELETE R (R MATCHING v);&lt;br /&gt;
	We must DELETE exactly those base tuples to achieve the DELETE of the proj.&lt;br /&gt;
	We can&amp;#039;t DELETE too many, by those rewrites.&lt;br /&gt;
&lt;br /&gt;
H)	INSERT through projection&lt;br /&gt;
	Not valid. (No surprise.) Therefore&lt;br /&gt;
&lt;br /&gt;
I)	assign (:=) through projection&lt;br /&gt;
	Not valid.&lt;br /&gt;
&lt;br /&gt;
J)	UPDATE through projection&lt;br /&gt;
	Valid providing the projection is key-preserving (i.e. at least one key).&lt;br /&gt;
	UPDATE (R{ ... }) WHERE p : assigns; ==&amp;gt; UPDATE R WHERE p : assigns;&lt;br /&gt;
	Note: the assigns could be changing the key.&lt;br /&gt;
&lt;br /&gt;
	Valid even if the projection is not key-preserving,&lt;br /&gt;
	providing the assigns are not changing attribs in the based-on&amp;#039;s key&lt;br /&gt;
	(for at least one key).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[For ref: Dave&amp;#039;s suggested &amp;#039;template&amp;#039; for spcifying rewrites]&lt;br /&gt;
&lt;br /&gt;
2. Update through JOIN&lt;br /&gt;
&lt;br /&gt;
Given r1 JOIN r2 where r1 and r2 are arbitrary relations.&lt;br /&gt;
&lt;br /&gt;
a. Rewrite &lt;br /&gt;
	UPDATE r1 JOIN r2: {p := q} &lt;br /&gt;
as &lt;br /&gt;
	UPDATE ….&lt;br /&gt;
&lt;br /&gt;
b. Rewrite&lt;br /&gt;
	INSERT (r1 JOIN r2) v&lt;br /&gt;
as&lt;br /&gt;
	INSERT ….&lt;br /&gt;
&lt;br /&gt;
c. Rewrite&lt;br /&gt;
	DELETE r1 JOIN r2 WHERE p&lt;br /&gt;
as&lt;br /&gt;
	DELETE ...&lt;br /&gt;
&lt;br /&gt;
d. Rewrite&lt;br /&gt;
	(r1 JOIN r2) := v&lt;br /&gt;
as&lt;br /&gt;
	...&lt;br /&gt;
&lt;br /&gt;
Or: Not supported.&lt;/div&gt;</summary>
		<author><name>AntC</name></author>	</entry>

	<entry>
		<id>http://d2.reldb.org/index.php/Update_through_views_possible_approach</id>
		<title>Update through views possible approach</title>
		<link rel="alternate" type="text/html" href="http://d2.reldb.org/index.php/Update_through_views_possible_approach"/>
				<updated>2017-02-06T09:02:05Z</updated>
		
		<summary type="html">&lt;p&gt;AntC: /* Musings: a possible comparison */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(In draft as at early February 2017.)&lt;br /&gt;
&lt;br /&gt;
It is assumed the reader is familiar with the topic of update through views. &amp;#039;View&amp;#039; is the term usual in database discussions, as for example in SQL. The ttm term is &amp;#039;Virtual relvar&amp;#039;. Updating through views is discussed, for example, in both DTATRM and DBE. Most textbooks on the Relational Model or SQL discuss views and at least mention updating through views.&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
&lt;br /&gt;
Update through views is a regular discussion topic on the ttm forum. And a regular topic for Chris Date, co-author of The Third Manifesto. He has published many treatments, since particularly a series of articles (with David McGoveran) 1994 [see [[#References]] below for publication details]. Arising from that 1994 treatment also was the Principle Of Orthogonal Design, aimed at making update through views more tractable. McGoveran continues to publish on the topic (nowadays separately to Date), emphasises Orthogonal Design as key to updating databases -- albeit a different interpretation from Date. The topic has also been much discussed on older forums, such as comp.database.theory.&lt;br /&gt;
&lt;br /&gt;
There is a wide range of opinions on the desirability, possibility and practicability of update through views:&lt;br /&gt;
&lt;br /&gt;
* Those who assert update is possible through all views, and the mechanisms merely need refining.&lt;br /&gt;
* Those who prescribe update should be possible through all views &amp;quot;that are theoretically updatable&amp;quot;.&lt;br /&gt;
** (The quote is from Codd&amp;#039;s 12 rules (1985), rule 6. The narrative for that rule includes a definition of &amp;#039;theoretically updatable&amp;#039;.)&lt;br /&gt;
* Those who think some but not all views are updatable through, (which is not inconsistent with Codd 1985) and there is merit in a relational dbms being able to support that ability.&lt;br /&gt;
** Note that the SQL standard stipulates some capabilities, which have been somewhat implemented by vendors.&lt;br /&gt;
* Those who think that although some views might support being updated through, that is certainly not all of the views encountered in practice, so the uncertainty and continuing debate do not justify implementing a feature that can at best be only partial.&lt;br /&gt;
* Those who are adamant that (even if some views are updatable-through unproblematically), it is an unnecessary feature, and adds complexity both to the dbms and to developers/schema designers wanting to update the database. &lt;br /&gt;
** (It is true that update to base relvars is always sufficient, and necessarily so: the objective for update through views is to translate updates requested against views into updates against base.)&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;possible approach&amp;quot; propounded in this article is squarely aimed at getting some progress in the middle of this range. Specifically:&lt;br /&gt;
* The debate has tended to be polarised, with the most prominent advocates (Date particularly) at the &amp;quot;all views can be updated through&amp;quot; position.&lt;br /&gt;
* Date&amp;#039;s continuing inability to &amp;#039;solve&amp;#039; the problem (even to his own satisfaction) have lead to many being sceptical.&lt;br /&gt;
* The only major attempt at a partial implementation is SQL. It is beset with limitations and hard-to-explain behaviour. (And subtle differences between different vendors&amp;#039; implementations.) Such that most developers avoid the &amp;#039;feature&amp;#039;, and advise others to do the same. (See, for example, regular questions on StackOverflow.)&lt;br /&gt;
* Consequently there appears to be little thinking that acknowledges some views can be updated through, some not, and seeks to arrive at a precise characterisation of which and why. (And how, for those updates that can be supported.)&lt;br /&gt;
&lt;br /&gt;
== Considerations for an approach ==&lt;br /&gt;
&lt;br /&gt;
[email from the forum]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt; On Jan 21, 2017, at 2:53 AM, Anthony Clayden &amp;lt;anthony.d.clayden@gmail.com&amp;gt; wrote:&lt;br /&gt;
 &lt;br /&gt;
The whole topic has suffered from too much ad-hockery.&lt;br /&gt;
I have a small and perfectly-formed set of rules in mind.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;So my general position:&lt;br /&gt;
*	Some views are updatable-through; some aren&amp;#039;t.&lt;br /&gt;
*	Some views are INSERTable-through but not DELETEable-through, and &amp;#039;&amp;#039;v.v.&amp;#039;&amp;#039;.&lt;br /&gt;
*	rather than putting effort into developing byzantine rules to make more views updatable;&lt;br /&gt;
*	the effort should go into agreeing a small set of rules [**] that&amp;lt;br/&amp;gt;&lt;br /&gt;
: a) are clear what&amp;#039;s updatable, what isn&amp;#039;t;&lt;br /&gt;
: b) have clear effects for views that are updatable;&lt;br /&gt;
: c) can give clear explanations (compilation error messages) for those that are not.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Note [**] the &amp;quot;rules&amp;quot; were in later discussions re-titled as &amp;quot;prescriptions&amp;quot;. The following has been editted accordingly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;I have four-and-a-bit prescriptions. Of which the bit is merely to say that if the four prescriptions don&amp;#039;t give a clear answer how to update, then the view is not updatable-through (for that action) -- i.e. c) above.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The prescriptions ==&lt;br /&gt;
&lt;br /&gt;
The first two prescriptions are standard on this topic [Dayal &amp;amp; Bernstein 1978]&amp;#039;s &amp;#039;&amp;#039;preserves semantic consistency&amp;#039;&amp;#039; and &amp;#039;&amp;#039;no side effects&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The third prescription is really to make view updating tractable and predictable/manageable for the dbms and application developers. The same motivation as for ttm&amp;#039;s OO Prescription 1 (compile time type checking).&lt;br /&gt;
&lt;br /&gt;
It is the fourth I&amp;#039;ve long had trouble with -- hence this prologue. When I say &amp;quot;fourth&amp;quot;, this has been up to 4 or 5 separate rules in my previous versions. I think I&amp;#039;ve now found a formulation to condense [D&amp;amp;B 1978]&amp;#039;s &amp;#039;&amp;#039;unique&amp;#039;&amp;#039;, &amp;#039;&amp;#039;no extraneous updates&amp;#039;&amp;#039;, my own &amp;#039;&amp;#039;unambiguous&amp;#039;&amp;#039;; and to find grounds to reject [D&amp;amp;B 1978]&amp;#039;s &amp;quot;uncomfortable dimension&amp;quot; with which I&amp;#039;ve never been, er, comfortable. The notion -- that both tuples for the update and their attributes be &amp;#039;&amp;#039;essential&amp;#039;&amp;#039; -- is cribbed from D,D&amp;amp;F&amp;#039;s ETNF paper. [Darwen, Date, Fagin 2012, ETNF = Essential Tuple Normal Form]&lt;br /&gt;
&lt;br /&gt;
There are footnotes for each prescription, but let&amp;#039;s state them succinctly first:&lt;br /&gt;
&lt;br /&gt;
# At all times all constraints must hold. (rubric: The &amp;quot;Golden Rule&amp;quot;.)&lt;br /&gt;
# Any update through a view must have precisely the effect on the content of the view as if it were a base relation. (rubric: &amp;quot;Assignment Principle&amp;quot;)&lt;br /&gt;
# That a view is updatable-through (for some action INSERT, DELETE, UPDATE, assignment :=) must be determined by reference only to the schema, view&amp;#039;s definition, constraints and the specified update effect for that action, per prescription 2. (rubric: &amp;quot;Not dependent on the happenstance of content&amp;quot;)&lt;br /&gt;
# Noting that the update is to be effected by some combination of tuples deleted and inserted into the database (base relations): each such tuple must be necessary to achieving 1. and 2., the set of tuples (deletes and inserts) must be sufficient, and each attribute value must be similarly necessary. (rubric: &amp;#039;&amp;#039;essential&amp;#039;&amp;#039; tuples, &amp;#039;&amp;#039;essential&amp;#039;&amp;#039; attribute values.)&lt;br /&gt;
# If there is no set of necessary, sufficient tuples/attributes per 4., that view is not updatable-through for that action.&lt;br /&gt;
&lt;br /&gt;
=== Footnotes to the prescriptions ===&lt;br /&gt;
&lt;br /&gt;
# Knowing all constraints must hold, the compiler can:&lt;br /&gt;
#: a) rely on them all holding before it plans the update steps;&lt;br /&gt;
#: b) examine them (in the catalogue or otherwise) to guide the update.&lt;br /&gt;
# I&amp;#039;m not expecting the update actions to be necessarily limited to the traditional INSERT/DELETE/UPDATE/assignment(:=).&lt;br /&gt;
#: Opportunity for new forms of update. (I&amp;#039;ve toyed with a few on the forum.)&amp;lt;br/&amp;gt;&lt;br /&gt;
# The consequence is that the algorithm for update be derivable at compile time.&lt;br /&gt;
#: (So could be implemented as a stored procedure.)&lt;br /&gt;
#: Suggested alternative formulation: “Whether a given view can be updated-through or not must be determined solely from the declared database constraints, the given view&amp;#039;s definition, and the requested update to be performed to the view (and thus update through it).”&lt;br /&gt;
# &amp;#039;&amp;#039;Essential&amp;#039;&amp;#039; tuple means that it is &amp;#039;&amp;#039;necessary&amp;#039;&amp;#039; for those tuples to be deleted/inserted to comply with 1., 2 for all valid states of the database.&lt;br /&gt;
#: &amp;#039;&amp;#039;Essential&amp;#039;&amp;#039; attribute value means that value is the only possible to comply with 1., 2 for all valid states of the database.&lt;br /&gt;
#: &amp;#039;&amp;#039;Sufficient&amp;#039;&amp;#039; requires that if there are two (or more) different sets of tuple actions/values that comply:&lt;br /&gt;
#* and one is a superset of another (deletes and inserts taken separately), then the tuples in the difference are not &amp;#039;&amp;#039;necessary&amp;#039;&amp;#039; (not &amp;#039;&amp;#039;essential&amp;#039;&amp;#039;).&lt;br /&gt;
#* or the sets only partially overlap (and their intersection is not sufficient), then the tuples unique to each set are not &amp;#039;&amp;#039;necessary&amp;#039;&amp;#039; (not &amp;#039;&amp;#039;essential&amp;#039;&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The ETNF paper&amp;#039;s use of &amp;#039;&amp;#039;essential&amp;#039;&amp;#039; tuple is (loosley speaking) that without that tuple some constraint would be violated, and we couldn&amp;#039;t &amp;#039;recreate&amp;#039; that tuple from other content to satisfy the constraint. I&amp;#039;m extending that idea: without that tuple (inserted or deleted) in the base some constraint would be violated and/or the update would not have precisely the effect requested for the view.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
* Codd&amp;#039;s 12 rules -- Rule 6 and definition, see also discussion under Rule 9.&lt;br /&gt;
: (The bare rules just prescribe.)&lt;br /&gt;
: http://computing.derby.ac.uk/c/codds-twelve-rules/&lt;br /&gt;
* Dayal and Bernstein 1978 &amp;quot;On the Updatability of Relational Views”&lt;br /&gt;
: https://pdfs.semanticscholar.org/39f4/853a35a913c714c5f3956dbefd02916447c4.pdf&lt;br /&gt;
: references a 1975 paper Chamberlin, Gray, Traiger&lt;br /&gt;
: https://www.computer.org/csdl/proceedings/afips/1975/5083/00/50830425.pdf&lt;br /&gt;
* Bancilhon and Spyratos 1981 &amp;quot;Update Semantics of Relational VIews&amp;quot;&lt;br /&gt;
: http://pages.cs.wisc.edu/~jhuang/qual/update-semantics-of-views.pdf&lt;br /&gt;
* Darwen, Date, Fagin 2012 &amp;quot;A Normal Form for Preventing Redundant Tuples in Relational Databases&amp;quot;&lt;br /&gt;
: http://researcher.watson.ibm.com/researcher/files/us-fagin/icdt12.pdf&lt;br /&gt;
* An example SQL implementation (SQL-Server) reference manual&lt;br /&gt;
: https://msdn.microsoft.com/en-us/library/ms187956.aspx#Anchor_3&lt;br /&gt;
* For another round of the continuing debate&lt;br /&gt;
: http://www.dbdebunk.com/2016/12/on-view-updating-c-j-date-and-d.html&lt;br /&gt;
: note this is Fabian Pascal reporting a Date/McGoveran posting from 2004, it&amp;#039;s unlikely either author would hold the same views today.&lt;br /&gt;
* Links to the Date &amp;amp; McGovern 1994 series of articles (need to dig them out via the wayback machine)&lt;br /&gt;
: http://www.dbdebunk.citymax.com/page/page/622302.htm -- Part 1 links through to the other parts, in a haphazard fashion&lt;br /&gt;
&amp;lt;blockquote&amp;gt;I am not alone in thinking that the treatment of view updating within the overall theory of relational databases has always been rather unsatisfactory for one reason or another. As Nat Goodman puts it:  &amp;quot;... there is no theory behind any of this.  Each [rule] seems intuitively correct, but there is no overall framework.  It would be better to have a general rule that states what a correct view update algorithm has to do, and then derive the special rules for each case from that general rule.  Without this, the [rules] feel like a crazy patchwork of exceptions and special notes.  In some cases, two or more [rules] are equally sensible ...&amp;quot; (and so on).&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
: http://www.dbdebunk.com/page/page/622150.htm  -- Part 6 is the concluding summary&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;#039;&amp;#039;&amp;#039;Comments On Republication:&amp;#039;&amp;#039;&amp;#039; [on dbdebunk] Originally published in Database Programming &amp;amp; Design 7, No. 6 (June 1994) and published as a two-part article in RELATIONAL DATABASE WRITINGS1991-94. It is republished here by permission of David McGoveran, Miller Freeman Inc. and Pearson Education, Inc. © All rights reserved by C.J. Date. Research has shown that certain detail level corrections might be needed, which we may undertake in the future. However, we still believe strongly that the overall approach is sound.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Musings: a possible comparison ==&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
On 3/02/2017, at 9:06 PM, Dave Voorhis &amp;lt;dave@armchair.mb.ca&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
The essence of the debate is perhaps something like this:&lt;br /&gt;
&lt;br /&gt;
The update-through-views proponent sees this...&lt;br /&gt;
&lt;br /&gt;
: VAR v VIEW ...&lt;br /&gt;
&lt;br /&gt;
…and feels it is perfectly reasonable to allow &lt;br /&gt;
&lt;br /&gt;
: UPDATE v WHERE Name = ‘Dave Vorhis’: {Name := ‘Dave Voorhis’}.&lt;br /&gt;
&lt;br /&gt;
The update-through-views opponent sees the above, and feels it is akin to...&lt;br /&gt;
&lt;br /&gt;
: #define e  (int)((p / n + sqrt(r) * 0.156) * pow(q, 3))&lt;br /&gt;
&lt;br /&gt;
…and expecting an assignment like e := 2 to meaningfully update p, n, r and q.&lt;br /&gt;
&lt;br /&gt;
The update-through-views proponent sees the above and says no, it’s really akin to…&lt;br /&gt;
&lt;br /&gt;
: a[e] := 2;&lt;br /&gt;
&lt;br /&gt;
…which is fine, isn’t it?&lt;br /&gt;
&lt;br /&gt;
The update-through-views opponent disagrees that it’s akin to updating an array.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Speaking as an update-through-views-sometimes proponent:)&lt;br /&gt;
&lt;br /&gt;
I&amp;#039;ve never been happy likening update-through-view to update-to-array. Because there&amp;#039;s only one way to update an array, and if two different expressions are targetting the same cell, that&amp;#039;s referentially transparent. It&amp;#039;s a little more like being able to target a slice/slab/sub-cube of an array (which some languages support), in that you&amp;#039;re updating multiple cells with one statement. (For comparison, there&amp;#039;s a quote alleged from Dijkstra that all array updates should be seen as assigning to the whole structure, even if they&amp;#039;re targetting a single cell. Similarly for targetting components of data structures in general.) But I&amp;#039;m still not happy with the analogy.&lt;br /&gt;
&lt;br /&gt;
An array you can&amp;#039;t change the size/shape merely by assigning a new value; you can&amp;#039;t at run time insert/delete cells (indexes) in the middle; you can&amp;#039;t add an extra dimension. (Changing shape would be something like renumbering the indexes in an array with rationals between the integers, and leaving &amp;#039;gaps&amp;#039;.)&lt;br /&gt;
&lt;br /&gt;
Contrast that with updating relations -- even just base ones -- there are expressions that target the same tuple, but in non-obvious ways:&lt;br /&gt;
&lt;br /&gt;
* S WHERE S# = &amp;#039;S1&amp;#039;;&lt;br /&gt;
* S WHERE SNAME = &amp;#039;Smith&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
You can update that base, and those same expressions no longer target the same tuple:&lt;br /&gt;
&lt;br /&gt;
* UPDATE S WHERE SNAME = &amp;#039;Smith&amp;#039; : {SNAME := &amp;#039;Smythe&amp;#039;};&lt;br /&gt;
* INSERT S REL{TUP{S# &amp;#039;S17&amp;#039;, SNAME &amp;#039;Smith&amp;#039;, ...}};&lt;br /&gt;
&lt;br /&gt;
(Indeed the idea of &amp;quot;the same tuple&amp;quot; is a nonsense, unlike an array cell. I mean: no longer return the same result as each other.)&lt;br /&gt;
&lt;br /&gt;
You can update a relation to change it&amp;#039;s size/shape, such that expressions that used to target a single tuple now target multiple tuples, or no tuples at all.&lt;br /&gt;
&lt;br /&gt;
Note all this applies just with update to base relations.&lt;br /&gt;
&lt;br /&gt;
If we&amp;#039;re looking for a conventional data structure &amp;quot;akin to&amp;quot; relations, could I suggest a doubly-linked list:&lt;br /&gt;
&lt;br /&gt;
* There are expressions that target the same cell, but in non-obvious ways&lt;br /&gt;
:: left(left(left(L))) === right(right(right(right(L))))&lt;br /&gt;
* You can at run time insert/delete cells, which changes the list&amp;#039;s size/shape, and&lt;br /&gt;
* thereby those expressions no longer target the same cell.&lt;br /&gt;
* You can &amp;#039;target&amp;#039; cells by content: form a list by filtering.&lt;br /&gt;
&lt;br /&gt;
* For extra fun, consider that each cell could itself be a doubly-linked list.&lt;br /&gt;
&lt;br /&gt;
So what would be the doubly-linked equivalent of update-through-views vs to-base? Perhaps targetting through the left vs through the right. Both are feasible; and for every leftwards update there&amp;#039;s an equivalent rightwards update. But each time you insert/delete cells you have to recalibrate those equivalences.&lt;br /&gt;
&lt;br /&gt;
You could also target by content an update to doubly-linked list: insert before the leftmost cell value &amp;#039;XYZ&amp;#039;; delete 3 cells to the right of the rightmost cell value &amp;#039;ABC&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
The rewrites for updates given in this approach take it that a target for update can be any relational expression, with a view name (virtual relvar) merely standing for its defining expression in a target context.&lt;br /&gt;
&lt;br /&gt;
== [[Update through views: rewrites]] ==&lt;br /&gt;
&lt;br /&gt;
Click on the section heading to go to the page with rewrites.&lt;/div&gt;</summary>
		<author><name>AntC</name></author>	</entry>

	</feed>