Clarion & ANSI SQL Standard Referential Integrity and Referential
Total Page:16
File Type:pdf, Size:1020Kb
Clarion & ANSI SQL Standard Referential Integrity and Referential Actions November 12, 2018 Whitemarsh Information Systems Corporation 2008 Althea Lane Bowie, Maryland 20716 Tele: 301-249-1142 Email: [email protected] Web: www.wiscorp.com Referential Integrity and Referential Actions Fundamental Definition: Actions resulting from instruction to the database engine created in the dictionary (i.e., schema) associated with “Relationship” specifications. For SQL-engine DBMSs, these relationship-specifications and actions relate to value congruence between the value-set of a primary key’s column(s) and the value-set of a Foreign key’s column(s). When either a Update or Delete action occurs that violates the value congruence, a Referential Action occurs. The actions depend on whether the Referential Action is specified. In ANSI SQL Standards, the four referential integrity actions: No Action, Cascade, or Set Null or Set Default. In Clarion, the five referential integrity actions are: None, Restrict, Cascade, Clear, Cascade Server, ClearServer and Restrict Server. Copyright 2018, Whitemarsh Information Systems Corporation Proprietary Data, All Rights Reserved 2 Referential Integrity and Referential Actions Referential Integrity and Actions Referential Action taken when violation occurs On Update On Delete Referential Action Parent Child Parent Child Function ANSI Clarion Table Table Table Table Parent Table No equivalent None: Instructs the Primary No change Row is Nothing. Primary Key Application Generator not key in the deleted Effect is to Column value can to generate any code to column foreign key make the change. Foreign maintain referential value can value child table Key Column value integrity between any change row an does not change. parent and child (a.k.a., orphan related) tables. A primary key column value can be changed without any affect on any child’s foreign key values. Copyright 2018, Whitemarsh Information Systems Corporation Proprietary Data, All Rights Reserved 3 Referential Integrity and Referential Actions Referential Integrity and Actions Referential Action taken when violation occurs On Update On Delete Referential Action Parent Child Parent Child Function ANSI Clarion Table Table Table Table Referential Actions No Action: Disallows Restrict: Tells the Rejects Nothing as Parent row Nothing as are prevented to the update or deletion of Application Generator to any Pkey operation cannot be operation both Parent Table values to a parent prevent the user from Column is rejected deleted as is rejected and Child Tables primary key column that deleting or changing an value out of this would out of would result in required entry, if the value is used change to hand. result in an hand changes to related table in a foreign key. For any orphan foreign key values. example, if the user different child attempts to change a value. It is checked at the end of primary key value, the the statement, or at the generated code checks for end of the transaction if a related record with the the constraint is deferred. same key value. If it finds a match, it will not allow the change. Copyright 2018, Whitemarsh Information Systems Corporation Proprietary Data, All Rights Reserved 4 Referential Integrity and Referential Actions Referential Integrity and Actions Referential Action taken when violation occurs On Update On Delete Referential Action Parent Child Parent Child Function ANSI Clarion Table Table Table Table Changes in Cascade: When Cascade: Tells the If Pkey Foreign Parent Child Primary Key referenced data is Application Generator to column Key value Table row rows are Column value also updated, all associated update or delete the value is is changed is deleted deleted cause updates to dependent data is foreign key record. For changed it to be that if and only where every foreign key correspondingly updated. example, if the user must be of the if all child Fkey column value in When a referenced row is changes a primary key changed changed rows are Value is related child tables. deleted, all associated value, the generated code to be Pkey value success- that of the dependent rows are changes any matching different fully parent’s deleted values in the foreign key. value deleted Pkey If the user deletes a parent from all Value. record, the code deletes other the children too. row’s Pkey Values Copyright 2018, Whitemarsh Information Systems Corporation Proprietary Data, All Rights Reserved 5 Referential Integrity and Referential Actions Referential Integrity and Actions Referential Action taken when violation occurs On Update On Delete Referential Action Parent Child Parent Child Function ANSI Clarion Table Table Table Table Resets the value of Set Default: When Does not exist Clarion Change in Foreign Parent row Child a Primary Key referenced data is Primary Key value is able to rows column to the its updated or deleted, all Key is changed be deleted. remain default value that associated dependent Column to be the and their was established in data is set to a default Value to default Foreign the schema. value its initial value for Key non-null that values are default column. set to the value default given that value. the Pkey Column value is able to be updated or deleted. Copyright 2018, Whitemarsh Information Systems Corporation Proprietary Data, All Rights Reserved 6 Referential Integrity and Referential Actions Referential Integrity and Actions Referential Action taken when violation occurs On Update On Delete Referential Action Parent Child Parent Child Function ANSI Clarion Table Table Table Table Removes the non- Set Null: When Clear: Instructs the If Pkey Foreign Parent row Child null value for the referenced data is Application Generator to Column Key value is able to rows Primary Key updated or deleted, all change the value in the value is is changed be deleted. remain Column and sets it associated dependent foreign key to null or able to be to Null for and their to the Null Value. data is set to NULL. zero. set to Null that Foreign column. Key Disallowed if the values are column cannot is a set Null. Non Null valued column. Copyright 2018, Whitemarsh Information Systems Corporation Proprietary Data, All Rights Reserved 7.