Difference between revisions of "Master-Detail relationship"
imported>Aeric |
imported>Aeric |
||
Line 1: | Line 1: | ||
==About Master-Detail Relationships== | ==About Master-Detail Relationships== | ||
A Master-Detail relationship is | 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 | 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, | 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 {{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| | {{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.
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.