Posts

Showing posts with the label one to one association

One to one association

Image
Welcome,  First, consider   when you might actually use a one-to-one association   because there are two main use cases.   The most common reason is for unique items   that a person or a thing can have only one of.   For example, an employee has_one : office   or a student has_one : id_card .   The ID card is unique.   It belongs only to this one student   and to no one else.   And that student is only allowed to have one ID card.   It's certainly possible to imagine a scenario   where an employee might have two offices. But by using a has_one relationship,   we're rejecting that possibility in our design.   We've made it a statement of fact   that each employee can have only one.   At the point that we want to allow employees   to have more than one,   we would need to revise our relationships to match. The second reason to use a one-to-one relationship   is to break up a sing...