Referential Integrity. 
Author Message
 Referential Integrity.

Quote:

> Hi All,

> After yesterday's disaster I've taken this opportunity to rebuild by
> database from the ground up. As part of this I want to be able to set a
> column to have a default of 0 (easy enough) but this column is a Foreign
> Key to another table whos referenced column value starts at 1.

> Is there anyway I can write a FK Constraint that will allow this? I don't
> want to have to enter a row in the referenced table since since it in turn
> has not null constraints on it.

> I really want a way to allow 0 as a legitimate value, to assist in the
> predicates of a SELECT. It is possible to get to and modify the code that
> PostgreSQL creates to enforce this I assume via CREATE CONSTRAINT TRIGGER?

You could make a copy of the trigger functions in
backend/utils/adt/ri_triggers.c and change them to do what you want.  I'm
assume that NULL in the foreign key table in unacceptable since a NULL
referencing column always works.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.***.com/



Sat, 06 Nov 2004 01:03:10 GMT
 
 [ 1 post ] 

 Relevant Pages 

1. Declarative Referential Integrity and SQL 7

2. enforcing referential integrity

3. Referential integrity between DB's

4. Best practice use of lookup tables and referential integrity

5. Help: Transaction with insert many record failed in referential integrity

6. Append Query to two tables (referential integrity problem)

7. Referential integrity helps the optimizer

8. Should I have to enforce referential integrity if I use Instead of Insert Trigge

9. Referential integrity on commit in SQL 2000?

10. setting referential integrity in sql 7.0

11. Referential integrity error trapping problem with OLEDB and ADO

12. Referential integrity between DB's


 
Powered by phpBB® Forum Software