question about OPTIONAL and UNION key words

Hi,

I recently read the specification. It is very helpful. However I got
confused by the difference between OPTIONAL and UNION key words. In
all queries using OPTIONAL, we can use UNION to write a query that
generates the same results. and vice versa.

for example:

select ?x ?mbox
where{
?x foaf:name ?name .
optional {?x foaf:mbox ?mbox} .
optional {?x foaf:homepage ?hpage}
}

will generate the same result as

select ?x ?mbox
where{
{?x foaf:name ?name } .
UNION
{?x foaf:mbox ?mbox} .
UNION
{?x foaf:homepage ?hpage}
}

So why the specification includes both OPTIONAL and UNION?

-- 
Thanks,
Mo

Received on Thursday, 28 May 2009 06:44:10 UTC