Consider an application being implemented following Domain Driven Design.
In the same aggregation, there are Car
and Computer
entities that should have a one to many
relationship between them (Car
has one Computer
and Computer
can be embedded in many of Car
). They are in the same aggregation because Computer
only exists within Car
, so the Car
is the aggregation root. Below, some simplified pseudo code.
The application uses for persistence an orm that requires such entities to have explicit relationship configuration between them using references and back references such as Computer computer
and Car[] cars
.
Does the usage of these references between the classes on the same aggregation root hurt the aggregate pattern principle from domain driven design? In time, the only reason why Computer
have an identifier, is because these entities will be persisted in different tables on the database.
class Car
uuid id
string name
string color
# Here is the reference
uuid computer_id
Computer computer
class Computer
uuid id
string processor
int memory
int storage
# Here is the back reference
Car[] cars