Session 9
Session 9
Table A Table B
Std ID (PK) SNO(PK)
StdName StdID(FK)
StdClass StdClass
Database & SQL
• Whenever you delete a record from Table A,
any records in Table B that are linked to the
deleted record will also be deleted. This is
called cascading delete.
• Whenever you modify the value of a linked
field in Table A, all records in Table B that are
linked to it will also be modified accordingly.
This is called cascading update.
Database & SQL
• One-to-One Relationships
• One-to-one relationships occur when there is
exactly one record in the first table that
corresponds to exactly one record in the
related table.
Database & SQL
• One-to-many and many-to-one relationships
• An employee can work in only one
department; this relationship is single-valued
for employees. On the other hand, one
department can have many employees; this
relationship is multi-valued for departments.
The relationship between employees (single-
valued) and departments (multi-valued) is a
one-to-many relationship.
Database & SQL
• Many-to-many relationships
• A relationship that is multi-valued in both
directions is a many-to-many relationship. An
employee can work on more than one project,
and a project can have more than one
employee.