Postgres value that never goes below zero
You can do this with BEFORE INSERT and BEFORE UPDATE triggers. Here is a tutorial.

These triggers can access the row being inserted (or the updated value) in the NEW variable. Do not use an UPDATE statement to change the row! Simply change the NEW variable, have the trigger function RETURN NEW, and the values will be used in the INSERT/UPDATE that fired the trigger. This only works in BEFORE triggers. AFTER INSERT/UPDATE cannot modify values since the operation is already done.

Code would look like this:

CREATE OR REPLACE FUNCTION mytrigger() RETURNS TRIGGER AS $example_table$
   BEGIN
      IF NEW.yourcolumn &lt; 0 THEN NEW.yourcolumn := 0 END
      RETURN NEW;
   END;
$example_table$ LANGUAGE plpgsql;


Then use the CREATE TRIGGER command as mentioned in the tutorial.