now i have created a field in the customer_entity table as student id..
i have applied foreign key to the student id in customer table using this:
->addForeignKey( $installer->getFkName('customer_entity', 'student_id', 'student_table', 'student_id'), 'customer_entity', 'student_id', $installer->getTable('student_table'), 'student_id' , \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE);
there is no error.. but now if i am trying to edit or delete the student id in student table it is giving me error..
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`magento`.`customer_entity`, CONSTRAINT `CUSTOMER_ENTITY_STUDENT_ID_STUDENT_TABLE_STUDENT_ID` FOREIGN KEY (`student_id`) REFERENCES `student_table` (`student_id`) ON DELETE CASCADE), query was: UPDATE `student_table` SET `student_id` = ? WHERE (entity_id='1')
can anyone help?
@Vimal Kumar this is working.. if i delete the Parent table(student table) student id.. it is deleting the customer's whole row containing that student id.. but i cannot update the student id in the parent table.. why?
i had added Action Cascade on the parent table as you can see in my above code
\Magento\Framework\DB\Ddl\Table::ACTION_CASCADE);