You need to sign in to do that
Don't have an account?
avimeir
Many-to-many relationship
Hi All
I am new to Force.com, trying to figure out a way to create a many-to-many relationship of objects.
I have two custom objects: Rooms and Reservations. A reservation can have zero or more rooms assigned to it, and a room can be assigned to zero or more reservations.
I tried using Master-Detail but it requires a single assignment on one of the objects, instead - I want to have lists on both objects, that can be empty or have more than 1 items.
Thanksq
You need to create a third object called Junction object to achieve Many to Many relationship. Rooms and Reservations objects will be the master for Junction object.
Creating a Many-to-Many Relationship: https://ap1.salesforce.com/help/doc/en/relationships_manytomany.htm
Madhan Raja M
All Answers
Just use the standard relationship, also, I would say to explore the new schema builder.
PB
You need to create a third object called Junction object to achieve Many to Many relationship. Rooms and Reservations objects will be the master for Junction object.
Creating a Many-to-Many Relationship: https://ap1.salesforce.com/help/doc/en/relationships_manytomany.htm
Madhan Raja M
Thanks!
And some followup advice.
- Naming
- Room
- Reservation
- Room Reservation (this should be the name of many to many resolution object).
Master detail relationships
- between Room and Room Reservation...this gets interesting. If someone deletes a Room (rare), would you want all the Room Reservations to cascade delete? Probably not. So I would not advise a Master Detail relationship
- between Reservation and Room Reservation ...far more common for someone to delete a reservation. But once again, I assume that you wouldnt actually want to delete a Reservation (probably change its status instead). So I would not advise a Master Detail relationship for this scenario either.
Thanks for the great advice!