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 [ Ссылка ]
Learn SQL for free [ Ссылка ]
![](https://s2.save4k.ru/pic/7RImD7miKeg/maxresdefault.jpg)