SQLite Forum

cycle detection in CHECK constraint with recursive CTE
Thank you, you're completely right, this is the appropriate approach for what you suggest. However, I wanted multiple parents in my setup (many-to-many relationship).

As for the schema itself, it was generated by django ORM. Perhaps in the future I can replace it with a handcrafted one.