0

During the preparation of my relational model, I'm stuck at the translation of a type constraint {XOR}.

Here's an example: I have a file that is equivalent credit by an applicant (a user) and it is also validated by a validator (another user) but there is an exclusion constraint the applicant may not be the validator to the same folder.

How I can translate it at my table?

Dossier_Equi (num_dosier, # applicant # validator ......)

enter image description here

Javier
  • 12,100
  • 5
  • 46
  • 57
Feres_F
  • 13
  • 6

1 Answers1

1

First, note that it is not a type constraint (i.e. a constraint between two classifiers) but an association constraint. Then, note that the xor constraint specifies that objects of a class may participate in, at most, one of the associations at a time.

Constraint:

The applicant must not be the validator.

The SQL equivalent would be:

CHECK (validator IS NULL OR applicant<>validator) 

(as a table constraint, since it applies to different columns).

However, MySQL does not support SQL check constraints. In another question, there is a suggerence for using BEFORE INSERT/UPDATE triggers for that purpose.

Community
  • 1
  • 1
Javier
  • 12,100
  • 5
  • 46
  • 57