Posts

Showing posts with the label one to many

One to Many Association

Image
Greetings Geeks, Let's  understand how to work with  one-to-many associations .   One-to-many associations are gonna be similar   to one-to-one associations,   but there are a few main differences that I wanna highlight.   First, one-to-many associations   are gonna be much more commonly used.   In a typical application, you'll rarely use one-to-one,   but you'll use one-to-many the most often.   Second, because we have one object related to many objects,   we're gonna use plural names.   That's both gonna be true when we define the association   and also when we call the methods on it. And third, the relationship   is going to return an array of objects back to us   instead of a single object.   And that just makes sense, right?   If we're going to have many records associated with it,   we're going to have to store those in an array   so that it can hold all of those records...