in

The ORM Foundation

Get the facts!

Simple exclusion constraint and Exclusive or constraint

Last post Tue, Sep 8 2015 6:16 by Ken Evans. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • Tue, Sep 1 2015 4:46

    • emcuevas
    • Top 75 Contributor
    • Joined on Tue, Aug 25 2015
    • Posts 9

    Simple exclusion constraint and Exclusive or constraint

    Hi,

     

    I badly need some help in telling the difference between these two constraints. I have read lots of notes about these constraints. But I barely understood it. All I know is that in Simple Exclusion Constraint, if an Entity A use Role1 then it cant use Role2. However, in Exclusive-or constraint, Entity A can use Role1 or Role2,but not both. I cant see the difference here.

     

    Please help me. If you are kind to show some ORM-examples With table representations.

     

    Thank you very much in advance! 

  • Tue, Sep 1 2015 6:00 In reply to

    Re: Simple exclusion constraint and Exclusive or constraint

    Hi,

    A word of explanation: In some situations, those constraints do act the same: The Simple Exclusion, attached to Roles 1 and 2, will have less force than the Exclusive-Or constraint ONLY IF either the entity type (A) is independent, OR that entity type has other roles besides 1 and 2.

    For only if at least one of those things is true, can you possibly have an object (call it "a1") of Entity Type A, in the population of the model, WITHOUT a1 playing either Role 1 or Role 2. And forbidding that latter situation is all that the Exclusive-Or does in addition to what the Simple Exclusion does.

    Hope that helps. If it doesn't, please follow up. 

    Regards,

    Andy 

  • Tue, Sep 1 2015 14:54 In reply to

    Re: Simple exclusion constraint and Exclusive or constraint

     As a follow-up to Andy's excellent explanation, the characterization of an exclusive-or constraint in "However, in Exclusive-or constraint, Entity A can use Role1 or Role2,but not both. I cant see the difference here." should have used "must" instead of "can".

      An exclusive-or constraint combines an inclusive-or constraint with a simple exclusion constraint. In ORM, unless an object type is declared independent, a mandatory role constraint is implicitly understood to apply to the disjunction of its roles. Consider a model with just the following fact types:

     Person(.Name) is a parent of Person.

     Person smokes.  

     Since Person is not declared independent, there is an implied inclusive-or constraint spanning the smokes role and the two roles in the parenthood fact type. Now add an inclusive-or constraint between the two roles in the parenthood relationship, but leave the smokes role optional. We have now declared that each person must either be a parent of someone or have someone as a parent. It would typically be wrong to strengthen the inclusive-or constraint to an exclusive-or constraint, because the additional exclusion constraint would forbid someone from having both a parent and a child.

    Cheers

    Terry 

  • Tue, Sep 1 2015 15:31 In reply to

    • emcuevas
    • Top 75 Contributor
    • Joined on Tue, Aug 25 2015
    • Posts 9

    Re: Simple exclusion constraint and Exclusive or constraint

     It is really hard to gather the information with just reading. Or is it just me? Im sorry. I need to see some examples to see the difference. Maybe by using a simple representation of table that relates to either xor constraint or exclusion.

     

    Thanks for the help by the way. Really appreciate it.  

  • Tue, Sep 1 2015 15:43 In reply to

    • emcuevas
    • Top 75 Contributor
    • Joined on Tue, Aug 25 2015
    • Posts 9

    Re: Simple exclusion constraint and Exclusive or constraint

    I really really appreciate that you have replied to my question. You are the author of the book we use in school. Im so psyched. But, unfortunately , for me it is only words. I got some points, but I am more of a visual person. Im really sorry for the inconvinience. But, I really really need to understand the difference between the two. On the book we use, I have seen some examples of simple exclusion + the table which represents the diagram drawn. But, for xor constraint i havent seen one table representation of a diagram. I used up hours searching for some tables to help me understand more, but, I didnt find anything.

     

    Simple exclusion would be like: (If role1(wrote) and role2(reviewed) has a simple exclusion constraint), am I correct?

    Person Wrote Reviewed 

    T.Halpin ORM ---------

    P.Burg ---------- WORLD 

    T.Halpin ---------- WORLD

     

    The last set would be wrong right, assuming I have a 1:many constraint over role1 and role2,?

     

     

    I have nothing for Xor Constraint.. :( 

  • Tue, Sep 1 2015 16:29 In reply to

    Re: Simple exclusion constraint and Exclusive or constraint

     Your wrote and reviewed examples sounds like two binary fact types: Person wrote Book; Person reviewed Book. There would be a pair-exclusion constraint between these fact types, so no person can write and review the same book. In this case, each argument of the exclusion constraint is a (Person, Book) role pair.

      An exclusive-or constraint can apply only between single roles, not role pairs. It is a combination of an inclusive-or constraint between single roles and an exclusion constraint between those same roles.

    As a very simple example, each person is either male or female. You could model this with two unary fact types (Person is male; Person is female) with an exclusive-or constraint between the two roles. Consider the population

      Terry is male.

       Norma is female.

     If you mapped this to a relational table under the closed world assumption you would get 

      Person (name,  isMale, isFemale)

                   Terry     true      false

                    Norma  false     true

     The exclusion constraint within the exclusive-or constraint ensures that we can't assert a person to be both male and female, so the following row would not be allowed

                    Fred     true      true

     Hope this helps

    Terry 

     

  • Tue, Sep 1 2015 17:33 In reply to

    Re: Simple exclusion constraint and Exclusive or constraint

    Trying these constraints in the NORMA tool on your own model can also be very instructive. You can practice using them against a domain you're familiar with, look at the verbalizations, try different constraint patterns, etc.

    I believe part of the confusion here is that an Xor constraint is two constraints, the inclusive-or and the exclusion. You can see these separated in NORMA by right-clicking on the xor constraint shape and choosing 'Split Exclusive Or Constraint'. You can then look at the verbalization and undo, or select both shapes and choose 'Combine as Exclusive Or Constraint' to put them back together.

    -Matt 

  • Tue, Sep 1 2015 22:36 In reply to

    • jacobvos
    • Top 25 Contributor
      Male
    • Joined on Mon, Jan 21 2013
    • The Netherlands
    • Posts 39

    Re: Simple exclusion constraint and Exclusive or constraint

    See below for a graphical answer. I hope it's clear.

    - Jacob


  • Tue, Sep 1 2015 23:48 In reply to

    • emcuevas
    • Top 75 Contributor
    • Joined on Tue, Aug 25 2015
    • Posts 9

    Re: Simple exclusion constraint and Exclusive or constraint

     First of all thank you very much. Just to clear it off. 

     

    The difference between exclusion and xor is that exclusion doesnt necessarily need an Entity to do role , but xor constraint must have at least one of the roles? 

  • Tue, Sep 1 2015 23:49 In reply to

    • emcuevas
    • Top 75 Contributor
    • Joined on Tue, Aug 25 2015
    • Posts 9

    Re: Simple exclusion constraint and Exclusive or constraint

     Thanks for the tip. Downloading Visual Studio right now to use NORMA

  • Tue, Sep 1 2015 23:50 In reply to

    • emcuevas
    • Top 75 Contributor
    • Joined on Tue, Aug 25 2015
    • Posts 9

    Re: Simple exclusion constraint and Exclusive or constraint

     You have no idea how happy I am to be able to talk to you. Right now were on the topic of relational modelling. Anyway, thanks for the great help. Really got me relieved a lot. 

  • Tue, Sep 8 2015 6:16 In reply to

    • Ken Evans
    • Top 10 Contributor
      Male
    • Joined on Sun, Nov 18 2007
    • Stickford, UK
    • Posts 805

    Re: Simple exclusion constraint and Exclusive or constraint

    Just to clarify this point. The concepts of OR and XOR are from logic.
    In the diagram, the blue rectangles represent "True" (i.e. "This is an A" or "This is a B")
    The red rectangles represent "False".
    This makes it clear that the XOR of two items means that only one of the items may be present.
    As the diagram shows, the only difference between XOR and OR is in the top row.

    Ken

     


Page 1 of 1 (12 items)
© 2008-2024 ------- Terms of Service