Difference Between One-to-Many, Many-to-One and Many-to-Many?

后端 未结 8 2039
孤城傲影
孤城傲影 2020-11-28 17:39

Ok so this is probably a trivial question but I\'m having trouble visualizing and understanding the differences and when to use each. I\'m also a little unclear as to how co

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 17:54

    I would explain that way:

    OneToOne - OneToOne relationship

    @OneToOne
    Person person;
    
    @OneToOne
    Nose nose;
    

    OneToMany - ManyToOne relationship

    @OneToMany
    Shepherd> shepherd;
    
    @ManyToOne
    List sheeps;
    

    ManyToMany - ManyToMany relationship

    @ManyToMany
    List travelers;
    
    @ManyToMany
    List destinations;
    

提交回复
热议问题