Microsoft Developer Network > 포럼 홈 > Microsoft SQL Server Modeling > Understanding HasExtentName / Mixin / Inheritance
질문하기질문하기
 

답변됨Understanding HasExtentName / Mixin / Inheritance

  • 2009년 6월 4일 목요일 오후 12:08slyVx 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    In the Models\Repository\System directory there is a type called HasExtentName:

    module System
    {
        export HasExtentName;   

        // Mixin used to include an extent name field in the root extent of a vertical partition
        // when implementing a generalization hierarchy that allows only single parenting.        
        type HasExtentName
        {
            ExtentName: Text;
        }   
       
    }

    It seems like this pattern was used for example in Microsoft.Samples.Process.Activities where each activity has an ExtentName referencing a database of its particular subtype (e.g. UserTasks, Decisions...).

    Now I wonder how you would implement this Mixin pattern and how it actually differs from the inheritance pattern using a discriminator field (as shown here: http://blogs.msdn.com/dave_langer/archive/2009/06/02/modeling-inheritance-in-oslo-s-m.aspx, Table per Concrete Class ). Intuitively, I would say, you use "ExtenName" as a discriminator field, but then again I would end up defining constraints for the allowed subtypes (UserTasks, Decisions,...).

    Could you provide a simple example (MSchema and MGraph) how to apply the "HasExtentName" (maybe you could stick to the example provided in the article above: Department has different kinds of Employees) ?

답변

  • 2009년 6월 12일 금요일 오후 5:16Bill Gibson MSFTMSFT사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    Sorry this has taken so long!

    The type System.HasExtentName is a hangover from an earlier approach to modeling generalization and was intended to be used as you surmised.  That pattern has been dropped in favor of other approaches that have broader use -- the extent name pattern arose from consideration of just one of the implementation patterns - extent/table-per-type - and had many limitations.  We will be removing HasExtentName in the next drop so I suggest you pretend it was never there!  Modeling generalization is an important scenario for us and is hugely important in our UML model, where you can already see some evidence of some of the patterns we're using.  Stay tuned for more on this topic soon!  

    Bill    

모든 응답

  • 2009년 6월 6일 토요일 오전 3:36Kraig BrockschmidtMSFT, 중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Just a quick note--I'll find someone to answer this for you on Monday. Have a great weekend and thanks for all your provocative posts this last week!

    .Kraig

  • 2009년 6월 6일 토요일 오후 3:54slyVx 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Thanks Kraig. And thank you for taking time to answer all these questions.
  • 2009년 6월 12일 금요일 오후 3:25Kraig BrockschmidtMSFT, 중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Someone should be getting back to you shortly. Sorry it's taking so long.

  • 2009년 6월 12일 금요일 오후 5:16Bill Gibson MSFTMSFT사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    Sorry this has taken so long!

    The type System.HasExtentName is a hangover from an earlier approach to modeling generalization and was intended to be used as you surmised.  That pattern has been dropped in favor of other approaches that have broader use -- the extent name pattern arose from consideration of just one of the implementation patterns - extent/table-per-type - and had many limitations.  We will be removing HasExtentName in the next drop so I suggest you pretend it was never there!  Modeling generalization is an important scenario for us and is hugely important in our UML model, where you can already see some evidence of some of the patterns we're using.  Stay tuned for more on this topic soon!  

    Bill    

  • 2009년 6월 14일 일요일 오후 4:34slyVx 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Ok, thank you for clearing that up.

    I stay tuned ;)
  • 2009년 7월 1일 수요일 오전 11:28slyVx 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Hello,

    I've got a further question about the implementation of the inheritance pattern discussed here. (Even though you said it will be dropped in future versions, I still consider it as the best approach at the moment ).

    This time it's not about the extent name issue. I'm interesting in the way you model the child class in terms of Primary Key, Foreign Key, and unique constraint.

    Let me explain it: So far I know three different ways to model the child class (see below). All three versions work fine for me.

    Do you see any advantages/disadvantages for any of these versions, in terms of both "M" and SQL considerations?


    // Version 1 (PK = FK), based on Shawn Wildermuth's version (http://wildermuth.com/2008/11/08/MSchema_and_Decorator_Tables)
    module Demo
    {
        type Person
        {
            name : Text;
            ID   : Integer32 => AutoNumber();
        } where identity ID;
       
        type Employee
        {
            jobTitle : Text;
            person   : Person;
        } where identity (person), value .person in Persons;
       
        Employees : Employee*;
        Persons : Person*; 
    }


    // Version 2 (PK, FK = UNIQUE), based on the [Microsoft.Samples.Processes.Process] models
    module Demo
    {
        type Person
        {
            name : Text;
            ID   : Integer32 => AutoNumber();
        } where identity ID;
       
        type Employee
        {
            person   : Person;
            jobTitle : Text;
            employeeID : Integer32 => AutoNumber();
        } where identity (employeeID), unique (person), value .person in Persons;
       
        Employees : Employee*;
        Persons : Person*;
    }


    // Version 3 (compound FK, PK), my own version
    module Tests.EmployeeInheritance
    {
        type Person
        {
            name : Text;
            ID   : Integer32 => AutoNumber();
        } where identity ID;
       
        type Employee
        {
            jobTitle : Text;
            person   : Person;
            employeeID : Integer32 => AutoNumber();
        } where identity (person, employeeID), value .person in Persons;
       
        Employees : Employee*;
        Persons : Person*; 
    }