Subject: Foreign keys and the rule system

From: Soren Larsen <[email-masked]>
Date: Sat, 21 Nov 92 15:59:22 GMT

We have created two classes X and Y by

	create X(k=int2, a=char16)
	create Y(p=int2, q=int2)

where k and p are primary keys.  Furthermore, we want q to act as a
foreign key, such that tuples may not be added to Y unless an X object
exists with X.k=Y.q.
Question: can this integrity constraint be enforced using the rule
system?  We have tried:

define rewrite rule FK is on append to Y
	where count{X.k where X.k=new.q} = 0
	do instead nothing

but we are told that there is a syntax error at or near "{".
Is there another way?

-- 
Soren Larsen / [email-masked]
Dept. of Math. & Computer Science, Odense University
Campusvej 55, DK-5230 Odense M, Denmark
phone: +45 66 15 86 00, ext. 2312 / telefax: +45 65 93 26 91