in

The ORM Foundation

Get the facts!

Exclusion constraint

Last post 01-12-2011 9:06 by oliver. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 01-02-2011 7:43

    • oliver
    • Top 50 Contributor
      Male
    • Joined on 01-31-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?

     



     

     

     


    Oliver
  • 01-02-2011 12:38 In reply to

    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


  • 01-10-2011 9:41 In reply to

    • oliver
    • Top 50 Contributor
      Male
    • Joined on 01-31-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.
     
     
     

     


    Oliver
  • 01-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.
  • 01-12-2011 9:06 In reply to

    • oliver
    • Top 50 Contributor
      Male
    • Joined on 01-31-2009
    • Belgrade, Serbia
    • Posts 9

    Re: Exclusion constraint

    Sad

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