ruchi.verma
25th July 2008, 09:22
What does deleting a table reference means ?
does it mean deleting that record...

can an example be given...;)

satish_pabathi
19th August 2008, 15:14
A table refered to that particular table .

NPRao
19th August 2008, 19:58
Ruchi,

Refer to the Baan developers software documenation CD for more info -

Table and field references
Business logic and application design might demand a certain level of inter-dependence between tables. To set up this relationship, you can define references at the table field level.
You can set up the relationship so that one field in a particular table refers to a logically similar field from another table. This type of reference is more relevant in a master-detail relationship
between the tables.
In the following Human Resources example, the Employee and Department tables have a logical relationship between them. If an employee works for a particular department, the
department code in the employee record must also exist in the Department table. In this case, you can think of the Department table as a master or parent table, and the Employee as the
child table.
Employee Department
Employee Code Department Code
Name Description
Address No. of Employees
Department Code
Figure 4-9 Relationship between the Employee and Department tables
To have interdependency between two or more tables, you must create a reference. A reference is a defined relationship between tables. This relation is set at the table-field level. In the
previous scenario, the two tables involved in the reference are called Related tables. To define the reference, you must create the primary index on the parent table.
The child table can reference the parent table in various modes. Refer to the previous scenario when you review the following possible reference modes:
------------------------------------------------------------------------
Mandatory The relation to the specified table is mandatory, which means that the record which is being referred to must exist.
For example, the Department Code in the Employee table must exist in the Department table and cannot be left blank
Mandatory unless empty The relation to the specified table is mandatory unless the field, or one of the child fields in case of a combined field, is not filled.
For example, the Department Code in the Employee table must exist in the Department table unless no department code is entered at all. As a result, the Department Code is left empty in the Employee table.
Not Mandatory The relation to the specified table is not mandatory. For example, the Department Code in the Employee table need not exist in the Department table
------------------------------------------------------------------------
Referential integrity
Because of the logical relationship between related tables, you must carefully consider the results of deleting or changing records in the parent table, and the effect this can have on the
child table. This can help to ensure the overall correctness of the data, which is also known as data integrity.
Referential integrity means setting up appropriate rules to protect and ensure the consistency and validity of the data between the referenced tables. These rules are defined in the child
table, and they specify the action to be taken in case of a delete or update on the parent table.
In the scenario discussed previously, if a record in the Department table is deleted and employee records, from the Employee table, exist for that department, then one of the following rules must be applied to address that situation:
?? All records from the Employee table that refer to the deleted department are also deleted.
?? A check is performed to ensure that if any employee records exist for that department, then
the deletion of the department record is not allowed.
?? No check is performed, and the deletion of the department is allowed.
The BaanERP software provides a choice of rules that can be used to ensure referential
integrity for the situations listed previously. The rules are as follows:
Child will be deleted
All child records that refer to the deleted parent record in the reference table will be deleted. This rule is also called the cascade rule.
Restricted (with counter)
A parent record cannot be deleted if any child refers to this parent. A reference counter is checked, which indicates how many child records refer to the parent. With each database action, this counter is checked and updated as necessary. The counter is checked whenever a delete action is initiated on the parent table, and permits the deletion only if the reference
counter is equal to zero.
No check
If the parent is deleted, no check or action will be performed on the child records that refer to the parent. In such a case, the referential integrity of the database cannot be guaranteed.
Lookup (Restricted)
Deletion of the parent is restricted if any child refers to the parent. Upon deletion of the parent, all child tables will be checked. This option is similar to Restricted, but does not use counters.
You can also define the rules for an update action in a similar manner to the delete scenario discussed previously.
So far, you have learned about the relationships between tables, as well as the methods for ensuring referential integrity for that related data. When you are ready to define the table and
field references, you can use the Table Fields (ttadv4122s000) session, as shown in the following figure. Previously in this chapter, the fields on the General tab were discussed.