sql code for UML composition relation - anyone?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fireball

    sql code for UML composition relation - anyone?

    hi, I got confused for a moment about creating data structure for UML
    composition (strong aggregation) relation one-to-many.

    I used Rose/DataModeler to do so.
    [Parent] <filled_diamond >-------- [Child]

    I got P/FK (primary key of my component is foreign key of it's container) in
    my child table:

    Parent: PK Parent_ID
    Child: P/FK Parent_ID

    that way I found out I got relation 1:1, I'm still not sure how to create
    data structure realizing compositiona one-to-many.


  • AlterEgo

    #2
    Re: sql code for UML composition relation - anyone?

    fireball,

    It looks to me like your model is defining a 1:n structure, not 1:1.

    ParentTable
    ------------
    ParentID (PK)

    ChildTable
    ------------
    ChildID (PK)
    ParentID (FK)

    ChildTable data example
    --------------
    ChildID, ParentID
    1, 100
    2, 100
    3, 100

    In this scenario, you can have one Parent (100) for many Children (1,2,3).
    To implement this physically, just make sure you have a ParentID column in
    the ChildTable that references the ParentTable.

    Is that the question you were asking?

    -- Bill

    "fireball" <fireball@onet. kropka.euwrote in message
    news:eoqnag$3ka $1@nemesis.news .tpi.pl...
    hi, I got confused for a moment about creating data structure for UML
    composition (strong aggregation) relation one-to-many.
    >
    I used Rose/DataModeler to do so.
    [Parent] <filled_diamond >-------- [Child]
    >
    I got P/FK (primary key of my component is foreign key of it's container)
    in my child table:
    >
    Parent: PK Parent_ID
    Child: P/FK Parent_ID
    >
    that way I found out I got relation 1:1, I'm still not sure how to create
    data structure realizing compositiona one-to-many.
    >
    >

    Comment

    • fireball

      #3
      Re: sql code for UML composition relation - anyone?

      Bill thx for your time!

      Your example looks like aggregation 1:many, that's correct - but the problem
      is I need to create _strong_ aggregation (=composition) 1:many,
      distinguishing from simple (weak) aggregation, your example seem to realize:

      So I created two relations in my Rose:
      a) aggregation (empty diamond) 1..*
      b) composition (filled diamond( 1..*
      and then I transformed it to data mode: And what I got?

      a)
      ParentTable
      ------------
      ParentID (PK)

      ChildTable
      ------------
      ChildID (PK)
      ParentID (FK)

      b)
      ParentTable
      ------------
      ParentID (PK)

      ChildTable
      ------------
      ParentID (PFK)

      which means for me 1:1, (and telling the truth, looks like
      generalization/specialization - am I correct or not?)



      TIA for further discussion


      Comment

      • fireball

        #4
        Re: sql code for UML composition relation - anyone?

        _strong_ aggregation (=composition)
        (weak) aggregation

        in other word's, how to make database data structure for _identyfying_
        aggregation (1..*).


        Comment

        • AlterEgo

          #5
          Re: sql code for UML composition relation - anyone?

          fireball,

          Unless I am missing something, you've already definded a strong aggregation.
          The child cannot exist without the parent - this is easy to enforce in the
          database via referential integrity.

          -- Bill


          "fireball" <fireball@onet. kropka.euwrote in message
          news:ep23rj$m4r $1@atlantis.new s.tpi.pl...
          >_strong_ aggregation (=composition)
          >(weak) aggregation
          >
          >
          in other word's, how to make database data structure for _identyfying_
          aggregation (1..*).
          >

          Comment

          Working...