AgileApps Support Wiki Pre Release

Difference between revisions of "Master-Detail relationship"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 1: Line 1:
==About Master-Detail Relationships==
==About Master-Detail Relationships==
A Master-Detail relationship is an association between two objects. When a Master-Detail relationship is created, it implies a tight relationship between the two objects. In essence, a Master-Detail relationship ''locks'' the objects together, so that every record in a Detail Object is associated with a record in a Master Object.
A Master-Detail relationship is a one-to-many association between two objects, where detail records only exist when there is a master record to point to.


Master-Detail relationships can be used in scenarios like these:
Examples of Master-Detail relationships include:
*Invoices, where ''items in an order'' are detail records, and ''pricing or discounts'' are fields in the master record (the invoice)
:* Invoices, where ''items in an order'' are detail records, and ''pricing or discounts'' are fields in the master record (the invoice)
*Timesheets, where ''employees'' are master records, and ''hours worked'' are detail records
:* Timesheets, where ''employees'' are master records, and ''hours worked'' are detail records
*Inventory, where where ''shoe style'' is a master record, while detail records specify the ''size and color'' of shoes in stock.
:* Inventory, where where ''shoe style'' is a master record, while detail records specify the ''size and color'' of shoes in stock.


For example, in an order management system, the Master object is ''Orders'' and the Detail object is ''Order Items''.
For example, consider an order management system, the Master object is ''Orders'' and the Detail object is ''Order Items''. Together, an invoice can be prepared from the records. Each line in the invoice can display the number of items ordered, the unit price, and line item total, taken from the detail records. Sales tax and sub-totals, meanwhile, can be calculated and stored in the master (invoice) record.


Together, an invoice can be prepared from the order items. Each line can display the number of items ordered, the unit price, and line item total. Sales tax and sub-totals can be calculated and included in the invoice.
When an order is deleted in a system like that, then all associated line items should be deleted as well.  


If an order is deleted, then all associated line items are deleted as well.  
In {{EnterpriseBrand}}, [[Rollup Summary Fields]] are used to do calculate the line item totals, and [[Cascade Rules]] are used to auto-delete detail records when a master record is deleted.


{{Note|The option to specify "Master-Detail relationship" when creating a Lookup field became redundant, and has been removed. Now, [[Rollup Summary Fields]] are used for summary calculations on fields in detail records, and [[Cascade Rules]] can be used automatically delete detail records when a master record is deleted. Those operations work across multiple related objects--not just those that have a particular flag set on the Lookup field that connects them.)}}
{{Note|There used to be an option to specify "Master-Detail relationship" when creating a Lookup field. That option became redundant, however, and has been removed. [[Rollup Summary Fields]] and [[Cascade Rules]] achieve the same goals, but they work across multiple related objects--not just those that have a particular flag set on the Lookup field that connects them.}}

Revision as of 20:09, 30 July 2014

About Master-Detail Relationships

A Master-Detail relationship is a one-to-many association between two objects, where detail records only exist when there is a master record to point to.

Examples of Master-Detail relationships include:

  • Invoices, where items in an order are detail records, and pricing or discounts are fields in the master record (the invoice)
  • Timesheets, where employees are master records, and hours worked are detail records
  • Inventory, where where shoe style is a master record, while detail records specify the size and color of shoes in stock.

For example, consider an order management system, the Master object is Orders and the Detail object is Order Items. Together, an invoice can be prepared from the records. Each line in the invoice can display the number of items ordered, the unit price, and line item total, taken from the detail records. Sales tax and sub-totals, meanwhile, can be calculated and stored in the master (invoice) record.

When an order is deleted in a system like that, then all associated line items should be deleted as well.

In AgileApps Cloud platform, Rollup Summary Fields are used to do calculate the line item totals, and Cascade Rules are used to auto-delete detail records when a master record is deleted.

Notepad.png

Note: There used to be an option to specify "Master-Detail relationship" when creating a Lookup field. That option became redundant, however, and has been removed. Rollup Summary Fields and Cascade Rules achieve the same goals, but they work across multiple related objects--not just those that have a particular flag set on the Lookup field that connects them.