Skip to Main Content

Write Great SQL Office Hours

Free tips and training every month! Subscribe for reminders and more from Office Hours. FAQ

Header container

March 21, 2023

14:00 UTC   Start Times Around the World

Subscribe to be notified of changes to sessions and give us feedback!

Having trouble watching the video on this page? Open the video in your browser.

Description

Advanced guide to database constraints
Last month we covered the five fundamental database constraints: primary keys, unique constraints, foreign keys, not null, and check constraints.

In this session we looked at more advanced use cases for database constraints, including how to

Ensure there's always a child row in parent-child relationships
Use foreign keys to ensure there are no gaps or overlaps in start/end dates
Check the total across child rows equal the total on a parent column

Highlights include:

04:50 - Deferrable constraints
08:10 - Cyclic foreign keys
11:50 - Deferrable foreign keys demo
23:00 - Constraints with materialized views
28:10 - Materialized view constraint demo
39:10 - Enforce consecutive start/end dates
43:40 - Supertype/subtype relationships
46:50 - Advanced foreign key rules demo
59:30 - Recap of advanced constraint uses

Get the scripts https://livesql.oracle.com/apex/livesql/file/content_OWKKFFYX6HATARQYT0VTF2FUV.h tml
Learn SQL for free http://bit.ly/learn-sql-free-dfd-f

Your Experts

  • #SELECTION#
    Chris Saxon

    Chris Saxon   

    Chris Saxon is an Oracle Developer Advocate and quizmaster on Dev Gym. His job is to help you get the best out of the Oracle Database and have fun with SQL! He's also part of the answer team on Ask TOM and creates YouTube videos at The Magic of SQL channel.
    #MISC#
    #ACTIONS#