PostgreSQL

745 readers
2 users here now

The world's most advanced open source relational database

Project
Events
Podcasts
Related Fediverse communities

founded 2 years ago
MODERATORS
51
52
 
 

Example flow is on the image. Here I want to accomplish if playlist removed, make it delete image too.

I know I should've put FK on image table but Image is generic and its used more than once.

What are my options? Triggers and application-side comes to mind, but I'm not sure. Maybe there is a better way.

UPDATE: I guess I've found what I was looking for, rules:

CREATE RULE playlist_delete AS ON DELETE TO playlist WHERE (SELECT id FROM image WHERE image.id = OLD.image_id) IS NOT NULL DO INSTEAD NOTHING;

53
54
55
56
57
58
59
60
9
Postgres Guide: Cache (www.postgresguide.com)
submitted 1 year ago by lysdexic to c/postgresql
61
62
63
64
65
66
67
68
69
70
 
 

I understand that there are times with critical issues and outages when DBA are to work until all is fixed, which may take up to 20 hours.

But if things are stable and settled, out of a standard 8-9-hour work day, how many hours are actually needed to finish daily routine work?

71
72
73
74
75
 
 

pg-safeupdate is a PostgreSQL extension designed to prevent users from accidentally updating or deleting too many records in a single statement by requiring a "where" clause in all update and delete statements.

view more: ‹ prev next ›