So I've the following Domain:
So far, I've end up with the following model:
Application
entity, which is defined by a name, an os and a typeVersion
value object, which basically wraps version informations (major, minor, etc.)Release
entity, which is a composed object referencing an Application entity and embedding a Version value objectDevice
entity, which is identified by a serial numberNotitificationSubscription
entity (to allow me to Query by attribute)Now I'm wondering how to "associate" Device
entity, Release
and the NotificationSubscription
because it should be associated to an "installed" Release
on a Device
and include some extra information (like an authentication token).
Given the limitation of my ORM (Doctrine2) & RDMS (MySQL) I'm stuck at how to find a good design.
Imagine the following workflow:
Device
entity from Database identified by its Serial NumberRelease
the Device
is running from is already associated with it, if no, I create an associationNotificationSubscription
for the current Device Release associationMy problem is I end up with much indirection.
To allow me to set extra data to the association, I created an Association Class which is itself an Entity referencing both a Device and a Release.
A device may have different Release installed and running on it, so for example, I don't know how to query the following information: "Fetches all the notification subscriptions for the current release for the current device"
I obviously added a method in a Repository findSubscriptionsByDeviceAndRelease($device, $release);
which means that I can query this information by both using the repository and through the graph $device->getInstalledReleases()->filter($identifiedRelease)->getNotificationSubscriptions();
Any ideas?
Keep it simple: you don't need a domain model here, you just need a good entity-relationship model. You probably don't need Doctrine either, since sql queries should be simple enough.