469,167 Members | 1,976 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,167 developers. It's quick & easy.

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.
Jan 19 '07 #1
4 5158
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" <fi******@onet.kropka.euwrote in message
news:eo**********@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.


Jan 19 '07 #2
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
Jan 22 '07 #3
_strong_ aggregation (=composition)
(weak) aggregation

in other word's, how to make database data structure for _identyfying_
aggregation (1..*).
Jan 22 '07 #4
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" <fi******@onet.kropka.euwrote in message
news:ep**********@atlantis.news.tpi.pl...
>_strong_ aggregation (=composition)
(weak) aggregation


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

Jan 23 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Bret Pehrson | last post: by
4 posts views Thread by Frederik Vanderhaegen | last post: by
6 posts views Thread by Bart Simpson | last post: by
5 posts views Thread by jyck91 | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.