Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:07:41+00:00 2026-06-04T03:07:41+00:00

I am having a debate at work about aggregate roots and using the navigational

  • 0

I am having a debate at work about aggregate roots and using the navigational properties to traverse through child objects.

Scenario 1:

  • Customer is the aggregate root
  • Address is an entity
  • Contact is an entity

A customer can have multiple addresses and an address can have multiple contacts. I query the customer repository below using the customer Id and return a customer object.

Dim customer as Customer = _customerRepository.GetById(request.Id)

If we need to acess the customers address we then traverse through the address within the customer object like below.

Dim address as Address = customer.RetrieveAddress(request.AddressId)

This approach would then be carried on for x number of child objects. The example I have shown is a simple one but in terms of DB tables containing millions of records how have other people managed with performance issues when traversing through several child objects once the aggregate root object has been queired and returned?

Scenario 2:

Same example above but instead of querying the customer repository and returning a customer object, we return a child object instead.

Dim address as Address = _customerRepository.GetAddressById(request.AddressId)

Now because we have queried the address object it means I don’t have to traverse through the customer object to get to it. Even though I have used the customer repository to query the address table directly and return the address object is this allowed when following DDD? Or should I be using scenario 1 where I query the customer repository and return the customer object which is the aggregate root and traverse through the child objects?

The reason I ask is because in our DB diagram we have several tables to traverse through from our aggregate root and potentially it can contain millions of records over time which will reduce performance.

Just wondering how other people have manage to apply DDD thoroughly without reducing performance because when using EF with the navigational properties as soon as you use them it then sends a query for each child object which potentially sends 100+ queries if it is in a for loop.

Mike

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:07:43+00:00Added an answer on June 4, 2026 at 3:07 am

    Aggregates are a tricky business and deciding on aggregate boundaries requires a lot of thinking. Reading your question I’m not quite sure you’re designing your aggregates based on behaviour rather than DB entity relationships. As Eben says, you won’t get very far with the latter approach, and your aggregates will probably end up being quite large (in terms of number of child entities).

    One of the most insightful things I’ve read on the topic is Effective Aggregate Design by Vaughn Vernon. I’d definitely recommend giving it a read. One important thing he talks about is trying to make your aggregates as small as possible. This will naturally help with performance.

    For child entities I would not do what you’ve done in scenario 2, because you should not be able to mutate the state of an entity without doing so via the aggregate root; this maintains the invariants. Having said that, your example uses an address object which is likely to be a value object, so having a separate address store for performance reasons would be fine.

    When starting with DDD, I think its important to be reminded that you still need to be pragmatic with your design choices; DDD doesn’t solve all your problems for you. In most cases the design choices are a trade-off for things like performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My teacher and I are having a debate about whether it is possible to
I'm having a little debate with a friend about Objective-C being a 3GL but
So I was having a debate with a fellow engineer about looping in JavaScript.
Several co-workers and I are having a debate about what happens when a local
I'm having a debate with a co-worker about throwing exceptions from constructors, and thought
I'm having a debate with some developers on another forum about accurately generating MIDI
I'm having an internal debate about where I should handle checking for changes to
I'm having this argument about using Cursors in TSQL recently... First of all, I'm
I'm having a debate with another programmer I work with. For a database return
Been having a heated debate with a colleague about his practice of wrapping most

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.