Page 1 of 1

About Question enthuware.oce-jpad.v6.2.444 :

Posted: Sun Aug 09, 2015 1:30 pm
by piotr.kraciuk
What about situation, when more than one person (or any other entity) has associated the same address in addresses list?

I assume address like that wouldn't become orphaned after remove of one person, and thus part "all the associated addresses are removed as well" would not be true with option 3.

Re: About Question enthuware.oce-jpad.v6.2.444 :

Posted: Sun Aug 09, 2015 10:09 pm
by admin
The problem statements clearly says that it is a unidirectional one-to-many. So same Address cannot be referred to by multiple Persons.

Re: About Question enthuware.oce-jpad.v6.2.444 :

Posted: Mon Aug 10, 2015 11:41 am
by piotr.kraciuk
You're right:) But what about situation, when this Address is in relation to some other Entity?

Lets say, that we have entity Letter, with the same Address assigned. Person with this address is removed, but Letter with this address remains in the database. Wouldn't option 3 be false then?

Re: About Question enthuware.oce-jpad.v6.2.444 :

Posted: Mon Aug 10, 2015 7:48 pm
by admin
Orphan delete implies that Person is the owner of Address. If you are associating the same address with another entity then that means you have a problem in your relationships! The address entity will be removed as per the orphan delete policy when you delete a person.

Re: About Question enthuware.oce-jpad.v6.2.444 :

Posted: Mon Aug 10, 2015 11:56 pm
by piotr.kraciuk
Thank you for for clarification.

Re: About Question enthuware.oce-jpad.v6.2.444 :

Posted: Mon Jul 03, 2017 2:37 pm
by himaiMinh
In the previous post:
But what about situation, when this Address is in relation to some other Entity?
Example, Employee 1 is living at Address 1. Employee 2, who is a spouse of Employee 1 is also living at Address 1. If Employee 1 quit the company, Employee 1 should be removed. Employee 2 stays with the company. Therefore, Address 1 should not be removed in the database.
In this situation, we don't want to cascade the remove in the Address.
In this case, a join table can be used like this:
Table : Employee_Address
Employee_ID (pk, Fk) Address_ID (PK, FK)
1 1
2 1
where pk's is composite primary key of the join table , FK is foreign keys referring to Employee and Address's primary keys.

Re: About Question enthuware.oce-jpad.v6.2.444 :

Posted: Wed Sep 19, 2018 7:47 am
by __JJ__
piotr.kraciuk wrote:
Sun Aug 09, 2015 1:30 pm
What about situation, when more than one person (or any other entity) has associated the same address in addresses list?
Then that address wouldn't be an orphan. orphanRemoval=true as the name suggests is intended to remove orphans.