473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

null value in compound foreign key with referential integrity enforced raises error

Microsoft Access 2007
No forms are involved.

I am trying to enforce referential integrity between two tables, but only if there is a non-null value in one of the foreign fields of a compound index. I am not having any success.

Tables 1 and 2 are related such that each record in table 2 is related to some record in table 1. Table 3 is the table with the issue. All records in table 3 must be related to a record in table 1 but need not be related to a record in table 2 unless the opCode field is Not Null. The problem seems to be that unless all of fields in the foreign key for table 3 are Null then they are collectively evaluated against table 2.

Is there any way around this?

Table 1
locNum (Primary Key)
locCode (Primary Key)
locDesc

Table 2
locNum (Primary Key)
locCode (Primary Key)
subLocCode (Primary Key)
subLocDesc

Table 3
recId (Primary Key)
locNum (Required)
locCode (Required)
subLocCode (Not Required, no default value)
recDesc

thanks,

Paul
Apr 29 '10 #1
0 1214

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Bodza Bodza | last post by:
I'm having an argument with an incumbent self-taught programmer that it is OK to use null foreign keys in database design. My take is the whole point of a foreign key is that it's not supposed...
19
by: Baldur Norddahl | last post by:
Hi, How come "X=null" is not the same as "X is null"? I got a few selects with queries like this: select * from foo where customer=#customer# or (#customer# is null and customer is null) ...
0
by: Steve | last post by:
In AccessXP in Access2000 mode --- TblCustomer: CustomerID, CustomerName TblOrder: OrderID, CustomerID, OrderDate TblOrderDetail: OrderDetailID, OrderID, Detail Appropriate...
0
by: Steve | last post by:
For all who might have read my previous posts ---- AccessXP in 2000 mode and I presume in 2002 mode has a bug you might not know about. If you try and delete a record in a subform where...
2
by: Kostas | last post by:
I ve been told from Allen and others that when enforcing referential integrity Access creates a hidden index for the foreign key, therefore, I do not need to re-index it myself. However, I...
10
by: Shawn Chisholm | last post by:
Hi, I am trying to deal with a deadlock situation caused by foreign key references on insert and I was wondering if anyone knows what order the foreign keys are locked (or evaluated) in for a...
7
by: am72de | last post by:
Hi all, I've posted this problem some weeks ago, but noone had a solution. Perhaps now someone could help me. I have the following tables: Create Table T1 ( ID1 int Not Null , ID2 int Not...
3
by: moskie | last post by:
Is there a way to run an alter table statement that adds a constraint for a foreign key, but does *not* check the existing data for refrential integrity? I'm essentially looking for the equivalent...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
11
by: abhishek chauhan | last post by:
I am developing a software on inventory with ms-access 2003 as backend and vb 6.0 as front end. There are two tables named Supplier(SupplierID, Name, Address, Phone NO) and Item(ItemCode, ItemName,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.