Generic trigger to restrict insertions based on count
问题 Background In a PostgreSQL 9.0 database, there are various tables that have many-to-many relationships. The number of those relationships must be restricted. A couple of example tables include: CREATE TABLE authentication ( id bigserial NOT NULL, -- Primary key cookie character varying(64) NOT NULL, -- Authenticates the user with a cookie ip_address character varying(40) NOT NULL -- Device IP address (IPv6-friendly) ) CREATE TABLE tag_comment ( id bigserial NOT NULL, -- Primary key comment_id