[comp.databases] Union and Views

aaron@grad2.cis.upenn.edu (Aaron Watters) (08/01/90)

I recently volunteered some consulting for a friend
about a difficult database problem.  The solution we came
up with was unduely complex because of the following
weird restriction:

In Informix, for example, Unions are not allowed in the
definitions of Views.  Why is this?

Do other systems have this restriction?

How can system implementers look themselves in the mirror when
they impose such arbitrary restrictions on their customers?

Please respond directly to me, as I tend to lose track of
this hyperactive newsgroup.	-aaron

<< It's amazing how sophisticated triviality has become.>> -Lakatos.

cortesi@infmx.UUCP (David Cortesi) (08/02/90)

In article <27663@netnews.upenn.edu> aaron@grad2.cis.upenn.edu.UUCP (Aaron Watters) writes:
>
>In Informix, for example, Unions are not allowed in the
>definitions of Views.  Why is this?
>
>Do other systems have this restriction?

Indeed they do.  First, from An Introduction To Database Systems
by Date (4th ed.1987), Section 8.2 "View Definition,"

	In principle, any derivable table -- i.e. any table that can
	be retrieved via a SELECT statement -- can theoretically be
	defined as a view.  In practice ... DB2 does not allow a
	view definition to include the UNION operator; however there
	is no intrinsic reason for that restriction, it is merely
	a quirk of DB2 per se...

Later, Date wrote The SQL Standard (2nd ed., 1989) in which he cites
the ANSI syntax for a view (page 88):

	CREATE VIEW view [ ( column-commalist) ]
	   AS query-specification
	       [WITH CHECK OPTION]

and then on page 95 he explicates the meaning of that nonterminal,
the "query-specification":

		query-expression
		  ::=   query-term
		      | query-expression UNION [ALL] query-term
		query-term
		  ::= query-specification | ( query-expression)

	The construct "query expression" appears only within a
	cursor definition (note, therefore, that UNION -- with or
	without ALL -- is not allowed in ... a view definition).

So it would appear that the "quirk" of DB2 has been enshrined in
the ANSI standard.  Hope you find this informative.

setas01@cai.com (08/17/90)

Subject: Union and Views

Aaron Watters (aaron@grad2.cis.upenn.edu) from University of Pennsylvania
writes :

> I recently volunteered some consulting for a friend
> about a difficult database problem.  The solution we came
> up with was unduely complex because of the following
> weird restriction:

> In Informix, for example, Unions are not allowed in the
> definitions of Views.  Why is this?

What reason did Informix give for not supporting this feature ?

> Do other systems have this restriction?

It would be interesting to know if others also have this restriction.
CA-DB ( a relational database software on VAX/VMS and UNIX ) does not 
have this restriction. 

> How can system implementers look themselves in the mirror when
> they impose such arbitrary restrictions on their customers?

Let us see what the implementors have to say on this.


Ashok Sethi