When developing Domain-Driven Design, your objects will usually not have much to do with the database structure.
You will quickly go to the point where you still need to map between the objects in the ORM table and the aggregates of your domain.
Forcing database-based aspects into your domain model is contrary to DDD.
So yes, I would recommend matching ORM object tables (which are pure data anyway) in your aggregates. The repository template is played here. It will provide domain objects, transforming the underlying data.
If metadata, such as the creation / modification date and the user, are not an integral part of the business domain (i.e. registration requirements within the entire system), this user and date / time can be entered when converting back to table objects for saving .
A layered architecture might look like this:
---------------------------- | Domain | (Aggregates) ---------------------------- ---------------------------- | Repositories | (transforms table-objects into Aggregates) ---------------------------- ---------------------------- | OR-Mapper | (loads records from DB into table-objects) ---------------------------- ---------------------------- | Database | (this is where the data lives) ----------------------------
source share