in

The ORM Foundation

Get the facts!

Exclusion constraint

Last post Wed, Jan 12 2011 9:06 by oliver. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • Sun, Jan 2 2011 7:43

    • oliver
    • Top 75 Contributor
      Male
    • Joined on Sun, Feb 1 2009
    • Belgrade, Serbia
    • Posts 9

    Exclusion constraint

    Hi,

     When I add Exclusion constraint on diagram I expect that NORMA generate some code behind, for example: 

    alter table Employee add constraint Employee _excl check

    ( (ParkingSpaceID is null) or

    (ExpenseID is null) )

    go

    alter table Employee add constraint Employee_MR check

    ( (ParkingSpaceID is not null) or

    (ExpenseID is not null) )

     But in SQL generated code I don't find what I expected. Why?

     



     

     

     


  • Sun, Jan 2 2011 12:38 In reply to

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

    Re: Exclusion constraint

    Hello Oliver,

    I changed your model slightly by putting an "." in front of "empNr" - (see the red arrow in the diagram) and by adding data type values in the properties window (F4)

    The diagram shows the relational table and SQL for SQL Server.

    How does this compare with your output?

    Ken


  • Mon, Jan 10 2011 9:41 In reply to

    • oliver
    • Top 75 Contributor
      Male
    • Joined on Sun, Feb 1 2009
    • Belgrade, Serbia
    • Posts 9

    Re: Exclusion constraint

    Hi Ken,

     Thank you for your answer.

     I create model like yours but I don't have same result. This is what I get.

     

    Lets asume that I get same result.

    Verbalisation of ExclusionConstraint is:

    For each Employee, at most one of the following holds:
    that Employee is allocated some ParkingSpace;
    that Employee claims parking some Expense.
     
    So, one employe is alocated some ParkingSpace or claims parking.
     
    I create table in SQL, then I insert row and as you see Employee is allocated some ParkingSpace and claims parking.
     
     
    Now I must generate some code.
     
     
     

     


  • Mon, Jan 10 2011 18:50 In reply to

    Re: Exclusion constraint

    Oliver,

    This is really a question for Matt, but I think I know the answer. Not all ORM2 constraints are yet rendered into SQL. This type of constraint seems to be one of those that are missed.

    On another note, if you add a hyphen in the parking expense reading "Employee claims parking- Expense", you get better verbalisation:

    For each Employee, at most one of the following holds:
    that Employee is allocated some ParkingSpace;
    that Employee claims some parking Expense.
  • Wed, Jan 12 2011 9:06 In reply to

    • oliver
    • Top 75 Contributor
      Male
    • Joined on Sun, Feb 1 2009
    • Belgrade, Serbia
    • Posts 9

    Re: Exclusion constraint

    Sad

Page 1 of 1 (5 items)
© 2008-2018 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service