Received: from parmastocks2.cylink.com.cy (parmastocks2.cylink.com.cy [194.42.142.6]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f6PHoUf54033 for ; Wed, 25 Jul 2001 13:50:30 -0400 (EDT) (envelope-from grigoriy.vovk@linustech.com.cy) Received: from [192.168.1.2] (parmastocks.cylink.com.cy [194.42.135.92]) by parmastocks2.cylink.com.cy (Postfix) with ESMTP id 8A5B93407C; Wed, 25 Jul 2001 20:48:24 +0300 (EEST) Date: Wed, 25 Jul 2001 20:49:13 +0300 (EEST) From: "Grigoriy G. Vovk" X-X-Sender: To: Josh Berkus Cc: Renato De Giovanni , Subject: Re: Meta integrity In-Reply-To: Message-ID: <20010725204642.Q750-100000@callisto.internal.linustech.com.cy> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200107/345 X-Sequence-Number: 4159 Yes, its not a task for _relation_ dbms. I am database developer, I like rdbms, but now I think that I should start to use LDAP for these kind of tasks. What people can say? Jul 25, 08:22 -0700, Josh Berkus wrote: > Renato, > > > ...will only guarantee that each attribute points to an existent > > object > > but it will not care about the object's class. Question is: how could > > I > > also enforce this kind of "meta integrity"? The following table > > definition came to my mind, but its an illegal construction: > > > > CREATE TABLE specific_attribute ( > > id INTEGER NOT NULL, > > value TEXT NOT NULL, > > object_id INTEGER NOT NULL, > > PRIMARY KEY (id), > > FOREIGN KEY (object_id, 'X') REFERENCES object (id, class_id) > > ); > > This is a fairly common problem that has no solution using REFERENCES, > either in Postgres or in SQL 99. You basically have two choices: > > 1. The rigorous -- write your own Triggers and Constraints to enforce > this kind of integrity, including INSERT, UPDATE, and DELETE triggers on > the various tables. Between postgresql.org and Roberto Mello's sight, > there's quite a bit of material on triggers. > > 2. The simple -- write functions to perform inserts, updates and deletes > on these tables. Put the relation into those functions, and make users > use those functions instead of direct SQL command access. > > I took the second approach to solve a similar problem, because I had > quite a number of other business rules I needed to apply, and adding the > special relationship rule was only one more. > > -Josh > > > > ______AGLIO DATABASE SOLUTIONS___________________________ > Josh Berkus > Complete information technology josh@agliodbs.com > and data management solutions (415) 565-7293 > for law firms, small businesses fax 621-2533 > and non-profit organizations. San Francisco > my best regards, ---------------- Grigoriy G. Vovk