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
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.
I found an answer by myself:
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.