How to write a constraint concerning a max number of rows in postgresql?

Quassnoi is right; a trigger would be the best way to achieve this. Here’s the code: CREATE OR REPLACE FUNCTION enforce_photo_count() RETURNS trigger AS $$ DECLARE max_photo_count INTEGER := 10; photo_count INTEGER := 0; must_check BOOLEAN := false; BEGIN IF TG_OP = ‘INSERT’ THEN must_check := true; END IF; IF TG_OP = ‘UPDATE’ THEN IF … Read more

Solution for overloaded operator constraint in .NET generics

There is no immediate answer; operators are static, and cannot be expressed in constraints – and the existing primatives don’t implement any specific interface (contrast to IComparable[<T>] which can be used to emulate greater-than / less-than). However; if you just want it to work, then in .NET 3.5 there are some options… I have put … Read more