title: How to decide which entity relationship should be used in JPA
body: <p>I have two entity classes there Order and Shop. An order should belong to one shop.And many orders can also belong to one shop. 
  My existing mapping is One to One unidirectional mapping from Order to Shop class.And it's working.</p>
  
  <pre><code>@Entity
  @Table(name = "order")
  public class Order implements Serializable {
  
      @Id
      @Column(name = "id")
      private Long id;
  
      @Column(name = "orderno")
      private Long orderNumber;
  
      @OneToOne
      @JoinColumn(name = "shopid")
      private Shop shop;
  
      ..
  }   
  @Entity
  @Table(name = "shop")
  public class Shop implements Serializable {
  
       @Id
       @Column(name = "id")
       private Long id;
  
       @Column(name = "key")
       private String key;
  
       @Column(name = "name")
       private String name;
  
       ..
   }
  </code></pre>
  
  <p>Now I found that Order to Shop could be ManyToOne relationship and should work.
  Now I wish to what are the differences between these two options and which one should be used.</p>
  
  <p>Also I am not 100% sure how to decide which one of entity relation should be used like One to One, One to Many, Many to One, Many to Many also whether the relation should unidirectional or bidirectional. Any explanation or suggested reading would be helpful.</p>