Skip to content

Cartesian product? more Optionals/Unions?  #6

@VladimirAlexiev

Description

@VladimirAlexiev

Hi! Interesting work but I have some doubts. Assume this query (where appearance is a string, for simplicity)

hero {
  name
  appearance
}
  • doesn't this suffer badly from Cartesian product syndrome? If a hero has 3 name and 5 appearance, won't this return 15 rows?
  • shouldn't it use more Optionals or Unions? If a hero got no appearances, I still want to get his name

I think both of these woes can be remedied by using Union, eg

{?hero ex:name ?name}
union
{?hero ex:appearance ?name}

You could retrospect field characteristics in the schema to optimize the query.

  • if a field is required ! you don't need to wrap it in optional/union
  • if a field is not array [...] you don't need to use union

So the above sparql is the worst case (both fields are optional arrays).
Your README shows the best case (both are required singleton).

If name is required singleton but appearance is optional singleton, the query could be

{?hero ex:name ?name}
optional {?hero ex:appearance ?name}

Complex questions:

  • How to group patterns with the same/different characteristics
  • How to trace characteristics down the object hierarchy: maybe you need some subquery nesting?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions