+ FOREIGN KEY (vhost,event) REFERENCES events (vhost,event),
+ FOREIGN KEY (vhost,event,render_id) REFERENCES images (vhost,event,id),
+
+ -- Redundant with the primary key, but the foreign key needs it.
+ UNIQUE (vhost,event,id),
+
+ CHECK (NOT (is_render AND (render_id IS NOT NULL)))