Discussion Locked

MS Access97 referential integrity

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to use complex foreign key, some
fields of this is not required. Simplified
example showed below (in real database values of required fields defines by another foreign key)

CREATE TABLE A
(F1 TEXT(3) NOT NULL,
F2 TEXT(3) NOT NULL, INFO TEXT(32) NOT NULL,
CONSTRAINT PK PRIMARY KEY (F1,F2));

CREATE TABLE B
(F1 TEXT(3) NOT NULL,
F2 TEXT(3) NULL,
INFO TEXT(32) NULL,
CONSTRAINT FK FOREIGN KEY (F1,F2) REFERENCES A(F1,F2));

In MS Access 97 I can't insert into table B
values ('001',NULL,'INFO') - error 3201 generated. In MS Access 2.0 such insert is
allowed. Can I tune MS Access 97 to allow this input - Thank you.

2 replies

by bill_h

To make this work, you have to either allow field F2 in table A to be NULL, or disallow NULL values in table B, field F2.

The specified foreign key for table B specifies that the values entered in fields F1 and F2 MUST have a corresponding matching pair in table A. By allowing table B, field F2 to be NULL, you are permitting entries that will never be matched to table A.

by avhohlov

I test this code in ORACLE DBMS and it work correctly. Is Access97 incompatible with Access 2.0 or exist way of tuning?

This discussion is closed to new replies.