There are three types of Delete actions :
- None : The row in this table is deleted but nothing occurs in the specified table.
- Cascade : The row in this table is deleted and all the releated data in the specified table is also deleted. This ensures that no orphaned records remain after the deletion.
- Restricted : The row in this Table is only deleted if there is nothing that releats to it in the specified table. This is used when parent record should only be deleted when no child record exists, and the child record is important to keep.
- Cascade +Restricted : Behaves the same as restricted.
Advantage -
1. Data integrity - Prevent Orphaned records (No meaningless data in database)
Delete actions rely upon relations. First we create a relation between tables , and then create a delete action.
Delete actions are defined on Master table, you must have proper relations between tables, to perform delete actions.
student master
Table : studentclassdetails studentmarkstable
Restricted says, look there is a marks record and u cannot delete a record in class table
Cascade says, okay delete a record in class table, so record in marks table are also deleted.
Example :
1. Create 3 tables
i) StudentMarksTable - 3 fields
StudentId- string, semester- string, subject -string, marks -int
ii) Student Table
Id- string, Name- string
iii)GlobalstudentsTable
Studentid(string), name-string
Relations on StudentMarksTable, with studenttable Normal
Relation on studentable with global students table Normal
- None : The row in this table is deleted but nothing occurs in the specified table.
- Cascade : The row in this table is deleted and all the releated data in the specified table is also deleted. This ensures that no orphaned records remain after the deletion.
- Restricted : The row in this Table is only deleted if there is nothing that releats to it in the specified table. This is used when parent record should only be deleted when no child record exists, and the child record is important to keep.
- Cascade +Restricted : Behaves the same as restricted.
Advantage -
1. Data integrity - Prevent Orphaned records (No meaningless data in database)
Delete actions rely upon relations. First we create a relation between tables , and then create a delete action.
Delete actions are defined on Master table, you must have proper relations between tables, to perform delete actions.
student master
Table : studentclassdetails studentmarkstable
Restricted says, look there is a marks record and u cannot delete a record in class table
Cascade says, okay delete a record in class table, so record in marks table are also deleted.
Example :
1. Create 3 tables
i) StudentMarksTable - 3 fields
StudentId- string, semester- string, subject -string, marks -int
ii) Student Table
Id- string, Name- string
iii)GlobalstudentsTable
Studentid(string), name-string
Relations on StudentMarksTable, with studenttable Normal
Relation on studentable with global students table Normal
Hope you find the data useful... :)
Its help me lot..........
ReplyDeleteIts help me lot..........
ReplyDelete