Delete Action is AX:
This Deletion are used for deleting the records from the tables.This delete action are mainly used to avoid the inconsistent data in database. the deletion are mainly used when the table data are interdependent on one other for the consistent information about a record.
Lets Take a example:
Table one : This table has three column that is account number as account,name and city.
| account | name | city | ||
| 1011 | sachin | Mumbai | ||
| 1012 | dravid | indore | ||
| 1013 | dhoni | ranchi | ||
| 1014 | kohli | delhi | ||
| 1015 | sehwag | Najafgarh | ||
| 1016 | rohit | Nagpur | ||
Table two: This table has three column that account, car id and car name and this account number is depend on the table one.
| account | car id | car name | ||
| 1011 | 101 | BENZ | ||
| 1011 | 102 | BMW | ||
| 1011 | 103 | Audi | ||
| 1012 | 101 | BENZ | ||
| 1012 | 102 | BMW | ||
| 1012 | 103 | Audi | ||
| 1013 | 104 | jaguar | ||
| 1014 | 101 | BENZ | ||
| 1014 | 103 | Audi | ||
| 1015 | 101 | BENZ | ||
| 1016 | 101 | BENZ | ||
The above tables are relation with each other so this can treated as parent and child tables.so the table one is the parent table and table two is the child table.
So we have how the deletion maintains the consistences of data in data base so now lets us see how many types of delete action are there in ax.
Types of Delete Action:
1.None
2.Cascade
3.Restricted.
4.Cascade + Restricted.
The are the delete action present in AX.
NONE: This delete action will not take any action in the tables.
Cascade : This cascade is used to delete the related data in both the table so let take a Example:
When we define the delete action in the parent table as cascade means in the table one.so lets see what happens.
so when you want delete a record say we want to delete the rohit records so select the rohit record in the table and press alt+f9 it will prompt a alter message saying are you sure you want to delete after pressing the yes both the table will be deleted.
Result will look like this in table one
| account | name | city | ||
| 1011 | sachin | Mumbai | ||
| 1012 | dravid | indore | ||
| 1013 | dhoni | ranchi | ||
| 1014 | kohli | delhi | ||
| 1015 | sehwag | Najafgarh | ||
Result will look like this in table two:
| account | car id | car name | ||
| 1011 | 101 | BENZ | ||
| 1011 | 102 | BMW | ||
| 1011 | 103 | Audi | ||
| 1012 | 101 | BENZ | ||
| 1012 | 102 | BMW | ||
| 1012 | 103 | Audi | ||
| 1013 | 104 | jaguar | ||
| 1014 | 101 | BENZ | ||
| 1014 | 103 | Audi | ||
| 1015 | 101 | BENZ | ||
The above examples give a how the delete action is taken place.
Restricted : This action is when you want to restrict the deletion of the record if it has any dependence on the other table.
So let see with a example:
So if we define the restricted delete action on the table and we are trying the delete records so let see what will happen.
Data in Table one as following:
| account | name | city | ||
| 1011 | sachin | Mumbai | ||
| 1012 | dravid | indore | ||
| 1013 | dhoni | ranchi | ||
| 1014 | kohli | delhi | ||
| 1015 | sehwag | Najafgarh | ||
| 1016 | rohit | Nagpur | ||
| account | car id | car name | ||
| 1011 | 101 | BENZ | ||
| 1011 | 102 | BMW | ||
| 1011 | 103 | Audi | ||
| 1012 | 101 | BENZ | ||
| 1012 | 102 | BMW | ||
| 1012 | 103 | Audi | ||
| 1013 | 104 | jaguar | ||
| 1014 | 101 | BENZ | ||
| 1014 | 103 | Audi | ||
| 1015 | 101 | BENZ | ||
When you to try to delete the ''sachin" record it will through a error saying that you have dependence on the table two. so first delete the those records and after that it will allow you to delete the records in the table one.
Cascade + Restricted:This option is mainly used when deletion is more than one level.That means as we have seen early example it was between parent and child tables so when you have more than two table like we have grand child table and there are also dependent one table one than we have to go for cascade/restricted delete action.