0

I want to migrate my legacy shop system from a relational system to a document based. The reason is obivious: I want to reduce the complexity of relations which describes a shop article, that can have multiple different properties.

So I read the documentation of Doctrine PHPCR and found out, that there are several examples of how to build a model with references, because the main concepts of PHPCR are

  • Hierarchy mapping
  • References

as described here: Assocation Mapping

But the documentation uses both concepts for the same goal:

References: Article with author and comments as references

Example: Working with Objects

The article is queried by its ID/path: /article/hello-world, the comments and the author are references.

/**
 * @ReferenceOne
 */
private $author;

/**
 * @Referrers(referrerDocument="Comment", referencedBy="article")
 */
private $comments;

Hiearchical: Blog user as child document

Example: The QueryBuilder

It queries the blog user (propably author) by path

$qb->from('Blog\User', 'u');

// where name is "daniel"
$qb->where()
  ->eq()->field('u.name')->literal('daniel');

Therefore, my main question is, what could be the reason for that, or to be more specific, what are the best practices to build up a model with dynamic properties like a shop article?

/article/id:properties[A|B|C]

or

/article/id/propertyA
/article/id/propertyB
/article/id/propertyC

It would be really helpful If someone shares its experience.

Mike Reiche
  • 382
  • 3
  • 12
  • I've realized that Blog\User is no path but a document name, but that doesn't change the essence of the question (imho). – Mike Reiche Apr 18 '17 at 22:33

1 Answers1

0

I found an answer by myself:

  • Use hierarchical references when you want to move documents and rearrange the structure
  • Use references to describe/extend the document

For shop articles, its better to use references for properties like name, price, tax ea. and children if you want to have sub articles like bundles.

Mike Reiche
  • 382
  • 3
  • 12