Some relational databases contain objects that link back to themselves. For example, a database where the objects represents Web pages is likely to include such a construct because many Web pages include links from one part of the page to another part of the same page. It’s important to understand how QGraph handles self links (loops) when matching queries against the database structure.
Consider the database fragment shown in Figure 2.11.
This fragment contains a directed link that connects the
directory-page object to itself, a common
phenomenon in
long Web pages. QGraph treats this link and object the
same as any other in the database, including matching them to
more than one query element when appropriate.
To see how this works, let’s see what happens when we execute the query shown in Figure 2.12 on the database fragment shown above.
The results of executing this query on the database fragment are shown in Figure 2.13.
The loop connecting the directory-page
object to itself is treated the same as any other link.
Like all other links, it can match more than one query edge and
thus appear in more than one place in a subgraph. Again, query
constructs such as conditions and constraints can be used to restrict
which database elements a query edge or vertex may match and to avoid
such duplications in query results when desired.