Oracle Magazine, July/August 2018
Database Developer OPEN SOURCE ORACLE MAGAZINE JULY AUGUST 2018 102 get_ all_ rows Original People Data people get_ all_ rows Original Pet Data pets Your code here get_ all_ rows New People Data people get_ all_ rows New Pet Data pets DELETING RECORDS REFERENCED BY FOREIGN KEYS If you are using integrity constraints in your database of course you are because you let the database do some heavy lifting for you you will sometimes need to change the way you process your changes In this articles data design a foreign key constraint in cx_ pets ensures that if a pet has an owner that owner exists Here is the statement that creates this constraint in the Create the Database Objects section of Part 1 of this article series ALTER TABLE CX_ PETS ADD CONSTRAINT FK_ CX_ PETS_ OWNER FOREIGN KEY OWNER REFERENCES CX_ PEOPLE ID If you attempt to delete a record in cx_ people that is referenced in cx_ pets where a pet has that owner you will get an error To see this replace the Your code here line in delete py with the following code snippet and run delete py in your Python session
You must have JavaScript enabled to view digital editions.