title: DDD - reference to entities outside the aggregate
body: <p>It's my first try at DDD and I would like to get advise on modeling issues.</p>
  
  <p>Here is my domain: The management of multiple schools.</p>
  
  <ul>
  <li>A <em>school</em> has multiple <em>students</em>, <em>teachers</em>, …</li>
  <li>For a school, there is (every year) a new <em>schoolYear</em> (which has a value object holding <code>2017-2018</code> for instance)</li>
  <li><em>Classes</em>, <em>student scores</em> are related to a schoolYear (for instance, Student A can be in class C1 in school year 2017-2018 and in classe C2 next year 2018-2019)</li>
  </ul>
  
  <p>My first doubt is in the modeling of <em>schoolYear</em>.</p>
  
  <p>I already have the <em>school</em> entity as a root aggregate. My first approach was to make the <em>school</em> aggregate handle the addition of <em>schoolYear</em> (so that I can avoid duplicates, or that I can create the next <em>schoolYear</em>, …) </p>
  
  <p>=> <em>schoolYear</em> is part of the <em>school</em> aggregate</p>
  
  <p>But then I had to model <em>classes</em> and <em>student scores</em>… which depend on the <em>schoolYear</em>. </p>
  
  <p>So in my <em>classes</em> aggregate, I have to hold a reference to a <em>schoolYear</em>… which breaks the rule that states</p>
  
  <blockquote>
    <p>"Cannot hold a reference to an internal entity from an outside aggregate."</p>
  </blockquote>
  
  <p>In my domain, a lot of entities are depending on a specific <em>schoolYear</em>. Maybe it should be an aggregate…</p>
  
  <p>On the other hand, the <em>schoolYear</em> of a given <em>class</em> is used for searching classes.</p>
  
  <p>Can I get some advice about this modeling issue?</p>
  
  <p>Another depending question is about the identity of <em>schoolYear</em>.</p>
  
  <ul>
  <li>Option A: Generate a UUID as is and holds <em>schoolId</em> + <em>year</em> as attributes</li>
  <li>Option B: Id is <em>schoolId</em> and <em>year</em>, so we cannot create the same <em>schoolYear</em> twice for the same <em>school</em> and the same year</li>
  </ul>
  
  <p>Any advise on this?</p>
  
  <p>Thanks a lot helping me enter the DDD world!</p>