[comp.databases] How do you union two databases in INGRES?

lee@ssc-vax.UUCP (Lee Carver) (07/21/88)

In the course of designing a new application, we came upon the need
to form a union of two base relations.  We have been unable to find
a way to do this in QUEL.

---- A little background. ----

We have a database of requirements, where requirements are traced
back to their paragraphs.  At the time, there was no need to record
paragraph numbers that do NOT contain a requirement.  Guess what!
We know have to record every paragraph, whether it contains a
requirement or not.

So, a new base relation was created to hold the paragraph number for
those paragraphs that do not contain a requirement.  It contains a
subset of the fields in the requirement base relation, those that
'identify' the paragraph.

Paragraphs, and requirements both belong to specific documents.  So
the basic database schema is:

	doc ( doc-id )
	req ( doc-id, para-id, req-id )
	para ( doc-id, para-id )

Note that some of these base relations are actually quite a bit
larger then shown here.  The space savings of the para relation over
a "blank" req record is substantial, as well as being more sound.

Yes, the database is not in Nth normal form.  So what.:-)  Its not my
fault and they won't let me change it if I wanted to.;-)

---- What we want to do. ----

What we'd like to do is to take the two databases, and reconstitue
the list of all paragraph numbers.  From my understanding of
relational database algebra, this should be a union.  Clearly you
would need to add dummy columns to the paragraph relation, and maybe
project the requirements relation so they are the same size, and
maybe require uniqueness of paragraph numbers, etc.

But the point is that we have two disjoint sets, and what to form
the union.

We've looked at:

	define view ( para_num )
		where req.doc = doc or para.node = node

But nobody thinks it will work.  Will it?  Is there a way to do the
job?