MySQL Forums
Forum List  »  InnoDB

How to constrain indirect relationships
Posted by: Matt Drees
Date: December 06, 2008 12:36PM

I'm working on a conference registration application.
A simplification of my schema looks like this:

Registrant (
int id,
int profile_id,
int registrant_type_id
)

Registrant_Type (
int id,
int conference_id
)

Conference (
int id
)

Profile (
int id
)

So, Registrants are directly related to Registrant_Types and Profiles, and indirectly related to Conferences (through Registrant_Types).
I want to prevent the existence of two Registrants that share the same Profile and the same Registrant_Type. This is easy enough through a unique index.
However, I also want to prevent the existence of two Registranst that share the same Profile and also share the same Conference. What is the best way to do this?



Edited 1 time(s). Last edit at 12/06/2008 12:37PM by Matt Drees.

Options: ReplyQuote


Subject
Views
Written By
Posted
How to constrain indirect relationships
5148
December 06, 2008 12:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.