@@ -414,3 +414,129 @@ Do You Yahoo!?
414414Get your free @yahoo.com address at http://mail.yahoo.com
415415
416416
417+ From pgsql-general-owner+M590@postgresql.org Tue Nov 14 16:30:40 2000
418+ Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28])
419+ by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id RAA22313
420+ for <pgman@candle.pha.pa.us>; Tue, 14 Nov 2000 17:30:39 -0500 (EST)
421+ Received: from mail.postgresql.org (webmail.postgresql.org [216.126.85.28])
422+ by mail.postgresql.org (8.11.1/8.11.1) with SMTP id eAEMSJs66979;
423+ Tue, 14 Nov 2000 17:28:21 -0500 (EST)
424+ (envelope-from pgsql-general-owner+M590@postgresql.org)
425+ Received: from megazone23.bigpanda.com (138.210.6.64.reflexcom.com [64.6.210.138])
426+ by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eAEMREs66800
427+ for <pgsql-general@postgresql.org>; Tue, 14 Nov 2000 17:27:14 -0500 (EST)
428+ (envelope-from sszabo@megazone23.bigpanda.com)
429+ Received: from localhost (sszabo@localhost)
430+ by megazone23.bigpanda.com (8.11.1/8.11.0) with ESMTP id eAEMPpH69059;
431+ Tue, 14 Nov 2000 14:25:51 -0800 (PST)
432+ Date: Tue, 14 Nov 2000 14:25:51 -0800 (PST)
433+ From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
434+ To: "Beth K. Gatewood" <bethg@mbt.washington.edu>
435+ cc: pgsql-general@postgresql.org
436+ Subject: Re: [GENERAL] a request for some experienced input.....
437+ In-Reply-To: <3A11ACA1.E5D847DD@mbt.washington.edu>
438+ Message-ID: <Pine.BSF.4.21.0011141403380.68986-100000@megazone23.bigpanda.com>
439+ MIME-Version: 1.0
440+ Content-Type: TEXT/PLAIN; charset=US-ASCII
441+ Precedence: bulk
442+ Sender: pgsql-general-owner@postgresql.org
443+ Status: OR
444+
445+
446+ On Tue, 14 Nov 2000, Beth K. Gatewood wrote:
447+
448+ > >
449+ >
450+ > Stephan-
451+ >
452+ > Thank you so much for taking the effort to answer this these questions. You
453+ > help is truly appreciated....
454+ >
455+ > I just have a few points for clarification.
456+ >
457+ > >
458+ > > MATCH PARTIAL is a specific match type which describes which rows are
459+ > > considered matching rows for purposes of meeting or failing the
460+ > > constraint. (In match partial, a fktable (NULL, 2) would match a pk
461+ > > table (1,2) as well as a pk table (2,2). It's different from match
462+ > > full in which case (NULL,2) would be invalid or match unspecified
463+ > > in which case it would match due to the existance of the NULL in any
464+ > > case). There are some bizarre implementation details involved with
465+ > > it and it's different from the others in ways that make it difficult.
466+ > > It's in my list of things to do, but I haven't come up with an acceptable
467+ > > mechanism in my head yet.
468+ >
469+ > Does this mean, currently that I can not have foreign keys with null values?
470+
471+ Not exactly...
472+
473+ Match full = In FK row, all columns must be NULL or the value of each
474+ column must not be null and there is a row in the PK table where
475+ each referencing column equals the corresponding referenced
476+ column.
477+
478+ Unspecified = In FK row, at least one column must be NULL or each
479+ referencing column shall be equal to the corresponding referenced
480+ column in some row of the referenced table
481+
482+ Match partial is similar to match full except we ignore the null columns
483+ for purposes of the each referencing column equals bit.
484+
485+ For example:
486+ PK Table Key values: (1,2), (1,3), (3,3)
487+ Attempted FK Table Key values: (1,2), (1,NULL), (5,NULL), (NULL, NULL)
488+ (hopefully I get this right)...
489+ In match full, only the 1st and 4th fk values are valid.
490+ In match partial, the 1st, 2nd, and 4th fk values are valid.
491+ In match unspecified, all the fk values are valid.
492+
493+ The other note is that generally speaking, all three are basically the
494+ same for the single column key. If you're only doing references on one
495+ column, the match type is mostly meaningless.
496+
497+ > > PENDANT adds that for each row of the referenced table the values of
498+ > > the specified column(s) are the same as the values of the specified
499+ > > column(s) in some row of the referencing tables.
500+ >
501+ > I am not sure I know what you mean here.....Are you saying that the value for
502+ > the FK column must match the value for the PK column?
503+
504+ I haven't really looked at PENDANT, the above was just a small rewrite of
505+ some descriptive text in the sql99 draft I have. There's a whole bunch
506+ of rules in the actual text of the referential constraint definition.
507+
508+ The base stuff seems to be: (Rf is the referencing columns, T is the
509+ referenced table)
510+
511+ 3) If PENDANT is specified, then:
512+ a) For a given row in the referencing table, let pendant
513+ reference designate an instance in which all Rf are
514+ non-null.
515+
516+ b) Let number of pendant paths be the number of pendant
517+ references to the same referenced row in a referenced table
518+ from all referencing rows in all base tables.
519+
520+ c) For every row in T, the number of pendant paths is equal to
521+ or greater than 1.
522+
523+ So, I'd read it as every row in T must have at least one referencing row
524+ in some base table.
525+
526+ There are some details about updates and that you can't mix PENDANT and
527+ MATCH PARTIAL or SET DEFAULT actions.
528+
529+ > > The main issues in 7.0 are that older versions (might be fixed in
530+ > > 7.0.3) would fail very badly if you used alter table to rename tables that
531+ > > were referenced in a fk constraint and that you need to give update
532+ > > permission to the referenced table. For the former, 7.1 will (and 7.0.3
533+ > > may) give an elog(ERROR) to you rather than crashing the backend and the
534+ > > latter should be fixed for 7.1 (although you still need to have write
535+ > > perms to the referencing table for referential actions to work properly)
536+ >
537+ > Are the steps to this outlined somewhere then?
538+
539+ The permissions stuff is just a matter of using GRANT and REVOKE to set
540+ the permissions that a user has to a table.
541+
542+
0 commit comments