0% found this document useful (0 votes)
14 views

Referential Cycle 2.0

The document discusses data integrity and referential cycles in databases. It explains that data integrity constraints restrict values that can be inserted or updated to preserve consistency. Referential cycles can occur when a constraint links a child table back to its parent table, creating a loop. To avoid issues, one relationship in the cycle needs a RESTRICT or SET NULL rule rather than CASCADE to allow deleting rows without cascading unintentionally.

Uploaded by

Bhagesh Khavshe
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Referential Cycle 2.0

The document discusses data integrity and referential cycles in databases. It explains that data integrity constraints restrict values that can be inserted or updated to preserve consistency. Referential cycles can occur when a constraint links a child table back to its parent table, creating a loop. To avoid issues, one relationship in the cycle needs a RESTRICT or SET NULL rule rather than CASCADE to allow deleting rows without cascading unintentionally.

Uploaded by

Bhagesh Khavshe
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 6

Presented by –

Kamal Tanwar
Tanmay Gupte
Bhagesh Khavshe
Venkatesh Rao
Bruno Nellisery
Harish Mordani
DATA INTEGRITY
Refers to the correctness and completeness of the data in a
database

To preserve the consistency and correctness, a RDBMS


imposes one or more data integrity constraints.

These constraints restrict the values that can be inserted


or created by a database update.

The various constraints are :Required data, Validity


checking, Entity Integrity, Referential Integrity,
Consistency, Business Rules and other data relationships
REFERENTIAL CYCLES
REFERENTIAL CYCLES
INSERT INTO SALESREPS (EMPL_NUM, NAME, REP_OFFICE,HIRE_DATE, SALES) VALUES
(115,'Ben Adams', 14, '01-APR-90', 0.00)

INSERT INTO OFFICES (OFFICE, CITY, REGION, MGR, TARGET, SALES) VALUES
(14,'Detroit', 'Eastern', 115, 0.00, 0.00)

Soln:
INSERT INTO SALESREPS (EMPL_NUM, NAME, REP_OFFICE,HIRE_DATE, SALES) VALUES
(115,'Ben Adams', NULL, '01-APR-90', 0.00)

INSERT INTO OFFICES (OFFICE, CITY, REGION, MGR, TARGET, SALES)VALUES


(14,'Detroit', 'Eastern', 115, 0.00, 0.00)

UPDATE SALESREPS SET REP_OFFICE = 14 WHERE EMPL_NUM = 115


RESTRICT rule
All three relationships specify
the RESTRICT delete rule
George's row is the only row
that can be deleted
Every other row is a parent
and is protected from deletion
by the RESTRICT rule.
Hence, RESTRICT rule should
not be specified for all
relationships in a referential
cycle
CASCADE rule
The CASCADE rule presents a
similar problem
For a production database, it
becomes impossible to keep
track of the cascaded deletions
and retain the database
integrity
At least one relationship must
have a RESTRICT or SET NULL
delete rule to break the cycle
of cascaded deletions.

You might also like