A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

alternative/mutually exclusive foreign keys



 
 
Thread Tools Display Modes
  #1  
Old March 24th, 2005, 07:49 AM
Julian Fowler
external usenet poster
 
Posts: n/a
Default alternative/mutually exclusive foreign keys

Part of a database I'm working on has three tables: City, State,
Country. For cities in the US I want to have a reference from City to
State (stateRef in the City table linked as foreign key to stateId in
State), whereas for cities in other countries I want to have a
reference from City to Country (countryRef linked as foreign key to
countryId in Country).

OK so far ... however, I want to be able to validate during data entry
that a City has a reference to a State *or* (exclusive) a reference to
a Country (i.e., that if stateRef is null, countryRef must not be
null, and vice versa). Any suggestions on how to accomplish this?

Julian

--
Julian Fowler
julian (at) bellevue-barn (dot) org (dot) uk
  #2  
Old March 24th, 2005, 01:53 PM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

Julian

Seems like that would be easily handled in a form's BeforeUpdate event. You
ARE using forms for data entry, right?!

--
Good luck

Jeff Boyce
Access MVP

"Julian Fowler" wrote in message
...
Part of a database I'm working on has three tables: City, State,
Country. For cities in the US I want to have a reference from City to
State (stateRef in the City table linked as foreign key to stateId in
State), whereas for cities in other countries I want to have a
reference from City to Country (countryRef linked as foreign key to
countryId in Country).

OK so far ... however, I want to be able to validate during data entry
that a City has a reference to a State *or* (exclusive) a reference to
a Country (i.e., that if stateRef is null, countryRef must not be
null, and vice versa). Any suggestions on how to accomplish this?

Julian

--
Julian Fowler
julian (at) bellevue-barn (dot) org (dot) uk


  #3  
Old March 24th, 2005, 03:10 PM
Julian Fowler
external usenet poster
 
Posts: n/a
Default

On Thu, 24 Mar 2005 05:53:23 -0800, "Jeff Boyce"
-DISCARD_HYPHEN_TO_END wrote:

Julian

Seems like that would be easily handled in a form's BeforeUpdate event. You
ARE using forms for data entry, right?!


Of course :-) Events does seem an obvous way to go, although I was
hoping for something inherent in the definition of the
tables/relationships that would then apply in any relevant form.

Julian

--
Julian Fowler
julian (at) bellevue-barn (dot) org (dot) uk
  #4  
Old March 25th, 2005, 01:49 AM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default

Julian

It may be feasible to create a single validation rule to apply to the entire
table, but once you've used it for THIS situation, you won't get to create
any others. This is true of the Access/JET database, but not so for a
SQL-Server back-end.

I'd probably still go with the form events...

--
Good luck

Jeff Boyce
Access MVP

"Julian Fowler" wrote in message
...
On Thu, 24 Mar 2005 05:53:23 -0800, "Jeff Boyce"
-DISCARD_HYPHEN_TO_END wrote:

Julian

Seems like that would be easily handled in a form's BeforeUpdate event.

You
ARE using forms for data entry, right?!


Of course :-) Events does seem an obvous way to go, although I was
hoping for something inherent in the definition of the
tables/relationships that would then apply in any relevant form.

Julian

--
Julian Fowler
julian (at) bellevue-barn (dot) org (dot) uk


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Normalization and foreign keys Tina Database Design 1 February 17th, 2005 08:50 PM
Edit foreign keys jma Running & Setting Up Queries 0 December 3rd, 2004 06:57 AM
Establishing Relationships with ID numbers as foreign keys lybargera Database Design 2 June 16th, 2004 07:30 PM
Choosing Primary and Foreign Keys A.V.H New Users 8 May 23rd, 2004 09:12 PM
Autonumber foreign keys and subforms Ed Havelaar Database Design 3 May 12th, 2004 07:34 AM


All times are GMT +1. The time now is 04:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.