title: Relational Algebra - Cartesian Product vs Natural Join?
body: <p>I am studying for exams and am failing to find a solid criteria by which I can determine if the Cartesian Product <code>x</code> is to be used or if Natural Join <code>|X|</code> is to be used.</p>
  
  <p>I had come up with a rough guide that: </p>
  
  <p><em><strong>"If you need to project an attribute that has the same name as an attribute in the table to be joined you must use <code>x</code> and state the table names to be projected: <code>tableA.colname1 = tableB.colname1</code>"</em></strong></p>
  
  <p>This however doesn't follow some of the solutions in my notes and my lecturer seems to use <code>x</code> with the above convention or <code>|x|</code> interchangeably.</p>
  
  <p>Does anyone have a rule that can be followed to define use of one over the other?</p>
  
  <hr>
  
  <p>Take for example this schema (only schema related to the question quoted for brevity):</p>
  
  <pre><code>takes(ID, course_id, sec_id, semester, year, grade)
  student(ID, name, dept_name, tot_cred)</code></pre>
  
  <p>Q) Find the name of all students who took courses that were taught in either Spring 2011 or Autumn 2011.</p>
  
  <p>My answer attempt:</p>
  
  <pre><code>π name(σ semester="Spring" ^ year=2011(takes ⋈ student)) ∪ π name(σ semester="Autumn" ^ year=2011(takes ⋈ student))</code></pre>
  
  <p>Actual answer:</p>
  
  <pre><code>π name(σ semester="Spring" ^ year=2011 ^ takes.ID=student.ID(takes x student)) ∪ π name(σ semester="Autumn" ^ year=2011 ^ takes.ID=student.ID(takes x student))</code></pre>
  
  <p>Can anyone provide a reason as to why?</p>
  
  <p>In my mind the Natural Join would take care of the <code>takes.ID=student.ID</code>?</p>