473,387 Members | 1,579 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.

XOR and foreign key constraints

I have a situation where attending a meeting could be either staff or
coalition members. But don't know how to enforce a foreign key
constraint. any ideas ?

Table Meeting
MeetingID int NOT NULL,
AttendeeID int NOT NULL
Primary Key (MeetingID, AttendeeID)

Table Staff
StaffID int IDENTITY not null PRIMARY KEY

Table CoalitionMember
MemberID int Identity not null PRIMARY KEY

Since AttendeeID can either a value from Staff.StaffID or from
CoalitionMember.MemberID, I cannot place both constraints as

ADD CONSTRAINT [FK_Meeting_Staff] FOREIGN KEY
(AttendeeID)
REFERENCES [Staff] ([StaffID])

ADD CONSTRAINT [FK_Meeting_CoalitionMember] FOREIGN KEY
(AttendeeID)
REFERENCES [CoalitionMember] ([MemberID])

Dec 8 '05 #1
1 4118
ar******@hotmail.com wrote:
I have a situation where attending a meeting could be either staff or
coalition members. But don't know how to enforce a foreign key
constraint. any ideas ?

Table Meeting
MeetingID int NOT NULL,
AttendeeID int NOT NULL
Primary Key (MeetingID, AttendeeID)

Table Staff
StaffID int IDENTITY not null PRIMARY KEY

Table CoalitionMember
MemberID int Identity not null PRIMARY KEY

Since AttendeeID can either a value from Staff.StaffID or from
CoalitionMember.MemberID, I cannot place both constraints as

ADD CONSTRAINT [FK_Meeting_Staff] FOREIGN KEY
(AttendeeID)
REFERENCES [Staff] ([StaffID])

ADD CONSTRAINT [FK_Meeting_CoalitionMember] FOREIGN KEY
(AttendeeID)
REFERENCES [CoalitionMember] ([MemberID])

Please do not multi-post!
This has been answer in microsoft.public.sqlserver.programming

--
David Portas
SQL Server MVP
--

Dec 8 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: D | last post by:
Database 1 is corrupted. Database 2 was created by dba but none of the primary or foreign key constraints were ported over. TOAD won't let me export. I will try ErWin next. What is the best way...
0
by: John Towell | last post by:
------=_NextPart_000_0008_01C360DD.C2475700 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit We are trying to load a set of data using Hibernate (O/R mapping tool)....
1
by: Jason Madison | last post by:
We sometimes get very large databases that we want to cut down to use for testing. The information is all related to a central accounts table. The way I thought of doing this is to grab all...
0
by: Scott Ribe | last post by:
I've got a problem which I think may be a bug in Postgres, but I wonder if I'm missing something. Two tables, A & B have foreign key relations to each other. A 3rd table C, inherits from A. A...
6
by: Brendan Jurd | last post by:
Hi all, I read on the manual page for Inheritance that: "A limitation of the inheritance feature is that indexes (including unique constraints) and foreign key constraints only apply to single...
13
by: Bob Stearns | last post by:
Why is the following constraint invalid? I want to make sure that every row in IS3.ANIMALS_PRIV_INDEXES matches one of those in IS3.table_var_defn with part of the primary key fixed. Since this is...
0
by: Rajesh Tiwari | last post by:
Hi Group, i have a foreign key in a table in sql server.i am using a dataset and populating it with the contents of this table.my problem is that i am not able to access the foreign key that i...
8
by: wespvp | last post by:
I am using PostgreSQL 7.4.1 on RedHat 7.2. The query I am executing is something like (I replaced all the return values with 'count'): db=> explain select count(*) from messages m join (select...
0
by: okonita | last post by:
DB2v8.2 LUW. Unable to drop Foreign Key constraints...although DROP constraints returns undefined name. Am I missing somrthing here? Hi all, I have a perplexing DB2 Drop command situation....
4
by: Bobby Edward | last post by:
I have an xsd dataset. I created a simple query called GetDataByUserId. I can preview the data fine! I created a very simple BLL function that calls it and returns a datatable. When I run...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.