Question

In: Computer Science

Describe the three main types of referential actions (cascade, restrict, set null). How do you use...

Describe the three main types of referential actions (cascade, restrict, set null). How do you use these in your work?

Solutions

Expert Solution

cascade :

It means that no action is performed with the child data when the parent data is deleted or updated. CASCADE. It is used in conjunction with ON DELETE or ON UPDATE. It means that the child data is either deleted or updated when the parent data is deleted or updated.

ON DELETE CASCADE / ON UPDATE CASCADE When a referenced foreign key is deleted or updated, all rows referencing that key are deleted or updated, respectively. If there are other alterations to the row, such as a SET NULL or SET DEFAULT, the delete will take precedence.

Note that CASCADE does not list objects it drops or updates, so it should be used cautiously.

restrict

ON DELETE NO ACTION Default action. If there are any existing references to the key being deleted, the transaction will fail at the end of the statement. The key can be updated, depending on the ON UPDATE action.

Alias: ON DELETE RESTRICT
ON UPDATE NO ACTION Default action. If there are any existing references to the key being updated, the transaction will fail at the end of the statement. The key can be deleted, depending on the ON DELETE action.

Alias: ON UPDATE RESTRICT
ON DELETE RESTRICT / ON UPDATE RESTRICT RESTRICT and NO ACTION are currently equivalent until options for deferring constraint checking are added. To set an existing foreign key action to RESTRICT, the foreign key constraint must be dropped and recreated.

set null :

ON DELETE SET NULL / ON UPDATE SET NULL When a referenced foreign key is deleted or updated, respectively, the columns of all rows referencing that key will be set to NULL. The column must allow NULL or this update will fail.
ON DELETE SET DEFAULT / ON UPDATE SET DEFAULT When a referenced foreign key is deleted or updated, the columns of all rows referencing that key are set to the default value for that column.

If the default value for the column is null, or if no default value is provided and the column does not have a NOT NULL constraint, this will have the same effect as ON DELETE SET NULL or ON UPDATE SET NULL. The default value must still conform with all other constraints, such as UNIQUE.

Related Solutions

Briefly describe the use of cascade control and its main benefits.
Briefly describe the use of cascade control and its main benefits.
Describe the types of activities in each of the three main sections of the Statement of...
Describe the types of activities in each of the three main sections of the Statement of Cash Flows and provide two examples. a) Operating b) Investing c) Financing
1. Explain how the three classes of receptors initiate a signal transduction cascade and describe how...
1. Explain how the three classes of receptors initiate a signal transduction cascade and describe how they are activated and the downstream proteins/molecules activated.
What would you do if you encountered a database that violated referential integrity? How would you...
What would you do if you encountered a database that violated referential integrity? How would you address the problem? When forming your answer be sure to include at least one of the three main types of referential actions (cascade, restrict, set null).
What is meant by a “null” hypothesis? How do you test a null hypothesis?
What is meant by a “null” hypothesis? How do you test a null hypothesis?
Describe the three main types of discrimination in the workplace, and discuss the organizational defenses for...
Describe the three main types of discrimination in the workplace, and discuss the organizational defenses for employee accusations of discrimination.
What is a null hypothesis and what is an alternative hypothesis?  How do you choose the null...
What is a null hypothesis and what is an alternative hypothesis?  How do you choose the null hypothesis in general? Give an example What is type I error? What is type II error? What is the significance level? What is the power of the test? What is the p-value of a hypothesis test?. Please type the answer. I have difficulties understanding handwritten answers. Thanks  
What is meant by a “null” hypothesis? How do you test a null hypothesis? What are...
What is meant by a “null” hypothesis? How do you test a null hypothesis? What are alternate hypotheses?   What are p-values? Explain "significance level." This is for business statistics
Why do you think researchers use samples? Why do you think we also use null and...
Why do you think researchers use samples? Why do you think we also use null and alternative (research) hypotheses?
Review the steps involved in a statistical hypothesis test. How do we set up the null...
Review the steps involved in a statistical hypothesis test. How do we set up the null and alternative hypotheses? How do we set the level of significance? Can you think of a business research situation where you could apply such processes?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT