title: Many to Many Relationship
body: <p>Please help me understand further the <code>many to many</code> relationship. Suppose I have Teacher and Students Table and in my understanding it is <code>one-to- many</code>.</p>
  
  <p><strong>Teacher</strong></p>
  
  <pre><code>TeacherId Primary Key 
  TeacherName 
  </code></pre>
  
  <p><strong>Student</strong></p>
  
  <pre><code>StudentId Primary Key
  TeacherId Foreign Key
  StudentName
  </code></pre>
  
  <p><code>TeacherId</code> can appear several times in the Student Table.
  I'm confused because Student can have many teacher. </p>
  
  <ol>
  <li>When can I say something is <code>one-to-many</code> and when is it <code>many to many</code>?</li>
  </ol>
  
  <p>I can say <strong>One</strong> Student can have <strong>many</strong> teacher.</p>
  
  <p>On the other hand, I can also say that <strong>One</strong> Teacher can have <strong>many</strong> student.</p>
  
  <ol start="2">
  <li>If both of <strong>one</strong> teacher and <strong>one</strong> student can have many students(<em>for teacher</em>), many teacher(<em>for students</em>). How should I construct the table(s)? </li>
  <li>Is Student-Teacher relationship or vice versa can be considered <code>many-to-many</code>?</li>
  </ol>
  
  <p>I understand that once I've properly identified the relationships, it would be easier for me to decide how many tables to create or whether or not there's a need to create a join table. From the tutorials and information I read online, it says that I should create a <code>join-table</code> if the relationship is <code>many-to-many</code>. So I thought it should look something like this.</p>
  
  <p><strong>Teacher</strong></p>
  
  <pre><code>TeacherId Primary Key 
  TeacherName 
  </code></pre>
  
  <p><strong>Student</strong></p>
  
  <pre><code>StudentId Primary Key
  StudentName
  </code></pre>
  
  <p><strong>Teacher_Student(join table)</strong></p>
  
  <pre><code>Id Primary Key
  TeacherId PRIMARY KEY
  StudentId --took PKs of both Student and Teacher table.
  </code></pre>
  
  <p>Are there conditions to easily identify relationships, maybe if it's dependent on one table or not? </p>
  
  <p>I'd appreciate any explanation. I just started learning this. </p>
  
  <p>Thanks. </p>