Re: Checking Multiplicity Constraints and Retrieving - Mailing list pgsql-general

From Simon Riggs
Subject Re: Checking Multiplicity Constraints and Retrieving
Date
Msg-id 1129843929.8300.799.camel@localhost.localdomain
Whole thread Raw
In response to Checking Multiplicity Constraints and Retrieving Data from Error Messages  (Ledina Hido <lh1101@ecs.soton.ac.uk>)
List pgsql-general
On Wed, 2005-10-19 at 15:25 +0100, Ledina Hido wrote:

> First of all, is there any way of limiting the number of rows in a
> table, referencing to the same element of another table? For example,
> force a manager not to have more than 10 employees under his control.
> In a way this can be seen as checking the multiplicity of the
> relation between the two tables. I know one way would be using
> triggers, but I was wondering if there was a way of specifying this
> when the table is constructed.

That's a lack of function within the SQL standard and PostgreSQL doesn't
implement that as an extension.

XML Schema allows you to define minoccurs and maxoccurs, but not the
SQL:2003 standard.

It would be very cool if it did, I grant you. You have to do this
yourself via a trigger. Just make sure you create an index on the
columns and you'll be fine - apart from the extra cost of inserting
rows, so keep maxoccurs small.

Best Regards, Simon Riggs


pgsql-general by date:

Previous
From: Richard_D_Levine@raytheon.com
Date:
Subject: Re: [HACKERS] 'a' == 'a '
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] 'a' == 'a '