AgileApps Support Wiki Pre Release

Difference between revisions of "Master-Detail relationship"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
==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.
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.


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 a more detailed example, consider an order management system, where the Master object is ''Orders'' and the Detail object is ''Order Items''. Together, an invoice can be prepared from those records. Each line in the invoice can display the number of items ordered, the unit price, and the line item total, using values 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.
In addition, 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 the {{EnterpriseBrand}}:
:* [[Rollup Summary Fields]] are used to do calculate the line item totals.
:* [[Cascade Rules]] are used to auto-delete detail records when a master record is deleted.
:* [[Subforms]] are typically used to view and modify detail records while entering or editing a master record.


{{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.}}

Latest revision as of 20:14, 30 July 2014

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 a more detailed example, consider an order management system, where the Master object is Orders and the Detail object is Order Items. Together, an invoice can be prepared from those records. Each line in the invoice can display the number of items ordered, the unit price, and the line item total, using values taken from the detail records. Sales tax and sub-totals, meanwhile, can be calculated and stored in the master (invoice) record.

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

In the AgileApps Cloud platform:

  • Rollup Summary Fields are used to do calculate the line item totals.
  • Cascade Rules are used to auto-delete detail records when a master record is deleted.
  • Subforms are typically used to view and modify detail records while entering or editing a master record.

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.